diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 00000000..3122d97e --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,29 @@ +# 1. 베이스 이미지 설정 (Node.js 18 버전 사용) +FROM node:18 + +# 2. 작업 디렉토리 설정 +WORKDIR /app + +# 3. root 폴더의 package.json, pnpm-lock.yaml, pnpm-workspace.yaml 파일을 복사 +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ + +# 4. pnpm을 설치 +RUN npm install -g pnpm + +# 5. 전체 의존성 설치 (root) +RUN pnpm install + +# 6. backend 폴더를 컨테이너로 복사 +COPY backend /app/backend + +# 7. 작업 디렉토리 backend로 이동 +WORKDIR /app/backend + +# 8. backend 의존성 설치 +RUN pnpm install + +# 9. 백엔드 실행 +CMD ["pnpm", "run", "dev"] + +#10. 백엔드 포트 설정 +EXPOSE 3001 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..b6916480 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,27 @@ +version: '3' +services: + backend: + build: + context: . + dockerfile: backend/Dockerfile + ports: + - "3001:3001" + environment: + - NODE_ENV=production + networks: + - app-network + + nginx: + image: nginx:alpine + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf + ports: + - "80:80" + networks: + - app-network + depends_on: + - backend + +networks: + app-network: + driver: bridge diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 00000000..09cc6772 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,27 @@ +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + server { + listen 80; + + location /api/ { + proxy_pass http://backend:3001; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + # TODO: 프론트엔드 요청 처리 (나중에 활성화) + location / { + root /usr/share/nginx/html; + index index.html; + } + } +}