IMAGE postgres_12.4.0-201021
FROM alpine3.12_3.12.1-201021

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