cable-service/docker/Dockerfile

62 lines
2.5 KiB
Text
Raw Normal View History

# VERSION: 0.2
# DESCRIPTION: Create the PostgreSQL 9.4 Databasee in a container
# AUTHOR: Dennis Mojado (denmojo@gmail.com)
# COMMENTS:
# This file describe how to install PostgreSQL with main
# dependencies installed.
# USAGE:
# # Download this Dockerfile
#
# # Build PostgreSQL image
# docker build -t postgresql-9.4
#
# docker run -v /var/lib/postgresql/9.4:/var/lib/postgresql/9.4 \
# postgresql-9.4
#
#
FROM debian:stretch
MAINTAINER Mario Incandenza <mario.incandenza@autistici.org>
ENV DEBIAN_FRONTEND noninteractive
ADD ./accountsdb.xml /tmp
ADD ./messagedb.xml /tmp
RUN apt-get update -qq && apt-get upgrade -y
RUN apt-get install redis-server wget openjdk-8-jre-headless -y
RUN apt-get install postgresql-9.6 postgresql-client-9.6 postgresql-contrib-9.6 libpostgresql-jdbc-java -y
RUN wget https://github.com/liquibase/liquibase/releases/download/liquibase-parent-3.5.3/liquibase-debian_3.5.3_all.deb
RUN dpkg -i liquibase-debian_3.5.3_all.deb
RUN apt-get clean
RUN sed 's/^bind\s\+127\.0\.0\.1/bind 0\.0\.0\.0/g' < /etc/redis/redis.conf > /tmp/redis.conf
RUN cat /tmp/redis.conf > /etc/redis/redis.conf && rm /tmp/redis.conf
RUN echo "/etc/init.d/postgresql start && exit 0" > /etc/rc.local
RUN /etc/init.d/postgresql start &&\
su postgres -c "psql --command \"CREATE USER signal with encrypted password 's1gn4l';\" " &&\
su postgres -c "psql --command \"CREATE DATABASE signaldb WITH OWNER signal;\" " &&\
su postgres -c "liquibase --driver=org.postgresql.Driver --classpath=/usr/share/java/postgresql-jdbc4.jar --url=jdbc:postgresql://localhost:5432/signaldb --username=signal --password=s1gn4l --changeLogFile=/tmp/accountsdb.xml update" &&\
su postgres -c "liquibase --driver=org.postgresql.Driver --classpath=/usr/share/java/postgresql-jdbc4.jar --url=jdbc:postgresql://localhost:5432/signaldb --username=signal --password=s1gn4l --changeLogFile=/tmp/messagedb.xml update"
RUN dpkg -P liquibase
RUN rm liquibase-debian_3.5.3_all.deb
USER postgres
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.6/main/pg_hba.conf
RUN echo "listen_addresses='*'" >> /etc/postgresql/9.6/main/postgresql.conf
EXPOSE 5432 6379
USER root
# VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"] /usr/share/java/postgresql-jdbc4.jar
CMD service redis-server start && su postgres -c "/usr/lib/postgresql/9.6/bin/postgres -D /var/lib/postgresql/9.6/main -c config_file=/etc/postgresql/9.6/main/postgresql.conf"