62 lines
2.3 KiB
Docker
62 lines
2.3 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
# One locked runtime produces three independently deployable process images.
|
|
ARG PYTHON_IMAGE=python:3.12.14-slim-bookworm@sha256:782412e85d0f0984994c290652577d4018aff08145c85b262bb63dc0c7522254
|
|
ARG UV_IMAGE=ghcr.io/astral-sh/uv:0.12.5@sha256:e85be844203885286c60ffad8a858d48afb6c5a5c237ca0e67f12e74b8f174b1
|
|
|
|
FROM ${UV_IMAGE} AS uv-bin
|
|
|
|
FROM ${PYTHON_IMAGE} AS runtime
|
|
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
UV_COMPILE_BYTECODE=1 \
|
|
UV_LINK_MODE=copy \
|
|
VIRTUAL_ENV=/app/.venv \
|
|
PATH=/app/.venv/bin:${PATH} \
|
|
HOME=/tmp/ekp \
|
|
XDG_CACHE_HOME=/tmp/ekp/cache \
|
|
APP_ENV=production \
|
|
API_HOST=0.0.0.0 \
|
|
MCP_HOST=0.0.0.0 \
|
|
ADMIN_WEB_ROOT=/app/apps/admin-web
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=uv-bin /uv /uvx /usr/local/bin/
|
|
COPY pyproject.toml uv.lock README.md alembic.ini ./
|
|
COPY apps ./apps
|
|
COPY packages ./packages
|
|
COPY migrations ./migrations
|
|
|
|
# --frozen prevents lock changes; --no-dev and --no-editable keep the runtime
|
|
# independent from source-tree import hooks while retaining migration sources.
|
|
RUN uv sync --frozen --no-dev --no-editable \
|
|
&& test -f /app/apps/admin-web/index.html \
|
|
&& groupadd --gid 10001 ekp \
|
|
&& useradd --uid 10001 --gid 10001 --no-create-home --shell /usr/sbin/nologin ekp \
|
|
&& mkdir -p /tmp/ekp/cache \
|
|
&& chown -R 10001:10001 /tmp/ekp \
|
|
&& rm -rf /root/.cache/uv
|
|
|
|
USER 10001:10001
|
|
|
|
FROM runtime AS api
|
|
EXPOSE 8000
|
|
# This endpoint is intentionally credential-free and suitable for container liveness.
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
|
CMD ["python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/healthz', timeout=2)"]
|
|
CMD ["uvicorn", "ekp_api.main:app", "--host", "0.0.0.0", "--port", "8000", "--no-access-log"]
|
|
|
|
FROM runtime AS mcp
|
|
EXPOSE 8766
|
|
# MCP requests require authentication, so the image-level check only verifies PID 1.
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
|
CMD ["python", "-c", "import os; os.kill(1, 0)"]
|
|
CMD ["ekp-mcp"]
|
|
|
|
FROM runtime AS worker
|
|
# Worker health is process-level here; durable Job recovery is validated by the service tests.
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
|
CMD ["python", "-c", "import os; os.kill(1, 0)"]
|
|
CMD ["ekp-worker"]
|