-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathDockerfile
133 lines (110 loc) · 4.14 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
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
# syntax = docker/dockerfile:1.2
# Prepare the base environment.
FROM ubuntu:24.04 as builder_base_boranga
LABEL maintainer="[email protected]"
LABEL org.opencontainers.image.source="https://github.com/dbca-wa/boranga"
ENV DEBIAN_FRONTEND=noninteractive \
DEBUG=True \
TZ=Australia/Perth \
PRODUCTION_EMAIL=True \
SECRET_KEY="ThisisNotRealKey" \
SITE_PREFIX='qml-dev' \
SITE_DOMAIN='dbca.wa.gov.au' \
OSCAR_SHOP_NAME='Parks & Wildlife' \
BPAY_ALLOWED=False \
NODE_MAJOR=20 \
NODE_OPTIONS=--max_old_space_size=4096
FROM builder_base_boranga as apt_packages_boranga
# Use Australian Mirrors
RUN sed 's/archive.ubuntu.com/au.archive.ubuntu.com/g' /etc/apt/sources.list > /etc/apt/sourcesau.list && \
mv /etc/apt/sourcesau.list /etc/apt/sources.list
RUN --mount=type=cache,target=/var/cache/apt apt-get update && \
apt-get upgrade -y && \
apt-get install --no-install-recommends -y \
binutils \
bzip2 \
ca-certificates \
curl \
g++ \
gcc \
gdal-bin \
git \
graphviz \
htop \
ipython3 \
libgdal-dev \
libgraphviz-dev \
libmagic-dev \
libpq-dev \
libproj-dev \
libreoffice \
mtr \
patch \
postgresql-client \
python3-dev \
python3-gdal \
python3-pil \
python3-pip \
python3-setuptools \
python3-venv \
software-properties-common \
sqlite3 \
ssh \
sudo \
systemd \
tzdata \
vim \
wget && \
rm -rf /var/lib/apt/lists/* && \
update-ca-certificates
FROM apt_packages_boranga as node_boranga
# install node
RUN mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" \
| tee /etc/apt/sources.list.d/nodesource.list && \
apt-get update && \
apt-get install -y nodejs
FROM node_boranga as configure_boranga
COPY startup.sh /
RUN chmod 755 /startup.sh && \
chmod +s /startup.sh && \
groupadd -g 5000 oim && \
useradd -g 5000 -u 5000 oim -s /bin/bash -d /app && \
usermod -a -G sudo oim && \
echo "oim ALL=(ALL) NOPASSWD: /startup.sh" > /etc/sudoers.d/oim && \
mkdir /app && \
chown -R oim.oim /app && \
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && \
wget https://raw.githubusercontent.com/dbca-wa/wagov_utils/main/wagov_utils/bin/default_script_installer.sh -O /tmp/default_script_installer.sh && \
chmod 755 /tmp/default_script_installer.sh && \
/tmp/default_script_installer.sh && \
rm -rf /tmp/*
FROM configure_boranga as python_dependencies_boranga
WORKDIR /app
USER oim
ENV VIRTUAL_ENV_PATH=/app/venv
ENV PATH=$VIRTUAL_ENV_PATH/bin:$PATH
COPY --chown=oim:oim requirements.txt gunicorn.ini.py manage.py python-cron ./
COPY --chown=oim:oim .git ./.git
COPY --chown=oim:oim boranga ./boranga
RUN python3.12 -m venv $VIRTUAL_ENV_PATH
RUN $VIRTUAL_ENV_PATH/bin/pip3 install --upgrade pip && \
$VIRTUAL_ENV_PATH/bin/pip3 install --no-cache-dir -r requirements.txt && \
rm -rf /var/lib/{apt,dpkg,cache,log}/ /tmp/* /var/tmp/*
# Libgeos patch. If not used when deploying to production then may be removed.
# COPY libgeos.py.patch /app/
# RUN patch /usr/local/lib/python3.8/dist-packages/django/contrib/gis/geos/libgeos.py /app/libgeos.py.patch
# RUN rm /app/libgeos.py.patch
FROM python_dependencies_boranga as build_vue_boranga
RUN cd /app/boranga/frontend/boranga; npm ci --omit=dev && \
cd /app/boranga/frontend/boranga; npm run build
FROM build_vue_boranga as collectstatic_boranga
RUN touch /app/.env && \
$VIRTUAL_ENV_PATH/bin/python manage.py collectstatic --noinput
FROM collectstatic_boranga as launch_boranga
EXPOSE 8080
HEALTHCHECK --interval=1m --timeout=5s --start-period=10s --retries=3 CMD ["wget", "-q", "-O", "-", "http://localhost:8080/"]
CMD ["/startup.sh"]
# When first deploying to a new environment (e.g. prod)
# patch /home/container/.local/lib/python3.10/site-packages/reversion/migrations/0001_squashed_0004_auto_20160611_1202.py 0001_squashed_0004_auto_20160611_1202.patch