Skip to content

Commit

Permalink
Merge pull request #282 from boostcampwm-2024/chore/be/dockerDeploy
Browse files Browse the repository at this point in the history
[BE][Chore] FE ์ปจํ…Œ์ด๋„ˆ Workdir ์ƒ์„ฑ ์•ˆ๋˜๋Š” ๋ฌธ์ œ ํ•ด๊ฒฐ
  • Loading branch information
happyhyep authored Nov 26, 2024
2 parents 117e1b4 + d02c266 commit 7d19e99
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
8 changes: 4 additions & 4 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# 1. ๋ฒ ์ด์Šค ์ด๋ฏธ์ง€ ์„ค์ • (Node.js 18 ๋ฒ„์ „ ์‚ฌ์šฉ)
FROM node:18

# 2. ์ž‘์—… ๋””๋ ‰ํ† ๋ฆฌ ์„ค์ •
WORKDIR /app
# 2. ์ž‘์—… ๋””๋ ‰ํ† ๋ฆฌ ์„ค์ • (๋ฐฑ์—”๋“œ ๋””๋ ‰ํ† ๋ฆฌ)
WORKDIR /backend-app

# 3. root ํด๋”์˜ package.json, pnpm-lock.yaml, pnpm-workspace.yaml ํŒŒ์ผ์„ ๋ณต์‚ฌ
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
Expand All @@ -14,10 +14,10 @@ RUN npm install -g pnpm
RUN pnpm install

# 6. backend ํด๋”๋ฅผ ์ปจํ…Œ์ด๋„ˆ๋กœ ๋ณต์‚ฌ
COPY backend /app/backend
COPY backend /backend-app/backend

# 7. ์ž‘์—… ๋””๋ ‰ํ† ๋ฆฌ backend๋กœ ์ด๋™
WORKDIR /app/backend
WORKDIR /backend-app/backend

# 8. backend ์˜์กด์„ฑ ์„ค์น˜
RUN pnpm install
Expand Down
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ services:
- NODE_ENV=production
networks:
- app-network
volumes:
- ./backend:/backend-app

frontend:
build:
context: .
dockerfile: frontend/Dockerfile
networks:
- app-network
depends_on:
- backend
volumes:
- ./frontend:/frontend-app

nginx:
image: nginx:alpine
Expand Down
14 changes: 7 additions & 7 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# 1. ๋ฒ ์ด์Šค ์ด๋ฏธ์ง€ ์„ค์ • (Node.js 18 ์‚ฌ์šฉ)
FROM node:18 AS builder

# 2. ์ž‘์—… ๋””๋ ‰ํ† ๋ฆฌ ์„ค์ •
WORKDIR /app
# 2. ์ž‘์—… ๋””๋ ‰ํ† ๋ฆฌ ์„ค์ • (ํ”„๋ก ํŠธ์—”๋“œ ๋””๋ ‰ํ† ๋ฆฌ)
WORKDIR /frontend-app

# 3. root์˜ ํŒจํ‚ค์ง€ ํŒŒ์ผ ๋ณต์‚ฌ
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
Expand All @@ -14,18 +14,18 @@ RUN npm install -g pnpm
RUN pnpm install

# 6. ํ”„๋ก ํŠธ์—”๋“œ ํด๋” ๋ณต์‚ฌ
COPY frontend /app/frontend
COPY frontend /frontend-app/frontend

# 7. ์ž‘์—… ๋””๋ ‰ํ† ๋ฆฌ ๋ณ€๊ฒฝ
WORKDIR /app/frontend
WORKDIR /frontend-app/frontend

# 8. frontend ์˜์กด์„ฑ ์„ค์น˜
RUN pnpm install

# 8. ๋นŒ๋“œ ์‹คํ–‰
# 9. ๋นŒ๋“œ ์‹คํ–‰
RUN pnpm build

# 9. Nginx ์ด๋ฏธ์ง€๋ฅผ ์‚ฌ์šฉํ•ด ์ •์  ํŒŒ์ผ ์ œ๊ณต
# 10. Nginx ์ด๋ฏธ์ง€๋ฅผ ์‚ฌ์šฉํ•ด ์ •์  ํŒŒ์ผ ์ œ๊ณต
FROM nginx:alpine
COPY --from=builder /app/frontend/dist /usr/share/nginx/html
COPY --from=builder /frontend-app/frontend/dist /usr/share/nginx/html
EXPOSE 80
8 changes: 4 additions & 4 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ http {
}

location / {
proxy_pass http://frontend:80;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
root /usr/share/nginx/html;
index index.html;

try_files $uri /index.html;
}
}
}

0 comments on commit 7d19e99

Please sign in to comment.