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] volumes로 app 디렉토리 공유하도록 변경 #284

Merged
merged 1 commit into from
Nov 26, 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
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 /backend-app
# 2. 작업 디렉토리 설정
WORKDIR /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 /backend-app/backend
COPY backend /app/backend

# 7. 작업 디렉토리 backend로 이동
WORKDIR /backend-app/backend
WORKDIR /app/backend

# 8. backend 의존성 설치
RUN pnpm install
Expand Down
10 changes: 8 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ services:
networks:
- app-network
volumes:
- ./backend:/backend-app
- .:/app
- /app/node_modules
- /app/backend/node_modules

frontend:
build:
Expand All @@ -18,7 +20,11 @@ services:
networks:
- app-network
volumes:
- ./frontend:/frontend-app
- .:/app
- /app/node_modules
- /app/frontend/node_modules
depends_on:
- backend

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 /frontend-app
# 2. 작업 디렉토리 설정
WORKDIR /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 /frontend-app/frontend
COPY frontend /app/frontend

# 7. 작업 디렉토리 변경
WORKDIR /frontend-app/frontend
WORKDIR /app/frontend

# 8. frontend 의존성 설치
RUN pnpm install

# 9. 빌드 실행
# 8. 빌드 실행
RUN pnpm build

# 10. Nginx 이미지를 사용해 정적 파일 제공
# 9. Nginx 이미지를 사용해 정적 파일 제공
FROM nginx:alpine
COPY --from=builder /frontend-app/frontend/dist /usr/share/nginx/html
COPY --from=builder /app/frontend/dist /usr/share/nginx/html
EXPOSE 80
Loading