-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (61 loc) · 2.35 KB
/
Dockerfile
File metadata and controls
75 lines (61 loc) · 2.35 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:1
ARG BUILDER_IMAGE="ubuntu:24.04"
ARG RUNNER_IMAGE="ubuntu:24.04"
FROM $BUILDER_IMAGE AS builder
ENV DEBIAN_FRONTEND=noninteractive \
UV_PYTHON_INSTALL_DIR="/opt/python" \
UV_PROJECT_ENVIRONMENT="/opt/venv" \
# Compile packages to bytecode after installation
UV_COMPILE_BYTECODE=1 \
# Copy packages from wheel
UV_LINK_MODE=copy
RUN rm -f /etc/apt/apt.conf.d/docker-clean \
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends \
git \
curl \
ca-certificates
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
WORKDIR /app
# Sync dependencies
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
--mount=type=bind,source=.python-version,target=.python-version \
--mount=type=bind,source=uv.lock,target=uv.lock \
ulimit -n 8192 \
&& uv sync --locked --no-install-project --no-editable
# Sync this project
COPY . .
RUN --mount=type=cache,target=/root/.cache/uv \
ulimit -n 8192 \
&& uv sync --locked --no-editable
FROM $RUNNER_IMAGE AS production
ENV DEBIAN_FRONTEND=noninteractive \
PATH="/opt/venv/bin:$PATH" \
UV_PYTHON_INSTALL_DIR="/opt/python" \
UV_PROJECT_ENVIRONMENT="/opt/venv" \
# Disable buffering of standard output and error streams
PYTHONUNBUFFERED=1 \
# Disable generation of .pyc files
PYTHONDONTWRITEBYTECODE=1
# Copy Python
COPY --from=builder /opt/python /opt/python
COPY --from=builder /opt/venv /opt/venv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
RUN rm -f /etc/apt/apt.conf.d/docker-clean \
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends \
git \
curl \
ca-certificates \
build-essential \
sudo \
gosu
# Allow sudo without password
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
COPY --chmod=755 ./docker/entrypoint.sh /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]