-
-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (36 loc) · 1.79 KB
/
Dockerfile
File metadata and controls
43 lines (36 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
# Main build (Django)
FROM python:3.13-slim-trixie
ENV PYTHONUNBUFFERED=1
WORKDIR /app
VOLUME /data
# Create a non-root user to run the app
RUN groupadd --gid ${GID:-1000} django \
&& adduser --disabled-password --gecos "" --home /app --uid ${UID:-1000} --gid ${GID:-1000} django \
&& chown -R django:django /app
# Upgrade and install required system packages
RUN apt update \
&& apt upgrade -y \
&& apt install --no-install-recommends -y build-essential gettext gnupg libxml2-dev libxslt1-dev make python3-dev wget \
&& echo "deb http://apt.postgresql.org/pub/repos/apt trixie-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
&& wget --quiet -O /etc/apt/trusted.gpg.d/postgres.asc https://www.postgresql.org/media/keys/ACCC4CF8.asc \
&& apt update \
&& apt install --no-install-recommends -y postgresql-client-17 libpq-dev \
&& apt purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& apt clean \
&& rm -rf /var/lib/apt/lists/*
# Upgrade pip and install (if needed) expensive-to-build, big packages and the ones from other indexes (for caching)
RUN --mount=type=cache,target=/var/cache/pip pip install --cache-dir /var/cache/pip -U pip
# Add custom nginx configuration
ADD srv/nginx.conf.sigil /app/
# Install app requirements
COPY --chown=django:django requirements.txt requirements-development.txt /app/
RUN --mount=type=cache,target=/var/cache/pip pip install --cache-dir /var/cache/pip -Ur /app/requirements.txt
ARG ENV_TYPE=production
RUN --mount=type=cache,target=/var/cache/pip if [ "$(echo $ENV_TYPE | tr A-Z a-z)" = "development" ]; then \
pip install --cache-dir /var/cache/pip -Ur /app/requirements-development.txt; \
else \
rm /app/requirements-development.txt; \
fi
# Copy all needed files and set permissions
COPY --chown=django:django . /app/
USER django