-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (55 loc) · 1.79 KB
/
Dockerfile
File metadata and controls
75 lines (55 loc) · 1.79 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
63
64
65
66
67
68
69
70
71
72
73
74
75
# syntax=docker/dockerfile:latest
# hadolint global shell=bash
# DEBIAN_VERSION The version of Debian to use for the base image
ARG DEBIAN_VERSION=bookworm
# DEBIAN_FRONTEND The frontend of the Apt package manager to use
ARG DEBIAN_FRONTEND=noninteractive
# PYTHON_VERSION The version of Python to use for the base image
ARG PYTHON_VERSION=3.13
# build builds the virtual environment of the project
FROM python:$PYTHON_VERSION-slim-$DEBIAN_VERSION AS build
ARG DEBIAN_FRONTEND
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
SHELL ["/bin/bash", "-c"]
COPY --link --from=ghcr.io/astral-sh/uv:latest /uv /usr/bin/
WORKDIR /opt
# hadolint ignore=DL4006
RUN --mount=type=cache,target=/root/.cache/uv \
<<EOT
#!/usr/bin/env bash
set -e
apt-get -q update
apt-get -qy upgrade
apt-get -qy install --no-install-recommends git
EOT
COPY --link pyproject.toml uv.lock ./
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --no-install-project --no-default-groups
COPY --link src/ src/
RUN --mount=type=cache,target=/root/.cache/uv \
uv pip install .
# release uses the built virtual environment of the project
FROM python:$PYTHON_VERSION-slim-$DEBIAN_VERSION AS release
ARG DEBIAN_FRONTEND
SHELL ["/bin/bash", "-c"]
# Define Git SHA build argument for sentry
ARG GIT_SHA="development"
ENV GIT_SHA=$GIT_SHA
WORKDIR /app
COPY --link --from=build /opt/.venv /opt/.venv
# hadolint ignore=DL4006
RUN --mount=type=cache,target=/root/.cache/pip \
<<EOT
#!/usr/bin/env bash
set -e
apt-get -q update
apt-get -qy upgrade
python3 -m pip install --no-cache-dir --use-pep517 --check-build-dependencies -U pip setuptools wheel build
apt-get -qy clean
rm -rf /var/lib/apt/lists/*
useradd --no-create-home --shell=/bin/bash bot
EOT
ENV PATH="/opt/.venv/bin:${PATH}"
COPY --link LICENSE ./
USER bot
CMD ["python", "-m", "bot"]