Repository navigation
Expand file tree
/
Copy pathDockerfile.worker
More file actions
41 lines (32 loc) · 1.67 KB
/
Copy pathDockerfile.worker
File metadata and controls
41 lines (32 loc) · 1.67 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
# Start from the existing worker image that has INLA and other dependencies
FROM ghcr.io/dhis2-chap/chap-worker-with-inla@sha256:634bb3e61e66f9c1c2d499c495d294cd5f287078ae7b54629114066f8ec75aab
# Compile Python bytecode for faster startup (.venv only)
ENV UV_COMPILE_BYTECODE=1
# Use copy mode to avoid issues with file permissions in mixed environments
ENV UV_LINK_MODE=copy
# Prevent Python from writing .pyc files at runtime
ENV PYTHONDONTWRITEBYTECODE=1
ENV MPLCONFIGDIR=/tmp
ENV PATH="/app/.venv/bin:$PATH"
# Bring in uv from the official image, consistent with Dockerfile and Dockerfile.inla
COPY --from=ghcr.io/astral-sh/uv:0.13 /uv /bin/uv
USER root
WORKDIR /app
# Copy chap-core source files
COPY --chown=chap:chap ./pyproject.toml ./uv.lock ./.python-version ./README.md ./
COPY --chown=chap:chap ./chap_core ./chap_core
COPY --chown=chap:chap ./config ./config
COPY --chown=chap:chap ./alembic.ini ./alembic.ini
COPY --chown=chap:chap ./alembic ./alembic
# Install chap-core dependencies in the existing virtual environment
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev && \
python -m compileall -q chap_core/
# Create data directories and set ownership for the chap user
# Each directory is owned explicitly rather than recursively owning /data
RUN mkdir -p /data/logs /data/uv /data/renv /data/pytensor /data/runs \
&& chown chap:chap /data/logs /data/uv /data/renv /data/pytensor /data/runs
HEALTHCHECK CMD /app/.venv/bin/celery -A chap_core.rest_api.celery_tasks inspect ping || exit 1
USER chap
# Keep the same command from the original worker image
CMD ["/app/.venv/bin/celery", "-A", "chap_core.rest_api.celery_tasks", "worker", "--loglevel=info"]