Skip to content

Instantly share code, notes, and snippets.

@krujos
Created October 10, 2014 04:40
Show Gist options
  • Save krujos/83b44e59e06eb7c15e67 to your computer and use it in GitHub Desktop.
Save krujos/83b44e59e06eb7c15e67 to your computer and use it in GitHub Desktop.
Dockerfile to build on top of postgres, brittle and gross, but works by more or less reimplementing the entry point.
FROM postgres:9.3
MAINTAINER krujos
ENV PGDATA /var/lib/postgresql/data #Why do I need this?
RUN chown -R postgres "$PGDATA"; gosu postgres initdb; sed -ri "s/^#(listen_addresses\s*=\s*)\S+/\1'*'/" "$PGDATA"/postgresql.conf ; { echo; echo 'host all all 0.0.0.0/0 trust'; } >> "$PGDATA"/pg_hba.conf
RUN ( chown -R postgres "$PGDATA"; gosu postgres postgres & sleep 2 ; psql -U postgres -c "create user schedule_user;"; psql -U postgres -c "alter user schedule_user password 'schedule_password';"; psql -U postgres -c "create database schedule with owner schedule_user;"; )
ENTRYPOINT ["/docker-entrypoint.sh"]
EXPOSE 5432
CMD ["postgres"]
#docker run -p 5432:5432 -d schedule-postgres
@pipex
Copy link

pipex commented Sep 11, 2015

Did you figure out why the comment is necessary? It's really bizarre that it does not work without the comment, when all logic says that it should not work with the comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment