Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
32 lines (28 loc) · 1.53 KB
/
Copy pathDockerfile
File metadata and controls
32 lines (28 loc) · 1.53 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
# Builds the Playwright engine (the one the README recommends) into a
# container with its own Chromium — for a CI canary run or a scheduled job,
# not required for local development (`pip install` directly is simpler there).
#
# docker build -t hackernews-scraper .
# docker run --rm -v "$PWD/out:/out" hackernews-scraper \
# --feed show --pages 3 --delay 4 --out /out/show
#
# Pass --proxy/--twocaptcha-key the same way as running locally, or mount a
# .env at /app/.env — nothing here bakes in a credential.
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt requirements-playwright.txt ./
RUN pip install --no-cache-dir -r requirements.txt -r requirements-playwright.txt \
# Playwright's own apt-get for Chromium's shared-library dependencies —
# not pip packages, so this has to run as a separate, explicit step.
&& playwright install --with-deps chromium
# Every module playwright_scraper.py imports, transitively, plus diff_runs.py
# as a useful companion in the same image. smoke_test.py checks this list
# against the entrypoint's real import graph: an earlier version of a sibling
# omitted proxy_pool.py, which the engine imports at module level, so the
# image died with ModuleNotFoundError on every invocation INCLUDING `--help`
# — a broken container that nothing in the repo would have noticed.
COPY env_config.py fingerprint_client.py output_writer.py \
page_flow.py playwright_scraper.py product_parser.py proxy_pool.py \
diff_runs.py ./
ENTRYPOINT ["python3", "playwright_scraper.py"]
CMD ["--help"]