forked from monosans/proxy-scraper-checker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
67 lines (46 loc) · 1.72 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# hadolint global ignore=DL3008,DL3013,DL4006
FROM docker.io/python:3.12-slim-bookworm AS python-base-stage
ENV \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_COLOR=1 \
PIP_NO_INPUT=1 \
PIP_PROGRESS_BAR=off \
PIP_ROOT_USER_ACTION=ignore \
PIP_UPGRADE=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
WORKDIR /app
FROM python-base-stage AS python-build-stage
ENV \
POETRY_NO_ANSI=1 \
POETRY_NO_CACHE=1 \
POETRY_NO_INTERACTION=1
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
RUN --mount=type=cache,target=/root/.cache/pip,sharing=locked \
pip install poetry poetry-plugin-export
COPY ./poetry.lock ./pyproject.toml ./
RUN --mount=type=cache,target=/root/.cache/pip,sharing=locked \
poetry export --without-hashes --only=main --extras=non-termux | \
pip wheel --wheel-dir /usr/src/app/wheels -r /dev/stdin
FROM python-base-stage AS python-run-stage
RUN apt-get update \
&& apt-get install -y --no-install-recommends tini \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
COPY --from=python-build-stage /usr/src/app/wheels /wheels/
RUN pip install --no-index --find-links /wheels/ /wheels/* \
&& rm -rf /wheels/
ARG GID UID
# hadolint ignore=SC3028
RUN groupadd --gid "${GID}" --system app \
&& useradd --gid app --no-log-init --create-home --system --uid "${UID}" app \
&& mkdir -p /home/app/.cache/proxy_scraper_checker \
&& chown app:app /home/app/.cache/proxy_scraper_checker
ENV IS_DOCKER=1
COPY . .
USER app
ENTRYPOINT ["tini", "--"]
CMD ["python", "-m", "proxy_scraper_checker"]