logging_bot / Dockerfile
AstraOS's picture
Update Dockerfile
f8fc43d verified
################ 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"]