File tree Expand file tree Collapse file tree 1 file changed +29
-4
lines changed Expand file tree Collapse file tree 1 file changed +29
-4
lines changed Original file line number Diff line number Diff line change 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
115FROM 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
527COPY . .
28+
629EXPOSE 3000
7- CMD [ "python" , "app.py" ]
30+
31+ # Use exec form to prevent shell issues
32+ CMD ["python" , "app.py" ]
You can’t perform that action at this time.
0 commit comments