Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE][Chore] #166 : docker-compose, nginx 설정 및 백엔드 dockerfile 작성 #171

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -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: 프론트엔드 요청 처리 (나중에 활성화)
happyhyep marked this conversation as resolved.
Show resolved Hide resolved
location / {
root /usr/share/nginx/html;
index index.html;
}
}
}
Loading