FROM ubuntu:18.04

WORKDIR /data
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y apache2

RUN rm /etc/apache2/sites-enabled/000-default.conf
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y postgresql libapache2-mod-wsgi-py3
# make for testing
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y virtualenv make sudo gcc

RUN ln -s /data/dev/apache-local.conf /etc/apache2/sites-enabled/
#RUN a2enmod rewrite


RUN sed -i "s#data_directory = '.*'#data_directory = '/data/run/postgres'#" /etc/postgresql/10/main/postgresql.conf
RUN echo "host all  all    0.0.0.0/0  md5" >> /etc/postgresql/10/main/pg_hba.conf
RUN echo "listen_addresses='*'" >> /etc/postgresql/10/main/postgresql.conf

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y docker.io libmpich-dev nano
RUN echo 'DOCKER_OPTS="-g /data/run/docker"' >> /etc/default/docker
RUN adduser --system --no-create-home --home /data --uid 1001  unpriv
RUN usermod -a -G docker www-data

CMD /data/dev/run-internal.sh
