FROM debian:jessie

# Install postgresql-9.4
RUN apt-get update && apt-get install --no-install-recommends postgresql-9.4 -y

# Add startupscripts to docker image
ADD ./startup.sh /usr/local/bin/startup.sh
ADD ./startup_postgres.sh /usr/local/bin/startup_postgres.sh

# Make the startup scripts executable
RUN chmod 700 /usr/local/bin/startup.sh
RUN chmod 700 /usr/local/bin/startup_postgres.sh

# Change ownership of startup_postgres to user postgres
RUN chown postgres /usr/local/bin/startup_postgres.sh

# Mark /data as volume
VOLUME /data
ENV PGDATA /data/postgres

# Expose the default postgres port 5432
EXPOSE 5432

# Set startup.sh as start point from
CMD /usr/local/bin/startup.sh
