forked from dbca-wa/wildlifecompliance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
120 lines (105 loc) · 4.87 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
# Prepare the base environment.
FROM ubuntu:20.04 as builder_base_wls
MAINTAINER [email protected]
ENV DEBIAN_FRONTEND=noninteractive
ENV DEBUG=True
ENV TZ=Australia/Perth
ENV EMAIL_HOST="smtp.corporateict.domain"
ENV DEFAULT_FROM_EMAIL='[email protected]'
ENV NOTIFICATION_EMAIL='[email protected]'
ENV NON_PROD_EMAIL='[email protected]'
ENV PRODUCTION_EMAIL=False
ENV EMAIL_INSTANCE='DEV'
ENV SECRET_KEY="ThisisNotRealKey"
ENV SITE_PREFIX='wls-uat'
ENV SITE_DOMAIN='dbca.wa.gov.au'
ENV OSCAR_SHOP_NAME='Department of Biodiversity, Conservation and Attractions'
ENV BPAY_ALLOWED=False
# For app.js, manifest.js, vendor.js versioning (default value set to 0.0.0)
ARG build_tag=0.0.0
#ENV BUILD_TAG=$build_tag
RUN echo "*************************************************** Build TAG = $build_tag ***************************************************"
# Install Python libs from base environment.
RUN apt-get clean
RUN apt-get update
RUN apt-get upgrade -y
# RUN apt-get install -yq git mercurial gcc gdal-bin libsasl2-dev libpq-dev \
# python python-setuptools python-dev python-pip \
# imagemagick poppler-utils \
# libldap2-dev libssl-dev wget build-essential \
# libmagic-dev binutils libproj-dev gunicorn tzdata \
# mtr libevent-dev python-gevent \
# cron rsyslog iproute2
# RUN pip install --upgrade pip
# RUN apt-get install -yq vim
RUN apt-get install --no-install-recommends -y wget git libmagic-dev gcc \
binutils libproj-dev gdal-bin python3-setuptools python3-pip tzdata cron \
rsyslog gunicorn libreoffice
RUN apt-get install --no-install-recommends -y libpq-dev patch
RUN apt-get install --no-install-recommends -y postgresql-client mtr htop \
vim
RUN apt-get install --no-install-recommends -y python3-gevent \
software-properties-common imagemagick
RUN apt-get install --no-install-recommends -y npm bzip2
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update
RUN apt-get install --no-install-recommends -y python3.7 python3.7-dev python3.7-distutils
RUN apt-get install --no-install-recommends -y graphviz libgraphviz-dev pkg-config
RUN ln -s /usr/bin/python3.7 /usr/bin/python
# ln -s /usr/bin/pip3 /usr/bin/pip
RUN python3.7 -m pip install --upgrade pip
RUN apt-get install -yq vim
# Install Python libs from requirements.txt.
FROM builder_base_wls as python_libs_wls
WORKDIR /app
COPY requirements.txt ./
#COPY git_history_recent ./
RUN touch /app/rand_hash
RUN python3.7 -m pip install --no-cache-dir -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
# && sed -i -e "s/ver = geos_version().decode()/ver = geos_version().decode().split(' ')[0]/" /usr/local/lib/python2.7/dist-packages/django/contrib/gis/geos/libgeos.py \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/ /tmp/* /var/tmp/*
COPY libgeos.py.patch /app/
RUN patch /usr/local/lib/python3.7/dist-packages/django/contrib/gis/geos/libgeos.py /app/libgeos.py.patch
RUN rm /app/libgeos.py.patch
# Install the project (ensure that frontend projects have been built prior to this step).
FROM python_libs_wls
COPY gunicorn.ini manage_wc.py ./
#COPY timezone /etc/timezone
RUN echo "Australia/Perth" > /etc/timezone
ENV TZ=Australia/Perth
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN touch /app/.env
COPY .git ./.git
#COPY ledger ./ledger
COPY wildlifecompliance ./wildlifecompliance
RUN cd /app/wildlifecompliance/frontend/wildlifecompliance; npm install
RUN cd /app/wildlifecompliance/frontend/wildlifecompliance; npm run build
RUN python manage_wc.py collectstatic --noinput
# upgrade postgresql to v11
#RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main 11" > /etc/apt/sources.list.d/pgsql.list
#RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main 11" > /etc/apt/sources.list.d/pgsql.list
#RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
#RUN apt update && apt install -y lsb-release postgresql-11 postgresql-client
RUN mkdir /app/tmp/
RUN chmod 777 /app/tmp/
COPY cron /etc/cron.d/dockercron
COPY startup.sh /
# Cron start
RUN service rsyslog start
RUN chmod 0644 /etc/cron.d/dockercron
RUN crontab /etc/cron.d/dockercron
RUN touch /var/log/cron.log
RUN service cron start
RUN chmod 755 /startup.sh
# cron end
# IPYTHONDIR - Will allow shell_plus (in Docker) to remember history between sessions
RUN export IPYTHONDIR=/app/logs/.ipython/
# Health checks for kubernetes
RUN wget https://raw.githubusercontent.com/dbca-wa/wagov_utils/main/wagov_utils/bin/health_check.sh -O /bin/health_check.sh
RUN chmod 755 /bin/health_check.sh
EXPOSE 8080
HEALTHCHECK --interval=1m --timeout=5s --start-period=10s --retries=3 CMD ["wget", "-q", "-O", "-", "http://localhost:8080/"]
CMD ["/startup.sh"]
#CMD ["gunicorn", "wildlifecompliance.wsgi", "--bind", ":8080", "--config", "gunicorn.ini"]