-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDockerfile
143 lines (122 loc) · 4.73 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
134
135
136
137
138
139
140
141
142
143
# syntax = docker/dockerfile:1.2
# Prepare the base environment.
FROM ubuntu:22.04 as builder_base_bfrs
LABEL maintainer="[email protected]"
ENV DEBIAN_FRONTEND=noninteractive \
TZ=Australia/Perth \
PRODUCTION_EMAIL=True \
SECRET_KEY="ThisisNotRealKey" \
USER_SSO="Docker Build" \
PASS_SSO="ThisIsNotReal" \
EMAIL_HOST="localhost" \
FROM_EMAIL="[email protected]" \
SMS_POSTFIX="sms.url.endpoint"
# 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
RUN apt install openssl
COPY openssl-legacy.conf /
# RUN ls -al /etc/ssl/
RUN cat /openssl-legacy.conf >> /etc/ssl/openssl.cnf
RUN rm /openssl-legacy.conf
# RUN --mount=type=cache,target=/var/cache/apt apt-get update
RUN apt-get update
RUN apt-get upgrade -y && \
apt-get install --no-install-recommends -y \
binutils \
cron \
gcc \
gdal-bin \
git \
libmagic-dev \
libproj-dev \
libpq-dev \
python2 \
python2-dev \
python-pip \
python-setuptools \
ipython3 \
tzdata \
wget \
curl \
vim \
texlive-full
RUN apt-get install virtualenv -y
# rm -rf /var/lib/apt/lists/*
#COPY get-pip.py /tmp/get-pip.py
#RUN python2 /tmp/get-pip.py
RUN apt-get install patch
# RUN ln -s /usr/bin/python2 /usr/bin/python && \
# pip install --upgrade pip==20.3
# Setup cron
# COPY cron /etc/cron.d/dockercron
COPY startup.sh /
# COPY pre_startup.sh /
# RUN chmod 0644 /etc/cron.d/dockercron && \
# crontab /etc/cron.d/dockercron && \
# touch /var/log/cron.log && \
# mkdir /container-config/ && \
RUN chmod 755 /startup.sh
# RUN chmod +s /startup.sh
# RUN chmod 755 /pre_startup.sh && \
# RUN chmod +s /pre_startup.sh
RUN groupadd -g 5000 oim
RUN useradd -g 5000 -u 5000 oim -s /bin/bash -d /app
RUN usermod -a -G sudo oim
# RUN echo "oim ALL=(ALL) NOPASSWD: /startup.sh" > /etc/sudoers.d/oim && \
RUN mkdir /app
RUN chown -R oim.oim /app
# Default Scripts
RUN wget https://raw.githubusercontent.com/dbca-wa/wagov_utils/main/wagov_utils/bin/default_script_installer.sh -O /tmp/default_script_installer.sh
RUN chmod 755 /tmp/default_script_installer.sh
RUN /tmp/default_script_installer.sh
# Install Python libs from requirements.txt.
FROM builder_base_bfrs as python_libs_bfrs
WORKDIR /app
USER oim
RUN virtualenv -p python2.7 /app/venv
ENV PATH=/app/venv/bin:$PATH
COPY requirements.txt ./
RUN ls -al /app/venv/bin/
RUN whereis pip
RUN pip install -r requirements.txt
# Update the Django <1.11 bug in django/contrib/gis/geos/libgeos.py
# Reference: https://stackoverflow.com/questions/18643998/geodjango-geosexception-error
RUN find /app/venv | grep libgeos
RUN sed -i -e "s/ver = geos_version().decode()/ver = geos_version().decode().split(' ')[0]/" /app/venv/lib/python2.7/site-packages/django/contrib/gis/geos/libgeos.py
# Install the project (ensure that frontend projects have been built prior to this step).
FROM python_libs_bfrs as collect_static_bfrs
COPY gunicorn.ini manage.py ./
COPY bfrs ./bfrs
COPY bfrs_project ./bfrs_project
COPY templates ./templates
COPY python-cron ./
# COPY md4byte_generate.py /bin/md4byte_generate.py
# RUN chmod 755 /bin/md4byte_generate.py
# COPY compute_hash_patch.diff /tmp/compute_hash_patch.diff
# RUN patch -p1 /usr/local/lib/python2.7/dist-packages/ntlm_auth/compute_hash.py < /tmp/compute_hash_patch.diff
# RUN rm /tmp/compute_hash_patch.diff
# NOTE: we can't currently run the collectstatic step due to how BFRS is written.
# Always be sure to run collectstatic locally prior to building the image.
RUN touch /app/.env && \
python2 manage.py collectstatic --noinput
FROM collect_static_bfrs as launch_bfrs
# RUN curl -fsSL -o /tmp/install.sh https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
# RUN chmod 755 /tmp/install.sh
# RUN /tmp/install.sh
# RUN git clone https://github.com/Homebrew/brew ~/.linuxbrew/Homebrew \
# && mkdir ~/.linuxbrew/bin \
# && ln -s ../Homebrew/bin/brew ~/.linuxbrew/bin \
# && eval $(~/.linuxbrew/bin/brew shellenv)
# ENV PATH=/app/.linuxbrew/bin/:$PATH
# RUN ls -al /app/.linuxbrew/bin
# RUN whereis brew
# RUN ln -s ../Homebrew/bin/brew ~/venv/bin/brew
# RUN brew install [email protected]
# RUN ls -al /app/.linuxbrew/opt/openssl\@1.1/bin/openssl
# RUN ln -s /app/.linuxbrew/opt/openssl\@1.1/bin/openssl /app/venv/bin/openssl
# RUN openssl version
EXPOSE 8080
HEALTHCHECK --interval=1m --timeout=5s --start-period=10s --retries=3 CMD ["wget", "-q", "-O", "-", "http://localhost:8080/"]
CMD ["/startup.sh"]