-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
47 lines (36 loc) · 1.64 KB
/
Dockerfile
File metadata and controls
47 lines (36 loc) · 1.64 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
# Use official Python runtime pinned by digest
FROM python:3.14-slim-bookworm@sha256:2e256d0381371566ed96980584957ed31297f437569b79b0e5f7e17f2720e53a AS builder
WORKDIR /build
# Build wheels in an isolated stage (botasaurus dependency is sourced from git).
RUN apt-get update \
&& apt-get install -y --no-install-recommends git \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt /build/requirements.txt
RUN pip wheel --no-cache-dir --wheel-dir /build/wheels -r /build/requirements.txt
FROM python:3.14-slim-bookworm@sha256:2e256d0381371566ed96980584957ed31297f437569b79b0e5f7e17f2720e53a
WORKDIR /app
# Install minimal browser/runtime dependencies for Botasaurus.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
chromium \
xvfb \
&& rm -rf /var/lib/apt/lists/*
COPY requirements.txt /app/requirements.txt
COPY --from=builder /build/wheels /wheels
RUN grep -v '^botasaurus @ git+' /app/requirements.txt > /app/requirements.runtime.txt \
&& echo 'botasaurus' >> /app/requirements.runtime.txt \
&& pip install --no-cache-dir --no-index --find-links /wheels -r /app/requirements.runtime.txt \
&& rm -f /app/requirements.runtime.txt \
&& rm -rf /wheels
# Copy application code
COPY . /app
# Keep both paths available; Botasaurus integrations often look for google-chrome.
ENV CHROME_BIN=/usr/bin/chromium
RUN ln -sf /usr/bin/chromium /usr/bin/google-chrome
# Run as unprivileged user
RUN useradd --create-home --shell /usr/sbin/nologin appuser \
&& chown -R appuser:appuser /app
USER appuser
EXPOSE 4010
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "4010"]