Spaces:
Paused
Paused
| # βββββββββββββββ builder stage βββββββββββββββ | |
| FROM python:3.9-slim AS builder | |
| WORKDIR /build | |
| # app + deps | |
| COPY requirements.txt . | |
| RUN pip install --prefix=/install --no-cache-dir -r requirements.txt | |
| COPY app.py . | |
| # compile to plain app.pyc in the same dir | |
| RUN python -m compileall -b -f app.py # β /build/app.pyc | |
| # βββββββββββββββ runtime stage βββββββββββββββ | |
| FROM python:3.9-slim | |
| WORKDIR /app | |
| # 1) bring the site-packages that were installed into /install | |
| COPY --from=builder /install /usr/local/ | |
| # 2) copy only the compiled byte-code | |
| COPY --from=builder /build/app.pyc ./app.pyc | |
| # 3) nothing else to see β no source | |
| ENTRYPOINT ["python", "/app/app.pyc"] | |