Skip to content

Commit 0887b6c

Browse files
committed
docker 파일 업데이트
1 parent b63377b commit 0887b6c

File tree

4 files changed

+63
-10
lines changed

4 files changed

+63
-10
lines changed

app/BE/main.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ def create_app() -> FastAPI:
2121

2222
# React 개발 서버와 연동하기 위한 CORS 설정
2323
origins = [
24-
"http://localhost:3001",
24+
"http://localhost:3001", # 로컬 개발 환경
25+
"http://frontend:3001", # Docker Compose 환경
2526
]
2627
app.add_middleware(
2728
CORSMiddleware,

app/Dockerfile

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
# 베이스 이미지 선택
2-
FROM python:3.13
1+
# 1️⃣ 베이스 이미지 선택 (최적화)
2+
FROM python:3.11
33

4-
# 작업 디렉토리 설정
4+
# 2️⃣ 작업 디렉토리 설정
55
WORKDIR /app
66

7-
# 의존성 파일 복사 및 설치
8-
COPY BE/requirements.txt /app/requirements.txt
9-
RUN pip install --upgrade pip && pip install -r requirements.txt
7+
# 3️⃣ 의존성 파일 복사 및 설치
8+
COPY BE/requirements.txt .
9+
RUN pip install --no-cache-dir -r requirements.txt
1010

11-
# 프로젝트 전체 파일을 컨테이너로 복사
12-
COPY . /app
11+
# 4️⃣ 프로젝트 전체 파일을 복사
12+
COPY BE /app
1313

14-
# uvicorn으로 FastAPI 애플리케이션 실행 (main.py의 app 객체를 실행)
14+
# 5️⃣ FastAPI 실행
1515
CMD ["uvicorn", "BE.main:app", "--host", "0.0.0.0", "--port", "80"]

app/docker-compose.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
version: "3.8"
2+
3+
services:
4+
backend:
5+
build:
6+
context: . # 🔥 프로젝트 루트에서 Backend Dockerfile을 사용
7+
dockerfile: Dockerfile # 🔥 Backend의 Dockerfile이 project-root/에 있음
8+
container_name: backend
9+
ports:
10+
- "8000:80"
11+
volumes:
12+
- ./BE:/app # 🔥 Backend 코드가 있는 `BE/` 폴더를 컨테이너에 마운트
13+
networks:
14+
- mynetwork
15+
16+
frontend:
17+
build:
18+
context: ./frontend
19+
dockerfile: Dockerfile
20+
container_name: frontend
21+
ports:
22+
- "3001:3001"
23+
volumes:
24+
- ./frontend:/frontend
25+
- /frontend/node_modules
26+
networks:
27+
- mynetwork
28+
depends_on:
29+
- backend
30+
31+
networks:
32+
mynetwork:
33+
driver: bridge

app/frontend/Dockerfile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# 1️⃣ 베이스 이미지 선택
2+
FROM node:16-alpine
3+
4+
# 2️⃣ 작업 디렉토리 설정
5+
WORKDIR /app
6+
7+
# 3️⃣ frontend 폴더 내부의 package.json 파일 복사
8+
COPY frontend/package*.json ./
9+
10+
# 4️⃣ npm 패키지 설치
11+
RUN npm install
12+
13+
# 5️⃣ frontend 코드 전체 복사
14+
COPY frontend/ ./
15+
16+
# 6️⃣ static 폴더 복사
17+
COPY static/ ./static
18+
19+
# (필요 시 CMD 또는 ENTRYPOINT 추가)

0 commit comments

Comments
 (0)