Skip to content

Commit 289be6d

Browse files
committed
Refactor Dockerfile to use multi-stage build
1 parent f253db2 commit 289be6d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Dockerfile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1-
FROM python:3.10.7-slim-buster
1+
# Stage 1: Build
2+
FROM python:3.10.7-slim-buster as builder
23

34
WORKDIR /app
45

5-
RUN mkdir -p /tmp/outputs
6-
76
COPY requirements.txt .
87

8+
# Install build dependencies and libraries
99
RUN pip install --no-cache-dir -r requirements.txt
1010

11+
12+
# Stage 2: Production
13+
FROM python:3.10.7-slim-buster as production
14+
15+
WORKDIR /app
16+
1117
COPY . .
1218

19+
# Copy only the compiled result from previous stage
20+
COPY --from=builder /app .
21+
1322
CMD ["python", "main.py"]

0 commit comments

Comments
 (0)