Download Dockerfile from cgmh/cropper: direct link, hf CLI and curl.
- Browser
- Download file 2.3 kB
-
https://huggingface.co/spaces/cgmh/cropper/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/cgmh/cropper/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/cgmh/cropper/resolve/main/Dockerfile
2.3 kB
| FROM python:3.10-slim | |
| RUN apt-get update && apt-get install -y git curl tesseract-ocr && rm -rf /var/lib/apt/lists/* | |
| # Node + the Claude Code CLI are for the dev container only (docker-compose sets DEV=1). | |
| # The deployed image leaves them out: less to patch, nothing it needs. | |
| ARG DEV=0 | |
| RUN if [ "$DEV" = 1 ]; then curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ | |
| && apt-get install -y nodejs && npm install -g @anthropic-ai/claude-code; fi | |
| WORKDIR /app | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # handwriting reader (TrOCR): large, and only needed for pen-written labels. | |
| # Drop this line and /api/read-names?engine=handwriting reports 503; nothing else changes. | |
| # transformers <5: v5 dropped the slow->fast tokenizer conversion TrOCR's processor | |
| # still relies on, and fails to load the model at all. sentencepiece is that path's | |
| # dependency. Weights (~1.4 GB) download on first use into HF_HOME. | |
| RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu \ | |
| && pip install --no-cache-dir "transformers>=4.40,<5" sentencepiece "jinja2>=3.1.6" | |
| # transformers <5 carries known CVEs, all in loading an attacker-chosen model, config or | |
| # checkpoint. This app loads one fixed model from local files only, so none is reachable. | |
| ENV HF_HOME=/app/.cache/huggingface | |
| # TROCR_MODEL=microsoft/trocr-small-handwritten for a ~6x smaller download | |
| # Standalone run (Hugging Face Spaces, any Docker host). docker-compose mounts the project | |
| # over /app and overrides CMD, so none of this changes local dev. Only app/ is copied: | |
| # .env and uploads/ never enter the image. Spaces run as uid 1000, hence the chmod. | |
| COPY app/ app/ | |
| # only the data folders are writable at runtime; the code is not | |
| RUN mkdir -p uploads outputs .cache && chmod 777 uploads outputs .cache | |
| # a 60000x60000 PNG is a few KB on the wire and 10 GB decoded: refuse past 250 MP | |
| ENV OPENCV_IO_MAX_IMAGE_PIXELS=250000000 | |
| # keep-alive past the proxy's own idle timeout: uvicorn's default 5 s let Hugging Face's | |
| # proxy reuse a connection uvicorn had just closed - measured, 10 of 16 requests paced | |
| # 5 s apart came back 502 ("Sorry, there is an error on our side"). | |
| CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--timeout-keep-alive", "300"] | |