Skip to content

Commit

Permalink
Merge pull request #175 from boostcampwm-2024/backend
Browse files Browse the repository at this point in the history
[BE][Chore] #166 : docker-compose, nginx ์„ค์ • ๋ฐ ๋ฐฑ์—”๋“œ dockerfile ์ž‘์„ฑ
  • Loading branch information
happyhyep authored Nov 14, 2024
2 parents 380d6a1 + 20bc0b4 commit 76ffef4
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
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: ํ”„๋ก ํŠธ์—”๋“œ ์š”์ฒญ ์ฒ˜๋ฆฌ (๋‚˜์ค‘์— ํ™œ์„ฑํ™”)
location / {
root /usr/share/nginx/html;
index index.html;
}
}
}

0 comments on commit 76ffef4

Please sign in to comment.