FROM alpine:3.7
MAINTAINER Disassembler <disassembler@dasm.cz>

RUN sed -i 's/postgres:x:70:70/postgres:x:5432:5432/' /etc/passwd \
 && sed -i 's/postgres:x:70/postgres:x:5432/' /etc/group \
 && echo 'http://repository.fit.cvut.cz/mirrors/alpine/edge/testing' >>/etc/apk/repositories \
 && apk --no-cache add postgresql postgresql-contrib postgis \
 && mkdir /run/postgresql \
 && chown postgres:postgres /run/postgresql

VOLUME ["/var/lib/postgresql"]
EXPOSE 5432

USER postgres
CMD ["postgres", "-D", "/var/lib/postgresql"]