Commit 57a821e9 authored by George Papathanail's avatar George Papathanail
Browse files

update dockerfile

parent 56013584
Loading
Loading
Loading
Loading
Loading
+17 −36
Changes for Dockerfile: 17 added lines, 36 removed lines.
Original line number Diff line number Diff line
FROM ghcr.io/astral-sh/uv:0.12.19 AS uv

FROM python:3.12-slim AS builder

COPY --from=uv /uv /bin/uv

WORKDIR /app

# DB build arg: base | postgres | mongo
ARG DB=base
# Install exactly what uv.lock pins (same as CI), so a new upstream release
# can't change the image without a lockfile change. uv verifies every package
# against the hashes in uv.lock, so the trusted hosts only relax TLS checks for
# networks that intercept HTTPS, not package integrity.
ENV UV_COMPILE_BYTECODE=1 \
    UV_LINK_MODE=copy \
    UV_PYTHON_DOWNLOADS=never \
    UV_HTTP_TIMEOUT=120 \
    UV_INSECURE_HOST="pypi.org files.pythonhosted.org"

ENV PIP_DEFAULT_TIMEOUT=120
# Dependencies first, so this layer is cached until uv.lock changes.
COPY pyproject.toml uv.lock ./
RUN uv sync --locked --no-install-project

COPY pyproject.toml ./
COPY README.md ./
COPY src/ ./src/

RUN python -m venv .venv && \
    .venv/bin/pip install \
      --no-cache-dir \
      --default-timeout=120 \
      --trusted-host pypi.org \
      --trusted-host files.pythonhosted.org \
      --upgrade pip setuptools wheel && \
    if [ "$DB" = "postgres" ]; then \
        .venv/bin/pip install \
          --no-cache-dir \
          --default-timeout=120 \
          --trusted-host pypi.org \
          --trusted-host files.pythonhosted.org \
          ".[postgres]"; \
    elif [ "$DB" = "mongo" ]; then \
        .venv/bin/pip install \
          --no-cache-dir \
          --default-timeout=120 \
          --trusted-host pypi.org \
          --trusted-host files.pythonhosted.org \
          ".[mongo]"; \
    else \
        .venv/bin/pip install \
          --no-cache-dir \
          --default-timeout=120 \
          --trusted-host pypi.org \
          --trusted-host files.pythonhosted.org \
          "."; \
    fi
RUN uv sync --locked --no-editable

FROM python:3.12-slim AS runtime

WORKDIR /app

COPY --from=builder /app/.venv /app/.venv
COPY src/ ./src/

ENV PATH="/app/.venv/bin:$PATH"
ENV PYTHONPATH="/app"
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1