services: classify: image: ghcr.io/ufal/atrium-page-classification:${ATRIUM_VERSION:-dev} # The host uid, group 0 (atrium-project#69, roadmap B6). ./data and ./data/output are in # the clone (their .gitkeep files), owned by whoever cloned it, while the image runs as # uid 10001 by default -- so without this the results written to /app/result (the # ./data/output mount) fail with EACCES. Every path the image writes is group-0 # writable, so any uid with group 0 works. On Linux set ATRIUM_UID in .env # (`echo "ATRIUM_UID=$(id -u)" >> .env`); Docker Desktop needs nothing. Unset, this is # the image's own uid 10001. Inherited by `api` through `extends:`. user: "${ATRIUM_UID:-10001}:0" build: context: . args: ATRIUM_RUNNER_IMAGE: ghcr.io/ufal/atrium-page-classification:${ATRIUM_VERSION:-dev} ATRIUM_RUNNER_REPO: https://github.com/ufal/atrium-page-classification ATRIUM_RUNNER_REF: ${ATRIUM_RUNNER_REF:-dev} environment: ATRIUM_RUNNER_IMAGE: ghcr.io/ufal/atrium-page-classification:${ATRIUM_VERSION:-dev} ATRIUM_RUNNER_REPO: https://github.com/ufal/atrium-page-classification ATRIUM_RUNNER_REF: ${ATRIUM_RUNNER_REF:-dev} HF_HOME: /cache/huggingface # HF_TOKEN: ${HF_TOKEN:-} # only for gated models / push_to_hub volumes: - ./data:/data # inputs read from ./data/input - ./data/output:/app/result # results + paradata land here on the host - page-model:/app/model # downloaded ViT weights persist across runs - hf-cache:/cache/huggingface # HF hub cache (models never baked into the image) # FastAPI service — opt-in: docker compose --profile api up api api: extends: service: classify profiles: ["api"] # issue #55: builds the Dockerfile's own `api` stage instead of overriding the batch # image's entrypoint here. The old `entrypoint: ["uvicorn", ...]` line was the ONLY # place this service's start command existed, so no runnable API image was ever # published (nothing to `docker pull` for Kubernetes) and the Dockerfile's # HEALTHCHECK/STOPSIGNAL could not apply to it. Publishing the stage also removes # the duplicate copy of the uvicorn command line. # # The published name (atrium-project#69, roadmap B2): `-api` is part of the image NAME, # as docker-tool.reusable.yml publishes it, so `ATRIUM_VERSION=1.8.0-beta docker compose # --profile api pull` fetches the released image. The old `…:-api` tag was # never published by any build. image: ghcr.io/ufal/atrium-page-classification-api:${ATRIUM_VERSION:-dev} build: context: . target: api args: ATRIUM_RUNNER_IMAGE: ghcr.io/ufal/atrium-page-classification-api:${ATRIUM_VERSION:-dev} ATRIUM_RUNNER_REPO: https://github.com/ufal/atrium-page-classification ATRIUM_RUNNER_REF: ${ATRIUM_RUNNER_REF:-dev} # env_file delivers every OTHER variable in .env.example into the container -- # LOG_LEVEL, GRACEFUL_SHUTDOWN_S, HOST, RELOAD, HEALTHCHECK_PATH and MAX_UPLOAD_MB # were all documented but undeliverable under compose until atrium-project#60 # added this. `required: false` because .env is gitignored -- a fresh clone has # none and compose must still start. env_file: - path: .env required: false environment: # ATRIUM_RUNNER_IMAGE is overridden here on purpose: the build arg above # correctly names this stage's image "...-api", but `extends: classify` (above) # inherits classify's environment: block, whose ATRIUM_RUNNER_IMAGE has no # such suffix -- so without this line, paradata recorded the BATCH image tag # for requests served by the API image. (atrium-project#60) ATRIUM_RUNNER_IMAGE: ghcr.io/ufal/atrium-page-classification-api:${ATRIUM_VERSION:-dev} ALLOWED_ORIGINS: ${ALLOWED_ORIGINS:-http://localhost:8080,http://127.0.0.1:8080} PORT: ${PORT:-8000} ports: # PORT is passed through so `PORT=9000 docker compose --profile api up` moves the # listener, the published port and the container's own HEALTHCHECK together — the # service reads it in service/api.py's __main__ block and service/healthcheck.py # probes it. (atrium-project#58) - "${PORT:-8000}:${PORT:-8000}" # HEALTHCHECK comes from the `api` stage — no override needed. stop_grace_period # raised from Compose's 10s default: the stage allows uvicorn 20s to drain in-flight # requests plus up to 25s in serve_lifecycle, so 10s would SIGKILL mid-drain. Matches # atrium-project/docs/templates/k8s/atrium-service.deployment.yaml's budget. stop_grace_period: 60s volumes: page-model: hf-cache: