Skip to content

Commit e9e2027

Browse files
authored
Update Dockerfile
1 parent 55aa042 commit e9e2027

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

Dockerfile

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,32 @@
1+
FROM python:3.11-alpine3.17 AS builder
2+
3+
# Set working directory
4+
WORKDIR /usr/src/app
5+
6+
# Install build dependencies
7+
RUN apk add --no-cache --virtual .build-deps \
8+
gcc musl-dev libffi-dev
9+
10+
# Install Python dependencies
11+
COPY requirements.txt .
12+
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
13+
14+
# Final lightweight runtime image
115
FROM python:3.11-alpine3.17
2-
WORKDIR /usr/app
3-
COPY requirements.txt /usr/app/
4-
RUN pip install -r requirements.txt
16+
17+
WORKDIR /usr/src/app
18+
19+
# Create non-root user
20+
RUN addgroup -S app && adduser -S app -G app
21+
USER app
22+
23+
# Copy installed dependencies from builder
24+
COPY --from=builder /install /usr/local
25+
26+
# Copy app source
527
COPY . .
28+
629
EXPOSE 3000
7-
CMD [ "python", "app.py" ]
30+
31+
# Use exec form to prevent shell issues
32+
CMD ["python", "app.py"]

0 commit comments

Comments
 (0)