-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…ackend [BE][Chore] #166 : docker-compose, nginx 설정 및 백엔드 dockerfile 작성
- Loading branch information
Showing
3 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: 프론트엔드 요청 처리 (나중에 활성화) | ||
location / { | ||
root /usr/share/nginx/html; | ||
index index.html; | ||
} | ||
} | ||
} |