-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
134 lines (107 loc) · 3.26 KB
/
Copy pathDockerfile
File metadata and controls
134 lines (107 loc) · 3.26 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# syntax=docker/dockerfile:1
ARG PRETALX_VERSION=main
# Base image with Python 3.12
FROM python:3.12-slim as base
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
DEBIAN_FRONTEND=noninteractive
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
gettext \
git \
libffi-dev \
libjpeg-dev \
libmemcached-dev \
libpq-dev \
libssl-dev \
libxml2-dev \
libxslt1-dev \
locales \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*
# Install Node.js
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs && \
rm -rf /var/lib/apt/lists/*
# Generate locales
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
locale-gen
ENV LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
LANGUAGE=en_US:en
# Build stage
FROM base
ARG PRETALX_VERSION
# Clone target pretalx repository
WORKDIR /build
RUN git clone --depth 1 --branch ${PRETALX_VERSION} https://github.com/COSCUP/pretalx.git .
# Install build deps
RUN --mount=type=cache,target=/root/.cache/pip \
python -m pip install uv && uv pip install --system wheel psycopg2 redis gunicorn -Ue ".[dev]"
RUN --mount=type=cache,target=/root/.cache/pip \
python -m build
# Install wheel + extras
RUN --mount=type=cache,target=/root/.cache/pip \
python -m pip install dist/pretalx*whl
# Create pretalx user
RUN mkdir /data && \
mkdir /static && \
groupadd -g 999 pretalx && \
useradd -r -u 999 -g pretalx -d /pretalx -ms /bin/bash pretalx && \
chown -R pretalx:pretalx /data && \
chown -R pretalx:pretalx /static
# Create deployment directory
RUN mkdir -p /etc/pretalx
COPY --chmod=755 deployment/entrypoint.sh /usr/local/bin/entrypoint.sh
# Create a temporary, valid config file for the build process with network components disabled
RUN echo "[pretalx]\n\
instance_name = My Conference\n\
short_domain = pretalx\n\
datadir = /data\n\
logdir = /data/logs\n\
secret = build-time-secret-key-is-not-used\n\
url = http://localhost\n\
[database]\n\
#backend = postgresql\n\
[mail]\n\
host = localhost\n\
port = 25\n\
user = \n\
password = \n\
from = pretalx@localhost\n\
tls = False\n\
ssl = False\n\
[redis]\n\
#sessions = True\n\
[celery]\n\
#backend = redis://redis:6379/2\n\
#broker = redis://redis:6379/3\n\
[filesystem]\n\
static = /static" > /tmp/pretalx.build.cfg
# Set environment to use the temporary config
ENV PRETALX_CONFIG_FILE=/tmp/pretalx.build.cfg \
DJANGO_SETTINGS_MODULE=pretalx.settings
# Run migrate and rebuild using the default (SQLite) settings
# RUN python -m pretalx migrate
RUN python -m pretalx rebuild --npm-install
RUN chown -R pretalx:pretalx /data && \
chown -R pretalx:pretalx /static
# Now, copy the real configuration file for runtime
COPY --chmod=644 deployment/pretalx.cfg /etc/pretalx/pretalx.cfg
ENV PRETALX_CONFIG_FILE=/etc/pretalx/pretalx.cfg
WORKDIR /pretalx
# Expose ports
EXPOSE 8000
# Set volumes
VOLUME ["/data"]
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8000/healthcheck/ || exit 1
USER pretalx
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["web"]