-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
43 lines (33 loc) · 1.15 KB
/
Dockerfile
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
FROM python:3.11-slim
## venv set-up.
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Install dependencies.
COPY requirements.txt .
RUN pip install -r requirements.txt
# === Playwright ===
ARG DEBIAN_FRONTEND=noninteractive
# playwright install.
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
# 1. Add tip-of-tree Playwright package to install its browsers.
# The package should be built beforehand from tip-of-tree Playwright.
COPY ./playwright/*-manylinux*.whl /tmp/
# 2. Bake in browsers & deps.
# Browsers will be downloaded in `/ms-playwright`.
# Note: make sure to set 777 to the registry so that any user can access
# registry.
RUN mkdir /ms-playwright && \
mkdir /ms-playwright-agent && \
cd /ms-playwright-agent && \
pip install /tmp/*manylinux1_x86_64*.whl && \
playwright install chromium --with-deps && rm -rf /var/lib/apt/lists/* && \
rm /tmp/*.whl && \
rm -rf /ms-playwright-agent && \
chmod -R 777 /ms-playwright
# Create user to run as.
RUN useradd -ms /bin/bash scraper
USER scraper
COPY --chown=scraper:scraper . /app
WORKDIR /app
CMD ["python", "-m", "scraper"]
# ENTRYPOINT ["tail", "-f", "/dev/null"]