-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (31 loc) · 1.22 KB
/
Dockerfile
File metadata and controls
42 lines (31 loc) · 1.22 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
FROM --platform=$BUILDPLATFORM python:3.10 AS deps
# Install Poetry
RUN curl -sSL https://install.python-poetry.org | python3 - && /root/.local/bin/poetry config virtualenvs.create false && \
/root/.local/bin/poetry self add poetry-plugin-export
# Copy Poetry data
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY pyproject.toml poetry.lock ./
# Generate requirements list
RUN /root/.local/bin/poetry export -o requirements.txt
FROM python:3.10
ENV TINI_VERSION=v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
# Install requirements
COPY --from=deps /usr/src/app/requirements.txt /requirements.txt
RUN pip --disable-pip-version-check install --no-cache-dir -r /requirements.txt
# Set up app
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY k8s_emailer.py ./k8s_emailer.py
RUN printf -- '#!/bin/sh\npython3 -c "from k8s_emailer import main; main()" "$@"' > /usr/local/bin/k8s-emailer && \
chmod +x /usr/local/bin/k8s-emailer
# Set up user
RUN mkdir -p /usr/src/app/home && \
useradd -d /usr/src/app/home -s /usr/sbin/nologin -u 998 appuser && \
chown appuser /usr/src/app/home
ENV PYTHONFAULTHANDLER=1
USER 998
ENTRYPOINT ["/tini", "--"]
CMD ["k8s-emailer"]