Spaces:
Running
Running
Download Dockerfile from mertkayacs/postkitty-api: direct link, hf CLI and curl.
- Browser
- Download file 2.85 kB
-
https://huggingface.co/spaces/mertkayacs/postkitty-api/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/mertkayacs/postkitty-api/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/mertkayacs/postkitty-api/resolve/main/Dockerfile
2.85 kB
| # postkitty API as a Hugging Face Docker Space. | |
| # Ubuntu 24.04 ships Python 3.12 and ffmpeg 6.1, the pair the engine's own test suite runs on. | |
| FROM ubuntu:24.04 | |
| ENV DEBIAN_FRONTEND=noninteractive \ | |
| PYTHONUNBUFFERED=1 | |
| # Burned-in captions are drawn by libass, which draws nothing, without an error, for a script no installed | |
| # font covers. Liberation is the Arial-shaped family the caption style asks for (Latin, Greek, Cyrillic), | |
| # Noto core adds Arabic, Hebrew and the other non-CJK scripts, Noto CJK adds Chinese, Japanese and Korean. | |
| RUN apt-get update \ | |
| && apt-get install -y --no-install-recommends python3 python3-venv ffmpeg ca-certificates \ | |
| fontconfig fonts-liberation fonts-noto-core fonts-noto-cjk \ | |
| && rm -rf /var/lib/apt/lists/* \ | |
| && fc-cache -f | |
| # Stop the build when this ffmpeg cannot burn captions (ass) or tone-map HDR (zscale), or a script has no font. | |
| RUN ffmpeg -hide_banner -filters | grep -E " (ass|zscale) +V->V" \ | |
| && test "$(ffmpeg -hide_banner -filters | grep -cE " (ass|zscale) +V->V")" = 2 \ | |
| && for lang in en el ru ar he hi th zh ja ko; do \ | |
| fc-list ":lang=$lang" family | grep -q . || { echo "no font covers $lang"; exit 1; }; \ | |
| done \ | |
| && fc-match Arial | |
| COPY requirements.txt /tmp/requirements.txt | |
| RUN python3 -m venv /opt/venv \ | |
| && /opt/venv/bin/pip install --no-cache-dir -r /tmp/requirements.txt | |
| # The engine, pinned by commit. Its repository root is the Python package, so it is unpacked into a | |
| # folder named postkitty and that folder's parent goes on the import path. | |
| ARG POSTKITTY_REF=06a80a50a445cc8eaf223cb334eb3fd28fc2ba22 | |
| ADD https://github.com/mertkayacs/postkitty/archive/${POSTKITTY_REF}.tar.gz /tmp/engine.tar.gz | |
| RUN mkdir -p /opt/engine/postkitty \ | |
| && tar -xzf /tmp/engine.tar.gz --strip-components=1 -C /opt/engine/postkitty \ | |
| && rm /tmp/engine.tar.gz \ | |
| && /opt/venv/bin/python -m compileall -q /opt/engine | |
| # The engine's Python packages come from the engine's own list at this commit, so the two cannot drift. | |
| COPY engine_requirements.py /tmp/engine_requirements.py | |
| RUN /opt/venv/bin/python /tmp/engine_requirements.py /opt/engine/postkitty > /tmp/engine-requirements.txt \ | |
| && cat /tmp/engine-requirements.txt \ | |
| && /opt/venv/bin/pip install --no-cache-dir -r /tmp/engine-requirements.txt | |
| ENV POSTKITTY_REF=${POSTKITTY_REF} \ | |
| PYTHONPATH=/opt/engine \ | |
| PATH=/opt/venv/bin:$PATH \ | |
| HOME=/home/ubuntu \ | |
| POSTKITTY_API_DATA=/tmp/postkitty-api | |
| # Spaces run the container as user id 1000, which is the image's built-in ubuntu user. | |
| USER ubuntu | |
| WORKDIR /home/ubuntu/app | |
| COPY --chown=ubuntu app ./app | |
| # Fetch the face model at build time so the first job does not wait for a download. | |
| RUN python -c "from app import engine; print(engine.fetch_model())" | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--no-access-log"] | |