Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (38 loc) · 1.8 KB
/
Copy pathDockerfile
File metadata and controls
51 lines (38 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# ── Stage 1: build dependencies ──────────────────────────────────────────────
FROM python:3.12-slim AS builder
RUN apt-get update && apt-get install -y \
build-essential \
git \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
RUN pip install --no-cache-dir poetry==2.1.0
COPY pyproject.toml poetry.lock ./
RUN poetry config virtualenvs.create false \
&& poetry install --only=main,plugins --no-root --no-interaction --no-ansi
COPY protea/ ./protea/
RUN poetry install --only=main,plugins --no-interaction --no-ansi \
&& python -c "import protea_method, protea_backends, protea_sources, protea_runners; print('plugins importable in builder')"
# ── Stage 2: runtime ────────────────────────────────────────────────────────
FROM python:3.12-slim
RUN apt-get update && apt-get install -y \
libpq5 \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy installed packages from builder
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
# Copy application code
COPY protea/ ./protea/
COPY scripts/ ./scripts/
COPY alembic/ ./alembic/
COPY alembic.ini ./
ENV PYTHONUNBUFFERED=1
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
# Default: API server
# Override CMD to run a worker:
# docker run protea python scripts/worker.py --queue protea.jobs
CMD ["uvicorn", "protea.api.app:create_app", "--factory", "--host", "0.0.0.0", "--port", "8000"]