FROM postgres:12

# Allow for connecting to database without password authentication
ENV POSTGRES_HOST_AUTH_METHOD=trust

USER postgres

# postgresql.conf and postgres_hba.conf resulted in error (Invalid data directory or sth); using -o/--options in initdb.sh instead
# COPY --chown=postgres:postgres --chmod=644 ./postgresql.conf /etc/postgresql/12/main/postgresql.conf
# COPY --chown=postgres:postgres --chmod=644 ./pg_hba.conf /etc/postgresql/12/main/pg_hba.conf
COPY ./schema.sql /schema.sql
COPY --chmod=755 ./initdb.sh /etc/fradrive-db

ENTRYPOINT /etc/fradrive-db