Commit f43b8215 authored by George Papathanail's avatar George Papathanail
Browse files

feat: add dockerfile

parent 451ffecb
Loading
Loading
Loading
Loading
Loading

Dockerfile

0 → 100644
+58 −0
Original line number Diff line number Diff line
FROM python:3.12-slim AS builder

WORKDIR /app

# DB build arg: base | postgres | mongo
ARG DB=base

ENV PIP_DEFAULT_TIMEOUT=120

COPY pyproject.toml ./
COPY README.md ./
COPY open_exposure_gateway/ ./open_exposure_gateway/

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

FROM python:3.12-slim AS runtime

WORKDIR /app

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

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

EXPOSE 8080

CMD ["uvicorn", "open_exposure_gateway.app.main:app", "--host", "0.0.0.0", "--port", "8080"]
 No newline at end of file