forked from balen/nomnom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
50 lines (33 loc) · 1.16 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
# Base this on Debian Bookworm + Python 3.11
FROM python:3.11-bookworm AS os
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential libpq-dev redis postgresql gettext curl jq \
&& rm -rf /var/lib/apt/lists/*
# Configure the application user and prepare our directories
RUN useradd -U app_user \
&& install -d -m 0755 -o app_user -g app_user /app \
&& install -d -m 0755 -o app_user -g app_user /system \
&& install -d -m 0755 -o app_user -g app_user /staticfiles
VOLUME /staticfiles
FROM os AS build
# Ensure we create a clean install with no bytecode cruft
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
RUN pip install -U pip
RUN pip install pdm
# Initialize the project virtualenv
RUN python -mvenv /system/venv
# Copy the project files
COPY pyproject.toml pdm.lock /system
# install dependencies and project
WORKDIR /system
RUN . venv/bin/activate && \
pdm install --prod --no-lock --no-editable --no-self
FROM os AS run
WORKDIR /app
COPY . /app
COPY --from=build /system /system
RUN chown -R app_user:app_user /app/*/locale/zh/LC_MESSAGES
USER app_user:app_user
EXPOSE 8000
ENTRYPOINT ["/app/docker/entrypoint.sh"]