-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (45 loc) · 1.41 KB
/
Copy pathDockerfile
File metadata and controls
58 lines (45 loc) · 1.41 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
FROM python:3.10.11-alpine3.16
LABEL maintainer="graham@grahamgilbert.com"
ENV APP_DIR /home/docker/crypt
ENV DEBUG false
ENV LANG en
ENV TZ Etc/UTC
ENV LC_ALL en_US.UTF-8
RUN set -ex \
&& apk add --no-cache --virtual .build-deps \
gcc \
git \
openssl-dev \
build-base \
libffi-dev \
libc-dev \
musl-dev \
linux-headers \
pcre-dev \
postgresql-dev \
xmlsec-dev \
tzdata \
postgresql-libs \
libpq
COPY setup/requirements.txt /tmp/requirements.txt
RUN set -ex \
&& LIBRARY_PATH=/lib:/usr/lib /bin/sh -c "pip install --no-cache-dir -r /tmp/requirements.txt" \
&& rm /tmp/requirements.txt
COPY / $APP_DIR
COPY docker/settings.py $APP_DIR/fvserver/
COPY docker/settings_import.py $APP_DIR/fvserver/
COPY docker/gunicorn_config.py $APP_DIR/
COPY docker/django/management/ $APP_DIR/server/management/
COPY docker/run.sh /run.sh
RUN chmod +x /run.sh \
&& mkdir -p /home/app \
&& ln -s ${APP_DIR} /home/app/crypt
WORKDIR ${APP_DIR}
# collectstatic imports the app, which needs a key present to load the encrypted
# fields. Generate a throwaway one for this build step only, so no key literal
# ends up in the image, the layer, or `docker history`.
RUN FIELD_ENCRYPTION_KEY="$(python -c 'import base64, os; print(base64.urlsafe_b64encode(os.urandom(32)).decode())')" \
python manage.py collectstatic --noinput
EXPOSE 8000
VOLUME $APP_DIR/keyset
CMD ["/run.sh"]