-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathDockerfile
More file actions
82 lines (59 loc) · 2.05 KB
/
Copy pathDockerfile
File metadata and controls
82 lines (59 loc) · 2.05 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
76
77
78
79
80
81
82
FROM ubuntu:24.04 AS base
EXPOSE 8000
RUN --mount=type=cache,sharing=locked,target=/var/lib/apt/lists \
--mount=type=cache,sharing=locked,target=/var/cache/apt \
rm -f /etc/apt/apt.conf.d/docker-clean && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get install -y --no-install-recommends \
python-is-python3 \
python3 \
python3-dev \
python3-pip \
python3-wheel \
gettext \
postgresql-client \
libpq-dev \
libpcre2-dev \
libgdal-dev \
tzdata \
build-essential
RUN pip install --break-system-packages uv
RUN userdel -r ubuntu && useradd -u 1000 -m appuser
WORKDIR /app
USER appuser
ENV VIRTUALENV=/home/appuser/venv
ENV UV_PROJECT_ENVIRONMENT=$VIRTUALENV
ENV PATH=$VIRTUALENV/bin:/usr/local/bin:/usr/bin:/bin
# Set Python cache path so that pyc files are not read from or
# written to the __pycache__ directories in their normal locations next
# to py files, since those could be used outside of the container and
# may not be compatible with the container's Python.
RUN mkdir -p /home/appuser/.cache/pycache
ENV PYTHONPYCACHEPREFIX=/home/appuser/.cache/pycache
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
# Set VAR_ROOT under home dir to ensure it's writable
RUN mkdir /home/appuser/var
ENV VAR_ROOT=/home/appuser/var
# Install dependencies
COPY pyproject.toml uv.lock .
RUN --mount=type=cache,sharing=locked,uid=1000,target=/home/appuser/.cache/uv \
uv sync --locked --no-default-groups --group deploy
# ---------------------------------------------------------------------
# Development image
FROM base AS development
# Install dev, test and style dependencies
RUN --mount=type=cache,sharing=locked,uid=1000,target=/home/appuser/.cache/uv \
uv sync --locked --all-groups
COPY . /app
ENV DEBUG=1
ENTRYPOINT ["./docker-entrypoint"]
# ---------------------------------------------------------------------
# Production image
FROM base AS production
COPY . /app
RUN python -m compileall .
ENV RUN_MODE=production
ENV DEBUG=0
ENTRYPOINT ["./docker-entrypoint"]