Files
ISSSTELEON/Dockerfile
T

49 lines
2.4 KiB
Docker

# One Python image for the API, the Dagster webserver and the Dagster daemon.
FROM python:3.12-slim AS app
RUN apt-get update \
&& apt-get install -y --no-install-recommends tesseract-ocr tesseract-ocr-spa ghostscript \
postgresql-client \
&& rm -rf /var/lib/apt/lists/*
COPY --from=ghcr.io/astral-sh/uv:0.12.21 /uv /bin/uv
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy UV_PROJECT_ENVIRONMENT=/venv PATH=/venv/bin:$PATH
WORKDIR /app
COPY . .
# Optional extras a machine opts into (`--extra dask` where a Dask cluster runs the batches).
ARG EXTRAS=""
RUN uv sync --frozen --no-dev $EXTRAS
ENV ISSSTELEON_DATA=/data DAGSTER_HOME=/data/dagster DLT_DATA_DIR=/data/dlt
# The same image plus the dev tools: what CI and `docker compose run --rm test` run.
# The HL7 validator is pinned by checksum; its FHIR 4.3.0 packages are fetched here, once,
# so tests validate offline.
FROM app AS test
RUN apt-get update \
&& apt-get install -y --no-install-recommends default-jre-headless \
&& rm -rf /var/lib/apt/lists/*
ADD --checksum=sha256:9dfe9f305b0f9389eceade2a4a1c9a2740d7b0e614066fdf07a78b571c76d92f \
https://github.com/hapifhir/org.hl7.fhir.core/releases/download/7.0.5/validator_cli.jar \
/opt/fhir/validator_cli.jar
RUN echo '{"resourceType":"Basic","code":{"text":"warm-up"}}' > /tmp/warm.json \
&& java -jar /opt/fhir/validator_cli.jar /tmp/warm.json -version 4.3.0 -tx n/a > /dev/null \
&& rm /tmp/warm.json
ENV FHIR_VALIDATOR_JAR=/opt/fhir/validator_cli.jar
# Synthea, pinned: seeded synthetic patients sent through the FHIR door in tests.
ADD --checksum=sha256:ed43c20ad40ba5c3bc724503a5af032715fe3c491620b766148e7c2361e6ecc1 \
https://github.com/synthetichealth/synthea/releases/download/v4.0.0/synthea-with-dependencies.jar \
/opt/synthea/synthea.jar
ENV SYNTHEA_JAR=/opt/synthea/synthea.jar
RUN uv sync --frozen
# The pages (-m webapp) run in CI's web job, which has Node and a browser.
CMD ["pytest", "-q", "-rs", "-m", "not webapp"]
# A Dask worker for testing on a cluster (not part of the product): the app's Python and code
# with the `dask` extra, run as the cluster runs its workers (user dask, one thread per math
# library). The cluster gives the command (`dask worker <scheduler>`).
FROM app AS dask-worker
RUN uv sync --frozen --no-dev --extra dask \
&& useradd --uid 10001 --create-home dask
ENV OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 MKL_NUM_THREADS=1
WORKDIR /home/dask
USER dask
CMD ["dask", "worker", "--help"]