71 lines
2.2 KiB
Docker
71 lines
2.2 KiB
Docker
FROM ubuntu:18.04
|
|
|
|
RUN set -ex; \
|
|
apt-get update; \
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
|
python3 python3-pip uwsgi uwsgi-plugin-python3 nginx postgresql-10 postgresql-client-10 vim-nox \
|
|
python3-dev build-essential; \
|
|
rm -rf /var/lib/apt/lists/*; \
|
|
locale-gen en_US.UTF-8;
|
|
ENV LANG en_US.UTF-8
|
|
VOLUME /var/log
|
|
|
|
# Configure Postgresql
|
|
ENV PGDATA=/var/lib/postgresql/10/main
|
|
RUN set -ex; \
|
|
pg_conftool set lc_messages 'en_US.UTF-8'; \
|
|
pg_conftool set lc_monetary 'en_US.UTF-8'; \
|
|
pg_conftool set lc_numeric 'en_US.UTF-8'; \
|
|
pg_conftool set lc_time 'en_US.UTF-8'; \
|
|
pg_conftool set listen_addresses '';
|
|
COPY pg_hba.conf /etc/postgresql/10/main
|
|
VOLUME /var/lib/postgresql
|
|
|
|
# Create users and a group for the Django apps.
|
|
# Their home dir does not contain the web files; they are in /var/www/{appname}
|
|
RUN set -ex; \
|
|
groupadd django; \
|
|
useradd -g django --no-user-group -m -d /home/mydata mydata; \
|
|
useradd -g django --no-user-group -m -d /home/opendata opendata
|
|
|
|
# Configure uWSGI
|
|
COPY uwsgi/mydata.ini /etc/uwsgi/apps-available
|
|
RUN set -ex; \
|
|
cd /etc/uwsgi/apps-enabled; \
|
|
ln -s ../apps-available/*.ini .
|
|
|
|
# Copy files and install Pipenv
|
|
RUN pip3 install pipenv
|
|
# This creates the Virtualenv inside {project}/.venv
|
|
ENV PIPENV_VENV_IN_PROJECT=1
|
|
COPY deploy/ /var/www/
|
|
|
|
# Set up My Data
|
|
WORKDIR /var/www/mydata
|
|
RUN pipenv install --deploy
|
|
COPY --chown=mydata:django deploytime-settings-mydata.py /var/www/mydata/mydata/settings.py
|
|
RUN pipenv run python3 manage.py collectstatic --noinput
|
|
|
|
# Set up Open Data
|
|
WORKDIR /var/www/opendata
|
|
RUN pipenv install --deploy
|
|
COPY --chown=mydata:django deploytime-settings-opendata.py /var/www/opendata/opendata/settings.py
|
|
RUN pipenv run python3 manage.py collectstatic --noinput
|
|
WORKDIR /
|
|
|
|
VOLUME /var/www/secrets/
|
|
EXPOSE 80
|
|
|
|
COPY entrypoint.sh /
|
|
COPY create_db.sh /
|
|
CMD ["/bin/bash", "/entrypoint.sh"]
|
|
|
|
# Generate on the host with:
|
|
# openssl dhparam -out /etc/nginx/ssl/dhparams.pem 4096
|
|
VOLUME /etc/nginx/ssl
|
|
|
|
# Configure nginx
|
|
COPY nginx/snippets/* /etc/nginx/snippets/
|
|
COPY nginx/sites-available/* /etc/nginx/sites-available/
|
|
RUN ln -s /etc/nginx/sites-available/mydata /etc/nginx/sites-enabled/
|