Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (34 loc) · 2.14 KB
/
Copy pathDockerfile
File metadata and controls
42 lines (34 loc) · 2.14 KB
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
# chapkit_minimalist_example_r Dockerfile
# chapkit-r-inla ships R 4.5 + INLA + the spatial / time-series stack (sf, spdep, dlnm,
# tsModel, sn, xgboost, fmesher, ...) preinstalled. The image is amd64-only (INLA ships
# x86_64 binaries only), so the FROM line pins linux/amd64 via a build ARG - this works
# on Apple Silicon too via Rosetta. Use chapkit-r instead if you don't need INLA - it's
# smaller and multi-arch (override BASE_PLATFORM at build time for a native arm64 build,
# and remove `platform: linux/amd64` from compose.yml).
ARG BASE_PLATFORM=linux/amd64
FROM --platform=${BASE_PLATFORM} ghcr.io/dhis2-chap/chapkit-r-inla:latest@sha256:71ccd15298303d05da310b48450453c3d7be4ee1ad3fede986170473745bdb0e
# FROM --platform=${BASE_PLATFORM} ghcr.io/dhis2-chap/chapkit-r:latest
# chapkit-py runs as root; matches chapkit-r / chapkit-r-inla.
USER root
WORKDIR /work
# Copy lockfile + manifest first so the dep-install layer caches independently of code changes.
# Run `uv sync` once locally before the first `docker build` to generate uv.lock.
COPY pyproject.toml uv.lock ./
# Sync user deps into the base image's existing venv at /app/.venv. --frozen pins to
# uv.lock for reproducible builds, --no-dev skips dev-only deps (uvicorn etc. ship with
# the base), --no-install-project because this project isn't a package, just a service.
RUN --mount=type=cache,target=/root/.cache/uv \
UV_PROJECT_ENVIRONMENT=/app/.venv uv sync --frozen --no-dev --no-install-project
# Commit the image was built from, reported as git_revision on /api/v1/info.
# The publish workflow passes it; locally: --build-arg GIT_REVISION=$(git rev-parse HEAD)
ARG GIT_REVISION=""
ENV GIT_REVISION=${GIT_REVISION}
COPY main.py ./
COPY scripts/ ./scripts/
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD curl --fail http://localhost:8000/health || exit 1
# Run uvicorn directly so server flags (--workers, --log-level, --timeout-keep-alive,
# etc.) are visible here in the Dockerfile. main.py's `if __name__ == "__main__":`
# block stays as the local-dev shortcut for `python main.py`.
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]