Skip to content

Commit a3af846

Browse files
Nuungsix-standard
andauthored
[25.01.05 / TASK-91] Feature - deploy 세팅 (#8)
* feature: dockerfile 과 github action 에서 docker image CI CD 환경 구성 * modify: readme 수정 * feature: 2차 배포 세팅 * refactor: devDependencies에서 sentry dependencies로 sentry 이동 * hotfix: fixed deploy * hotfix: 로그인 오토필 관련 오류 해결 * modify: standalone 설정을 위한 dockerfile update * modify: git action 에 workflow_dispatch: 추가 * hotfix: 데이터 타입 맞춤 * refactor: 타입 맞춤 * hotfix: env ignore 이슈 해결 * hotfix: 커서 관련 오류 해결 * modify: action version --------- Co-authored-by: six-standard <dbrrl1127@gmail.com>
1 parent d399a2c commit a3af846

File tree

9 files changed

+357
-15
lines changed

9 files changed

+357
-15
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
build-and-push:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 23
21+
22+
- name: Install dependencies
23+
run: |
24+
npm install -g pnpm
25+
pnpm install --frozen-lockfile
26+
27+
- name: Build Next.js application
28+
run: |
29+
pnpm run build
30+
31+
# Docker 로그인
32+
- name: Log in to Docker Hub
33+
uses: docker/login-action@v3
34+
with:
35+
username: ${{ secrets.DOCKER_USERNAME }}
36+
password: ${{ secrets.DOCKER_PASSWORD }}
37+
38+
# Docker 이미지 빌드
39+
- name: Build Docker Image
40+
run: |
41+
docker build -t velog-dashboard-v2-fe:latest .
42+
43+
# Docker Hub에 푸시
44+
- name: Push Docker Image
45+
run: |
46+
docker tag velog-dashboard-v2-fe:latest ${{ secrets.DOCKER_USERNAME }}/velog-dashboard-v2-fe:latest
47+
docker push ${{ secrets.DOCKER_USERNAME }}/velog-dashboard-v2-fe:latest

.gitignore

Lines changed: 242 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,59 @@
1-
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
1+
# Created by https://www.toptal.com/developers/gitignore/api/windows,macos,visualstudiocode,nextjs,react,git,node
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=windows,macos,visualstudiocode,nextjs,react,git,node
23

4+
### Git ###
5+
# Created by git for backups. To disable backups in Git:
6+
# $ git config --global mergetool.keepBackup false
7+
*.orig
8+
9+
# Created by git when using merge tools for conflicts
10+
*.BACKUP.*
11+
*.BASE.*
12+
*.LOCAL.*
13+
*.REMOTE.*
14+
*_BACKUP_*.txt
15+
*_BASE_*.txt
16+
*_LOCAL_*.txt
17+
*_REMOTE_*.txt
18+
19+
### macOS ###
20+
# General
21+
.DS_Store
22+
.AppleDouble
23+
.LSOverride
24+
25+
# Icon must end with two \r
26+
Icon
27+
28+
29+
# Thumbnails
30+
._*
31+
32+
# Files that might appear in the root of a volume
33+
.DocumentRevisions-V100
34+
.fseventsd
35+
.Spotlight-V100
36+
.TemporaryItems
37+
.Trashes
38+
.VolumeIcon.icns
39+
.com.apple.timemachine.donotpresent
40+
41+
# Directories potentially created on remote AFP share
42+
.AppleDB
43+
.AppleDesktop
44+
Network Trash Folder
45+
Temporary Items
46+
.apdisk
47+
48+
### macOS Patch ###
49+
# iCloud generated files
50+
*.icloud
51+
52+
### NextJS ###
353
# dependencies
454
/node_modules
555
/.pnp
656
.pnp.js
7-
.yarn/install-state.gz
857

958
# testing
1059
/coverage
@@ -17,16 +66,13 @@
1766
/build
1867

1968
# misc
20-
.DS_Store
2169
*.pem
2270

2371
# debug
2472
npm-debug.log*
2573
yarn-debug.log*
2674
yarn-error.log*
27-
28-
# local env files
29-
.env*.local
75+
.pnpm-debug.log*
3076

3177
# vercel
3278
.vercel
@@ -35,7 +81,195 @@ yarn-error.log*
3581
*.tsbuildinfo
3682
next-env.d.ts
3783

84+
# envs
3885
.env*
86+
!.env.sample
87+
88+
# Diagnostic reports (https://nodejs.org/api/report.html)
89+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
90+
91+
# Runtime data
92+
pids
93+
*.pid
94+
*.seed
95+
*.pid.lock
96+
97+
# Directory for instrumented libs generated by jscoverage/JSCover
98+
lib-cov
99+
100+
# Coverage directory used by tools like istanbul
101+
coverage
102+
*.lcov
103+
104+
# nyc test coverage
105+
.nyc_output
106+
107+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
108+
.grunt
109+
110+
# Bower dependency directory (https://bower.io/)
111+
bower_components
112+
113+
# node-waf configuration
114+
.lock-wscript
115+
116+
# Compiled binary addons (https://nodejs.org/api/addons.html)
117+
build/Release
118+
119+
# Dependency directories
120+
node_modules/
121+
jspm_packages/
122+
123+
# Snowpack dependency directory (https://snowpack.dev/)
124+
web_modules/
125+
126+
# TypeScript cache
127+
128+
# Optional npm cache directory
129+
.npm
130+
131+
# Optional eslint cache
132+
.eslintcache
133+
134+
# Optional stylelint cache
135+
.stylelintcache
136+
137+
# Microbundle cache
138+
.rpt2_cache/
139+
.rts2_cache_cjs/
140+
.rts2_cache_es/
141+
.rts2_cache_umd/
142+
143+
# Optional REPL history
144+
.node_repl_history
145+
146+
# Output of 'npm pack'
147+
*.tgz
148+
149+
# Yarn Integrity file
150+
.yarn-integrity
151+
152+
# dotenv environment variable files
153+
.env
154+
.env.development.local
155+
.env.test.local
156+
.env.production.local
157+
.env.local
158+
159+
# parcel-bundler cache (https://parceljs.org/)
160+
.cache
161+
.parcel-cache
162+
163+
# Next.js build output
164+
.next
165+
out
166+
167+
# Nuxt.js build / generate output
168+
.nuxt
169+
dist
170+
171+
# Gatsby files
172+
.cache/
173+
# Comment in the public line in if your project uses Gatsby and not Next.js
174+
# https://nextjs.org/blog/next-9-1#public-directory-support
175+
# public
176+
177+
# vuepress build output
178+
.vuepress/dist
179+
180+
# vuepress v2.x temp and cache directory
181+
.temp
182+
183+
# Docusaurus cache and generated files
184+
.docusaurus
185+
186+
# Serverless directories
187+
.serverless/
188+
189+
# FuseBox cache
190+
.fusebox/
191+
192+
# DynamoDB Local files
193+
.dynamodb/
194+
195+
# TernJS port file
196+
.tern-port
197+
198+
# Stores VSCode versions used for testing VSCode extensions
199+
.vscode-test
200+
201+
# yarn v2
202+
.yarn/cache
203+
.yarn/unplugged
204+
.yarn/build-state.yml
205+
.yarn/install-state.gz
206+
.pnp.*
207+
208+
### Node Patch ###
209+
# Serverless Webpack directories
210+
.webpack/
211+
212+
# Optional stylelint cache
213+
214+
# SvelteKit build / generate output
215+
.svelte-kit
216+
217+
### react ###
218+
.DS_*
219+
**/*.backup.*
220+
**/*.back.*
221+
222+
node_modules
223+
224+
*.sublime*
225+
226+
psd
227+
thumb
228+
sketch
229+
230+
### VisualStudioCode ###
231+
.vscode/*
232+
!.vscode/settings.json
233+
!.vscode/tasks.json
234+
!.vscode/launch.json
235+
!.vscode/extensions.json
236+
!.vscode/*.code-snippets
237+
238+
# Local History for Visual Studio Code
239+
.history/
240+
241+
# Built Visual Studio Code Extensions
242+
*.vsix
243+
244+
### VisualStudioCode Patch ###
245+
# Ignore all local history of files
246+
.history
247+
.ionide
248+
249+
### Windows ###
250+
# Windows thumbnail cache files
251+
Thumbs.db
252+
Thumbs.db:encryptable
253+
ehthumbs.db
254+
ehthumbs_vista.db
255+
256+
# Dump file
257+
*.stackdump
258+
259+
# Folder config file
260+
[Dd]esktop.ini
261+
262+
# Recycle Bin used on file shares
263+
$RECYCLE.BIN/
264+
265+
# Windows Installer files
266+
*.cab
267+
*.msi
268+
*.msix
269+
*.msm
270+
*.msp
271+
272+
# Windows shortcuts
273+
*.lnk
39274

40-
# Sentry Config File
41-
.env.sentry-build-plugin
275+
# End of https://www.toptal.com/developers/gitignore/api/windows,macos,visualstudiocode,nextjs,react,git,node

Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM node:23-alpine
2+
3+
WORKDIR /usr/src/app
4+
5+
RUN npm install -g pnpm pm2
6+
7+
# 기존 빌드된 파일들과 필요한 설정 파일들 복사
8+
COPY next.config.mjs ecosystem.config.js ./
9+
COPY .next/standalone ./
10+
COPY .next/static ./.next/static
11+
COPY public ./public
12+
COPY .env ./.env
13+
COPY .env.production ./.env.production
14+
15+
# 프로덕션 의존성만 설치
16+
COPY package.json pnpm-lock.yaml ./
17+
RUN pnpm install --no-frozen-lockfile --prod
18+
19+
EXPOSE 3000
20+
21+
CMD ["pm2-runtime", "start", "ecosystem.config.js"]

ecosystem.config.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// @ts-nocheck
2+
module.exports = {
3+
apps: [
4+
{
5+
name: 'velog-dashboard-v2-fe',
6+
script: 'node',
7+
args: './server.js',
8+
instances: 1,
9+
autorestart: true,
10+
watch: false,
11+
max_memory_restart: '1G',
12+
env: {
13+
NODE_ENV: 'production',
14+
},
15+
error_file: 'logs/next-err.log',
16+
out_file: 'logs/next-out.log',
17+
log_date_format: 'YYYY-MM-DD HH:mm:ss',
18+
restart_delay: 4000,
19+
},
20+
],
21+
};

next.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { withSentryConfig } from '@sentry/nextjs';
22
/** @type {import('next').NextConfig} */
33
const nextConfig = {
4-
reactStrictMode: false,
4+
reactStrictMode: true,
55
experimental: { forceSwcTransforms: true },
6+
output: 'standalone',
67

78
webpack: (config, options) => {
89
config.module.rules.push({

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"test": "jest"
1313
},
1414
"dependencies": {
15+
"@sentry/nextjs": "^8.47.0",
1516
"@tanstack/react-query": "^5.61.3",
1617
"@tanstack/react-query-devtools": "^5.62.11",
1718
"chart.js": "^4.4.7",
@@ -27,7 +28,6 @@
2728
},
2829
"devDependencies": {
2930
"@eslint/js": "^9.15.0",
30-
"@sentry/nextjs": "^8.47.0",
3131
"@svgr/webpack": "^8.1.0",
3232
"@testing-library/jest-dom": "^6.6.3",
3333
"@testing-library/react": "^16.0.1",

0 commit comments

Comments
 (0)