Spaces:
Running
Running
# ---------- stage 1: build ---------- | |
FROM python:3.9-slim AS builder | |
WORKDIR /src | |
COPY . . | |
RUN pip install --prefix=/install --no-cache-dir -r requirements.txt | |
# optional: compile to .pyc or a zipapp | |
RUN python -m compileall -b app.py | |
# ---------- stage 2: runtime ---------- | |
FROM python:3.9-slim | |
WORKDIR /app | |
# bring in only what you need | |
COPY --from=builder /install /usr/local | |
COPY --from=builder /src/app.pyc ./app.pyc | |
ENTRYPOINT ["python", "app.pyc"] |