-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
91 lines (85 loc) · 3.94 KB
/
Copy pathDockerfile
File metadata and controls
91 lines (85 loc) · 3.94 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# syntax=docker/dockerfile:1
#
# Multi-stage build for ujin. Three targets:
#
# ujin (default) — pure-python image: poller + scrape HTTP service.
# Fast build; the Rust stage below is NOT built.
# obscura rendering degrades gracefully (HTTP-only).
# docker build --target ujin -t ujin:latest .
#
# ujin-full — ujin + the obscura headless renderer baked in
# (binary mode via OBSCURA_BIN). Builds the Rust stage,
# which compiles V8 and is SLOW the first time (~15-20m).
# docker build --target ujin-full -t ujin:full .
#
# The obscura submodule must be checked out first:
# git submodule update --init ujin/obscura
# ---- (optional) build the obscura headless renderer (Rust) ----
FROM rust:1-slim AS obscura-build
WORKDIR /build
COPY ujin/obscura/ ./
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential cmake python3 \
git ca-certificates pkg-config libssl-dev \
&& rm -rf /var/lib/apt/lists/* \
&& cargo build --release \
&& strip target/release/obscura || true
# ---- ujin python service (pure-python; default target) ----
FROM python:3.12-slim AS ujin
WORKDIR /app
COPY pyproject.toml README.md ./
COPY ujin ./ujin
# Drop the Rust submodule source from the image and install the rich extras.
# The wheel build already excludes ujin/obscura, so site-packages stays pure-python.
RUN rm -rf ujin/obscura \
&& pip install --no-cache-dir ".[scrape,social,diff,sessions,jobs]"
# Mount points for the unified job control plane: operator plugins (capabilities),
# the workflow definition files, and the durable jobstore. All are typically bind-
# or volume-mounted by compose. Owned by a non-root user for defense in depth —
# a named volume mounted here inherits this ownership on first creation; a bind
# mount still depends on the host directory's own permissions.
RUN mkdir -p /plugins /data /workflows \
&& useradd --create-home --uid 1000 --shell /usr/sbin/nologin ujin \
&& chown -R ujin:ujin /app /plugins /data /workflows
ENV UJIN_PLUGINS_DIR=/plugins \
UJIN_WORKFLOWS_DIR=/workflows \
UJIN_JOBS_DB=/data/ujin-jobs.db
EXPOSE 8900 8901 8902
USER ujin
ENTRYPOINT ["ujin"]
# Default to the scrape HTTP service; override for the poller (`api`), the
# unified jobs control plane (`jobs-serve`), or `watch`.
CMD ["scrape-serve", "--host", "0.0.0.0", "--port", "8901"]
# ---- ujin + Playwright/Chromium + Selenium/chromedriver (heavy) ----
# docker build --target ujin-browser -t ujin:browser .
# Built on top of the slim `ujin` stage so the default image is untouched. This
# image is large (~1.5GB+): Chromium + its runtime libs + the Playwright browser.
FROM ujin AS ujin-browser
USER root
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
chromium chromium-driver fonts-liberation ca-certificates \
libnss3 libatk-bridge2.0-0 libatk1.0-0 libcups2 libdrm2 libxkbcommon0 \
libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libasound2 \
&& rm -rf /var/lib/apt/lists/*
# Set the browser path BEFORE installing so Playwright downloads into
# /ms-playwright (baked into the image / copied into a fresh cache volume).
# Setting it afterwards would install to ~/.cache and the runtime lookup at
# /ms-playwright would miss the binary.
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN mkdir -p /ms-playwright \
&& pip install --no-cache-dir ".[browser]" \
&& python -m playwright install --with-deps chromium \
&& chown -R ujin:ujin /ms-playwright
ENV UJIN_BROWSER_ENABLED=1 \
UJIN_BROWSER_ENGINE=playwright \
UJIN_BROWSER_HEADLESS=1 \
UJIN_CHROMEDRIVER=/usr/bin/chromedriver
USER ujin
# ---- ujin + bundled obscura binary (slow build) ----
FROM ujin AS ujin-full
USER root
COPY --from=obscura-build /build/target/release/obscura /usr/local/bin/obscura
RUN chmod +x /usr/local/bin/obscura
ENV OBSCURA_BIN=/usr/local/bin/obscura
USER ujin