IMAGE postgres_12.2.0-200313
FROM alpine3.11_3.11.3-200313

RUN EOF
    # Create OS user (which will be picked up later by apk add)
    addgroup -S -g 5432 postgres
    adduser -S -u 5432 -h /var/lib/postgresql -s /bin/false -g postgres -G postgres postgres

    # Install PostgreSQL
    apk --no-cache add postgresql postgresql-contrib

    # Create socket directory 
    mkdir /run/postgresql
    chown postgres:postgres /run/postgresql
EOF

USER postgres
CMD /usr/bin/postgres -D /var/lib/postgresql
READY /usr/bin/pg_isready