-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (29 loc) · 1.16 KB
/
Copy pathDockerfile
File metadata and controls
43 lines (29 loc) · 1.16 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
# --- Stage 1: build dependencies into an isolated venv -----------------------
FROM python:3.12-slim AS builder
ENV PIP_NO_CACHE_DIR=1 PIP_DISABLE_PIP_VERSION_CHECK=1
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
COPY requirements.txt .
RUN pip install --upgrade pip && pip install -r requirements.txt
# --- Stage 2: runtime image ----------------------------------------------------
FROM python:3.12-slim
ENV PATH="/opt/venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1
# Chromium system dependencies for Playwright
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /opt/venv /opt/venv
WORKDIR /app
COPY app/ app/
COPY server.py legacy/ ./
# Download Chromium browser into the image (deep analysis / batch screenshots)
RUN playwright install --with-deps chromium
# Non-root user
RUN useradd --create-home appuser && chown -R appuser /app /home/appuser
USER appuser
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
CMD curl -fs http://localhost:8000/health || exit 1
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]