Spaces:
Sleeping
Sleeping
File size: 1,901 Bytes
36a47ad 2b4d551 36a47ad 2b4d551 36a47ad 2b4d551 36a47ad 2b4d551 36a47ad 2b4d551 36a47ad | 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 41 42 43 44 45 46 47 | # syntax=docker/dockerfile:1.7
# The Hugging Face Space's image. Anyone can pull a public Space's image, so it holds no engine
# code: boot.py downloads the engines from the private model repo when the container starts.
# The base stage matches the one in the repo's own Dockerfile.
FROM ghcr.io/astral-sh/uv:0.13.4@sha256:9f130421e930bfbdc563c00740466603f8723158e90297d07957c2294640262b AS uv
FROM python:3.12-slim-trixie@sha256:2259debdc6af85626058a15a7bf44ad6a68b8c98c9ae82a02cf5cdb92f096d47 AS base
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# The bank engine imports tkinter at the top. This Python's _tkinter links libtk8.6; Debian's
# python3-tk is built for Debian's own Python, not this one.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libtk8.6 poppler-utils tesseract-ocr tesseract-ocr-eng tini \
&& rm -rf /var/lib/apt/lists/* \
&& useradd --create-home --uid 1000 user
FROM base AS build
COPY --from=uv /uv /usr/local/bin/uv
ENV UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy \
UV_PYTHON_DOWNLOADS=never \
UV_PROJECT_ENVIRONMENT=/opt/venv
WORKDIR /src
COPY pyproject.toml uv.lock ./
RUN --mount=type=cache,target=/root/.cache/uv uv sync --locked --no-dev
FROM base AS runtime
COPY --from=build /opt/venv /opt/venv
RUN install -d -o 1000 -g 1000 /opt/engines
WORKDIR /app
COPY docker/engines.py boot.py /opt/boot/
COPY engines.lock ./
COPY app ./app
ENV PATH=/opt/venv/bin:$PATH \
AA_ENGINE_ROOT=/opt/engines \
AA_TESSERACT_CMD=/usr/bin/tesseract \
AA_POPPLER_PATH=/usr/bin \
AA_JOBS_ROOT=/tmp/audit-automation-jobs
USER 1000
EXPOSE 7860
# boot.py execs tini, so tini stays PID 1 and reaps the tesseract and pdftoppm children of a
# worker the runner kills.
ENTRYPOINT ["python", "/opt/boot/boot.py", "tini", "--"]
CMD ["uvicorn", "app.main:create_app", "--factory", "--host", "0.0.0.0", "--port", "7860"]
|