배포 모드 전환: 프로덕션 Dockerfile + docker-compose 재구성
- frontend/Dockerfile: 멀티스테이지 (node 빌드 → serve로 dist 정적 서빙). 포트 5173은 그대로 유지해서 Caddy 설정 변경 불필요 - backend/Dockerfile: npm ci --omit=dev + npm start (node --watch 제거) - docker-compose.yml: volumes/모듈 마운트 제거, build 기반으로 변경, restart: unless-stopped, NODE_ENV=production 추가 - .dockerignore 양쪽 추가해서 이미지에 node_modules/.git 제외 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
66cafdb540
commit
ea9a6461f2
5 changed files with 35 additions and 16 deletions
3
backend/.dockerignore
Normal file
3
backend/.dockerignore
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
node_modules
|
||||||
|
.git
|
||||||
|
*.log
|
||||||
7
backend/Dockerfile
Normal file
7
backend/Dockerfile
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
FROM node:22-alpine
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm ci --omit=dev
|
||||||
|
COPY . .
|
||||||
|
EXPOSE 3000
|
||||||
|
CMD ["npm", "start"]
|
||||||
|
|
@ -1,36 +1,26 @@
|
||||||
services:
|
services:
|
||||||
frontend:
|
frontend:
|
||||||
|
build: ./frontend
|
||||||
container_name: maplestory-frontend
|
container_name: maplestory-frontend
|
||||||
image: node:22-alpine
|
|
||||||
working_dir: /app
|
|
||||||
volumes:
|
|
||||||
- ./frontend:/app
|
|
||||||
- frontend_modules:/app/node_modules
|
|
||||||
command: sh -c "npm install --legacy-peer-deps && npm run dev"
|
|
||||||
labels:
|
labels:
|
||||||
- "com.centurylinklabs.watchtower.enable=false"
|
- "com.centurylinklabs.watchtower.enable=false"
|
||||||
networks:
|
networks:
|
||||||
- caddy
|
- caddy
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
|
build: ./backend
|
||||||
container_name: maplestory-backend
|
container_name: maplestory-backend
|
||||||
image: node:22-alpine
|
|
||||||
working_dir: /app
|
|
||||||
volumes:
|
|
||||||
- ./backend:/app
|
|
||||||
- backend_modules:/app/node_modules
|
|
||||||
command: sh -c "npm install && npm run dev"
|
|
||||||
env_file: .env
|
env_file: .env
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=production
|
||||||
labels:
|
labels:
|
||||||
- "com.centurylinklabs.watchtower.enable=false"
|
- "com.centurylinklabs.watchtower.enable=false"
|
||||||
networks:
|
networks:
|
||||||
- caddy
|
- caddy
|
||||||
- db
|
- db
|
||||||
- app
|
- app
|
||||||
|
restart: unless-stopped
|
||||||
volumes:
|
|
||||||
frontend_modules:
|
|
||||||
backend_modules:
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
caddy:
|
caddy:
|
||||||
|
|
|
||||||
4
frontend/.dockerignore
Normal file
4
frontend/.dockerignore
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
.git
|
||||||
|
*.log
|
||||||
15
frontend/Dockerfile
Normal file
15
frontend/Dockerfile
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
# 빌드 단계
|
||||||
|
FROM node:22-alpine AS builder
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm ci --include=dev --legacy-peer-deps
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# 정적 파일 서빙 단계
|
||||||
|
FROM node:22-alpine
|
||||||
|
WORKDIR /app
|
||||||
|
RUN npm install -g serve
|
||||||
|
COPY --from=builder /app/dist ./dist
|
||||||
|
EXPOSE 5173
|
||||||
|
CMD ["serve", "-s", "dist", "-l", "5173"]
|
||||||
Loading…
Add table
Reference in a new issue