favicon-api-v3/Dockerfile

37 lines
741 B
Docker

FROM python:3.12-slim AS builder
WORKDIR /app
COPY requirements.txt .
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.txt
COPY . .
RUN python -m compileall -b .
FROM python:3.12-slim
WORKDIR /app
COPY --from=builder /app/wheels /wheels
COPY --from=builder /app/requirements.txt .
RUN pip install --no-cache /wheels/*
COPY --from=builder /app /app
RUN find . -type d -name "__pycache__" | while read -r dir; do \
module_dir=$(dirname "$dir"); \
mv "$dir"/*.pyc "$module_dir/"; \
rmdir "$dir"; \
done
RUN find . -name "*.py" -delete
EXPOSE 8000
VOLUME ["/app/data", "/app/conf", "/app/logs"]
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["gunicorn", "-c", "conf/gunicorn.conf.py", "main:app"]