-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
71 lines (51 loc) · 2.03 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
68
69
70
71
# syntax=docker/dockerfile:1.6
FROM python:3.11
ARG DEBIAN_FRONTEND=noninteractive
ARG PIP_NO_CACHE_DIR=1
ENV PYTHONUNBUFFERED=1
ENV PATH=/home/user/.local/bin:${PATH}
RUN <<EOF
set -eu
apt-get update
apt-get install -y \
gosu
apt-get clean
rm -rf /var/lib/apt/lists/*
EOF
ARG CONTAINER_UID=1000
ARG CONTAINER_GID=1000
RUN <<EOF
set -eu
groupadd --non-unique --gid "${CONTAINER_GID}" user
useradd --non-unique --uid "${CONTAINER_UID}" --gid "${CONTAINER_GID}" --create-home user
EOF
ARG POETRY_VERSION=1.8.1
RUN <<EOF
set -eu
gosu user pip install "poetry==${POETRY_VERSION}"
gosu user poetry config virtualenvs.in-project true
mkdir -p /home/user/.cache/pypoetry/{cache,artifacts}
chown -R "${CONTAINER_UID}:${CONTAINER_GID}" /home/user/.cache
EOF
RUN <<EOF
set -eu
mkdir -p /code/live_inbox_updater
chown -R "${CONTAINER_UID}:${CONTAINER_GID}" /code/live_inbox_updater
EOF
WORKDIR /code/live_inbox_updater
ADD --chown="${CONTAINER_UID}:${CONTAINER_GID}" ./pyproject.toml ./poetry.lock /code/live_inbox_updater/
RUN --mount=type=cache,uid="${CONTAINER_UID}",gid="${CONTAINER_GID}",target=/home/user/.cache/pypoetry/cache \
--mount=type=cache,uid="${CONTAINER_UID}",gid="${CONTAINER_GID}",target=/home/user/.cache/pypoetry/artifacts <<EOF
set -eu
gosu user poetry install --no-root --only main
EOF
ADD --chown="${CONTAINER_UID}:${CONTAINER_GID}" ./README.md /code/live_inbox_updater/
ADD --chown="${CONTAINER_UID}:${CONTAINER_GID}" ./live_inbox_updater /code/live_inbox_updater/live_inbox_updater
ADD --chown="${CONTAINER_UID}:${CONTAINER_GID}" ./scripts /code/live_inbox_updater/scripts
RUN --mount=type=cache,uid="${CONTAINER_UID}",gid="${CONTAINER_GID}",target=/home/user/.cache/pypoetry/cache \
--mount=type=cache,uid="${CONTAINER_UID}",gid="${CONTAINER_GID}",target=/home/user/.cache/pypoetry/artifacts <<EOF
set -eu
gosu user poetry install --only main
EOF
ENTRYPOINT [ "gosu", "user", "poetry", "run", "python", "-m", "live_inbox_updater" ]
CMD [ "update" ]