Spaces:
Paused
Paused
File size: 905 Bytes
a69ec7f 0dd8a54 53cf95f a69ec7f 0dd8a54 53cf95f a69ec7f 1af59e5 a69ec7f 1af59e5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
######################## builder stage ########################
FROM python:3.9-slim AS builder
WORKDIR /build
# --- install dependencies into /install ---
COPY requirements.txt .
RUN pip install --prefix=/install --no-cache-dir -r requirements.txt
# --- copy source and compile to byte-code ---
COPY app.py .
RUN python -m compileall -b -f app.py # produces /build/app.pyc
# --- pack the .pyc into a gzip tarball ---
RUN tar -C /build -czf /build/app.tgz app.pyc
######################## runtime stage ########################
FROM python:3.9-slim
WORKDIR /app
# 1) bring in site-packages from builder
COPY --from=builder /install /usr/local/
# 2) bring in the compressed payload only
COPY --from=builder /build/app.tgz ./app.tgz
# 3) entry-point that unpacks β runs β deletes
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
EXPOSE 7860
ENTRYPOINT ["/entrypoint.sh"]
|