-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
51 lines (40 loc) · 1.45 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
# syntax=docker/dockerfile:1.7-labs
FROM python:3.12-slim-bookworm
ARG APP_HOME=/app
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# These are here just to make collectstatic work.
# Replace these values with your own configuration.
ENV DATABASE_URL="sqlite://:memory:"
ENV REDIS_URL="redis://localhost:6379"
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
echo "Initial system configuration..." \
&& apt-get update \
&& apt-get dist-upgrade -y \
&& apt-get install -y curl gettext \
&& adduser --system --uid 1000 --group --shell /bin/bash --home ${APP_HOME} django \
&& pip install --upgrade pip \
&& pip install poetry==1.8.3
USER django
WORKDIR ${APP_HOME}
# --- Dependencies ---
COPY --chown=django:django \
pyproject.toml poetry.lock \
${APP_HOME}
RUN --mount=type=cache,target=${APP_HOME}/.cache,uid=1000,gid=1000 \
echo "Creating the virtualenv and installing Python dependencies..." \
&& poetry config virtualenvs.in-project true \
&& poetry install --no-root --no-directory
# --- Application ---
COPY --chown=django:django \
--exclude=.private \
--exclude=.venv \
--exclude=media \
--exclude=static \
. ${APP_HOME}
RUN --mount=type=cache,target=${APP_HOME}/.cache \
echo "Installing Coriolis and creating static files..." \
&& poetry install \
&& poetry run python manage.py collectstatic --noinput
ENTRYPOINT ["/bin/bash"]