cable-service/docker/Dockerfile
2017-01-25 19:25:22 +01:00

59 lines
2.4 KiB
Docker

# VERSION: 0.1
# DESCRIPTION: Create a ready-to-use environment for Signal
# AUTHOR: Mario Incandenza <mario.incandenza@autistici.org>
# COMMENTS:
# Cereate a debian box with redis and postgres initialized with Signal
# DB structures
# USAGE:
# # Download this Dockerfile
#
# # Build PostgreSQL image
# docker build -t "signal:0.1" .
#
# docker run -it --name="signal" -p 5432:5432 -p 6379:6379 signal:0.1
#
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"