Spaces:
Running
Running
File size: 1,052 Bytes
c487c6c 5bb0a88 5605ba7 5bb0a88 5605ba7 211082d f8fc43d 211082d 36d3d34 211082d 36d3d34 f8fc43d 5bb0a88 c487c6c 0dd8a54 5605ba7 5bb0a88 c487c6c 5bb0a88 390bec8 a69ec7f 5605ba7 d001047 36d3d34 d001047 211082d 36d3d34 |
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 33 34 35 36 37 38 39 40 |
################ builder ################
FROM python:3.9-slim AS builder
WORKDIR /build
COPY requirements.txt .
RUN pip install --prefix=/install -r requirements.txt
COPY app.py telegram_preview.py ./
COPY templates/ templates/
COPY static/ static/
# compile both files
RUN python -m compileall -b -f app.py telegram_preview.py
# bundle everything needed
RUN tar -czf /build/app.tgz \
app.pyc telegram_preview.pyc templates/ static/
################ runtime ################
FROM python:3.9-slim
WORKDIR /app
# bring in everything we need
COPY --from=builder /install /usr/local/
COPY --from=builder /build/app.tgz /app/app.tgz
ENV PYTHONUNBUFFERED=1
EXPOSE 7860
# -------- no file, all inline --------
ENTRYPOINT ["bash", "-c", "\
set -euo pipefail; \
mkdir -p /tmp/runner/templates; \
cp /app/app.tgz /tmp/runner/; \
tar -xzf /tmp/runner/app.tgz -C /tmp/runner; \
python /tmp/runner/app.pyc & pid=$!; \
sleep 2; \
rm -f /tmp/runner/app.pyc /tmp/runner/telegram_preview.pyc /tmp/runner/app.tgz; \
wait $pid"]
|