-
Notifications
You must be signed in to change notification settings - Fork 91
/
Dockerfile
94 lines (71 loc) · 2.29 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
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
# A base ocfweb Dockerfile containing the code and dependencies.
# This doesn't run the website or the background worker; see Dockerfile.* for those.
FROM theocf/debian:bullseye-py AS base
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
cracklib-runtime \
libcrack2 \
libcrack2-dev \
libffi-dev \
libfreetype6-dev \
libpng-dev \
libssl-dev \
libxft-dev \
libxml2-dev \
locales \
nginx \
python3-dev \
python3-pip \
python-is-python3 \
redis-tools \
runit \
rustc \
yui-compressor \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN pip3 install virtualenv
RUN install -d --owner=nobody /opt/ocfweb /opt/ocfweb/venv /etc/ocfweb
COPY requirements.txt /opt/ocfweb/
RUN virtualenv -ppython3.9 /opt/ocfweb/venv \
&& /opt/ocfweb/venv/bin/pip install \
-r /opt/ocfweb/requirements.txt
ARG ocflib_version=
RUN /opt/ocfweb/venv/bin/pip install ocflib${ocflib_version}
COPY bootstrap-scss /opt/ocfweb/bootstrap-scss/
COPY manage.py /opt/ocfweb/
COPY ocfweb /opt/ocfweb/ocfweb/
COPY conf /etc/ocfweb/
ENV MATPLOTLIBRC /etc/ocfweb
# Kubernetes will set this to 0, but we set it to 1 in case staff run this
# locally to prevent ocflib report emails.
ENV OCFWEB_TESTING 1
WORKDIR /opt/ocfweb
CMD ["runsvdir", "/opt/ocfweb/services"]
##########
# static #
##########
FROM base AS static
RUN /opt/ocfweb/venv/bin/pysassc /opt/ocfweb/ocfweb/static/scss/site.scss /opt/ocfweb/ocfweb/static/scss/site.scss.css
RUN find /opt/ocfweb/ocfweb/ \( -name '*.js' -o -name '*.css' \) -exec yui-compressor -o {} {} \;
RUN mkdir /opt/ocfweb/static
ENV OCFWEB_STATIC_ROOT /opt/ocfweb/static
RUN /opt/ocfweb/venv/bin/python /opt/ocfweb/manage.py collectstatic --noinput
COPY services/static /opt/ocfweb/services/static
RUN chown -R nobody:nogroup /opt/ocfweb/services
USER nobody
#######
# web #
#######
FROM base as web
COPY services/web /opt/ocfweb/services/
RUN chown -R nobody:nogroup /opt/ocfweb/services
USER nobody
##########
# worker #
##########
FROM base as worker
COPY services/worker /opt/ocfweb/services/worker
RUN chown -R nobody:nogroup /opt/ocfweb/services
USER nobody
# vim: ft=Dockerfile