084fe2e8d3
Cookie session with /auth/login, /auth/logout and /auth/me. Four accounts come from WEBAPI_USUARIOS (admin plus one per domain) and a second before_request answers 403 when an account asks for another domain. The data suites run with WEBAPI_AUTH_REQUIRED=0; test_auth.py turns the lock back on and covers both hooks. The Dockerfile normalises the entrypoint so a Windows checkout still starts the container.
72 lines
3.4 KiB
Docker
72 lines
3.4 KiB
Docker
# Build context is the repo root (see docker-compose.yml) so the sibling
|
|
# packages Core/, Persistance/, Extraction/ and models/
|
|
# can be copied, and Transformation/ compiled.
|
|
|
|
# dbt's manifest: the measures' definitions and the compiled SQL of their event
|
|
# models. The API serves the measures from it and the indicator cycle creates
|
|
# the views. The manifest built here is SQLite's, the image's default engine;
|
|
# the same environments compile it again at start-up against MySQL/MariaDB,
|
|
# PostgreSQL or SQL Server when *_DATABASE_URL points there (docker-entrypoint.sh),
|
|
# because those adapters open a connection to compile. dbt-mysql needs an
|
|
# older dbt-core, so it gets an environment of its own.
|
|
FROM python:3.12-slim AS manifest
|
|
COPY --from=ghcr.io/astral-sh/uv:0.7.9 /uv /uvx /bin/
|
|
WORKDIR /app/Transformation
|
|
COPY Transformation/ ./
|
|
RUN uv sync --group sqlite --group sqlserver --group postgres \
|
|
&& UV_PROJECT_ENVIRONMENT=.venv-mysql uv sync --only-group mysql \
|
|
&& uv run --no-sync dbt compile --profiles-dir . --profile cacu --target sqlite --no-introspect
|
|
|
|
FROM python:3.12-slim
|
|
|
|
# Tesseract (with Spanish data) for scanned documents; pytesseract only wraps the binary.
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
tesseract-ocr tesseract-ocr-spa \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY --from=ghcr.io/astral-sh/uv:0.7.9 /uv /uvx /bin/
|
|
|
|
WORKDIR /app
|
|
COPY Core/ Core/
|
|
COPY Persistance/ Persistance/
|
|
COPY Extraction/ Extraction/
|
|
COPY models/ models/
|
|
COPY WebApi/ WebApi/
|
|
|
|
# One environment for the API, the migrations and the indicator cycle. The SQL
|
|
# drivers serve both the import sources and *_DATABASE_URL on MySQL/PostgreSQL/SQL Server.
|
|
RUN cd WebApi && uv sync --locked --no-dev --extra sql-drivers
|
|
|
|
ENV CACU_DATABASE_URL=sqlite:////data/cacu.db
|
|
ENV CAMA_DATABASE_URL=sqlite:////data/cama.db
|
|
ENV TEA_DATABASE_URL=sqlite:////data/tea.db
|
|
ENV GOVERNANCE_DATABASE_URL=sqlite:////data/governance.db
|
|
# MLflow model registry and artifacts, next to the databases so backups cover them.
|
|
ENV MLFLOW_TRACKING_URI=sqlite:////data/mlflow.db
|
|
ENV MLFLOW_ARTIFACT_ROOT=/data/mlflow-artefactos
|
|
# No usage telemetry from MLflow: the server runs on a closed network.
|
|
ENV MLFLOW_DISABLE_TELEMETRY=true DO_NOT_TRACK=true
|
|
# Aggregate import log and the live indicator queue (webapi.recomputation).
|
|
ENV WEBAPI_REPORT_DIR=/data/reportes
|
|
ENV INDICADORES_DIR=/data/indicadores
|
|
ENV MLFLOW_DISABLE_AGENT_HINT=1
|
|
# Session login (webapi/blueprints/auth.py): the four demonstration accounts live
|
|
# in the code; WEBAPI_USUARIOS (JSON list, see .env.example) replaces them.
|
|
# Signs the session cookie: the same value in every worker and across restarts,
|
|
# or the login does not survive the next request.
|
|
ENV WEBAPI_SECRET_KEY=issteleon-dev-cambiar-en-produccion
|
|
# Without it the measure routes (/<domain>/indicadores, /<domain>/fhir) aren't
|
|
# registered. The entrypoint replaces it with one compiled against the
|
|
# deployment's engine when that engine isn't SQLite (webapi.dbt_manifest).
|
|
COPY --from=manifest /app/Transformation /app/Transformation
|
|
ENV DBT_MANIFEST=/app/Transformation/target/manifest.json
|
|
ENV TRANSFORMATION_DIR=/app/Transformation
|
|
|
|
# A checkout on Windows can bring the script with CRLF, and then the shebang
|
|
# is `#!/bin/sh\r`: the container would not start. Normalize it here so the
|
|
# image builds the same from any platform.
|
|
RUN sed -i 's/\r$//' /app/WebApi/docker-entrypoint.sh && chmod +x /app/WebApi/docker-entrypoint.sh
|
|
|
|
EXPOSE 5000
|
|
ENTRYPOINT ["/app/WebApi/docker-entrypoint.sh"]
|