This repository has been archived on 2023-02-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-my-data/docker/Dockerfile
2018-08-08 15:39:26 +02:00

99 lines
3.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 software-properties-common \
postgresql-10 postgresql-client-10 \
openjdk-11-jre-headless \
python3-dev build-essential vim-nox; \
add-apt-repository ppa:certbot/certbot; \
apt-get update; \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
python-certbot-nginx; \
rm -rf /var/lib/apt/lists/*; \
locale-gen en_US.UTF-8;
ENV LANG en_US.UTF-8
VOLUME /var/log
# Configure Certbot
VOLUME /etc/letsencrypt
# 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 -g 1000 django; \
useradd -u 1000 -g django --no-user-group -m -d /home/mydata mydata; \
useradd -u 1001 -g django --no-user-group -m -d /home/opendata opendata
# Copy files and install Pipenv
RUN pip3 install pipenv
# This creates the Virtualenv inside {project}/.venv
ENV PIPENV_VENV_IN_PROJECT=1
COPY --chown=mydata:django deploy/mydata /var/www/mydata/
COPY --chown=opendata:django deploy/opendata /var/www/opendata/
# Set up My Data
WORKDIR /var/www/mydata
RUN pipenv install --deploy
COPY 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 deploytime-settings-opendata.py /var/www/opendata/opendata/settings.py
RUN pipenv run python3 manage.py collectstatic --noinput
WORKDIR /
VOLUME /var/www/settings/
VOLUME /var/www/downloads/
EXPOSE 80
EXPOSE 443
# Generate on the host with:
# openssl dhparam -out /etc/nginx/ssl/dhparams.pem 4096
VOLUME /etc/nginx/ssl
# Configure nginx
COPY nginx/conf.d/* /etc/nginx/conf.d/
COPY nginx/snippets/* /etc/nginx/snippets/
COPY nginx/sites-available/* /etc/nginx/sites-available/
RUN set -ex; \
ln -s /etc/nginx/sites-available/mydata /etc/nginx/sites-enabled/; \
ln -s /etc/nginx/sites-available/opendata /etc/nginx/sites-enabled/; \
rm -f /etc/nginx/snippets/{snakeoil,fastcgi-php}.conf; \
rm -f /etc/nginx/sites-enabled/default
# Configure uWSGI
COPY uwsgi/* /etc/uwsgi/apps-available/
RUN set -ex; \
cd /etc/uwsgi/apps-enabled; \
ln -s ../apps-available/*.ini .
# Configure ElasticSearch
RUN useradd -u 1002 -m -d /home/elastic elastic
COPY --chown=elastic:elastic deploy/elasticsearch-* /opt/elasticsearch/
COPY --chown=elastic:elastic elasticsearch.yml /opt/elasticsearch/config/
ENV ELASTIC_PID /opt/elasticsearch/elasticsearch.pid
VOLUME /opt/elasticsearch/data
VOLUME /opt/elasticsearch/logs
COPY hosts /etc/hosts
COPY create_db.sh LAYOUT.txt entrypoint.sh /
COPY bash_history /root/.bash_history
CMD ["/bin/bash", "/entrypoint.sh"]