-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
62 lines (41 loc) · 1.54 KB
/
Dockerfile
File metadata and controls
62 lines (41 loc) · 1.54 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
FROM python:3.12-slim@sha256:80571b64ab7b94950d49d413f074e1932b65f6f75e0c34747b40ea41889a2ca9 AS base
RUN apt-get update \
&& apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Export python requirements from poetry
FROM base AS poetry-export
ENV PATH=$PATH:/root/.local/bin POETRY_VERSION=1.8.3
RUN curl -sSL https://install.python-poetry.org | python -
COPY ./pyproject.toml ./pyproject.toml
COPY ./poetry.lock ./poetry.lock
RUN poetry export --no-interaction -o /requirements.txt --without-hashes --only main
# Install pip requirements
# This is needed to lower the size of the final image (no build dependencies)
FROM base AS requirements
# Install requirements
RUN apt-get update && apt-get install gcc python3-dev -y --no-install-recommends
COPY --from=poetry-export requirements.txt /requirements.txt
RUN pip install -r /requirements.txt
# Copy source code
# This is done in a separate stage to squash layers into one
FROM base AS source
RUN mkdir -p /app
WORKDIR /app
COPY pinger /app/pinger
COPY pyproject.toml /app
COPY README.md /app/README.md
# Remove apt files
FROM base AS pre-final
RUN rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Final image
FROM scratch AS final
LABEL org.opencontainers.image.source=https://github.com/D0Nater/PingerBot
COPY --from=pre-final / /
WORKDIR /app
ENV MODE=app
COPY --from=requirements /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=source /app /app
RUN pip install -e /app
CMD ["python", "-m", "pinger"]