build(docker/database): use postgres-container given .d dir to automatically apply postgres config

This commit is contained in:
Sarah Vaupel 2024-10-01 09:59:15 +02:00
parent 09e53fda53
commit 2295f54486
2 changed files with 12 additions and 5 deletions

View File

@ -3,11 +3,13 @@ FROM docker.io/postgres:12
# Allow for connecting to database without password authentication
ENV POSTGRES_HOST_AUTH_METHOD=trust
RUN cp /mnt/fradrive/docker/database/pg_hba.conf /docker-entrypoint-initdb.d/pg_hba.conf && chown postgres:postgres /docker-entrypoint-initdb.d/pg_hba.conf
RUN cp /mnt/fradrive/docker/database/postgresql.conf /docker-entrypoint-initdb.d/postgresql.conf && chown postgres:postgres /docker-entrypoint-initdb.d/postgresql.conf
COPY --chown=postgres:postgres docker/database/pg_hba.conf /tmp/pg_hba.conf
COPY --chown=postgres:postgres docker/database/postgresql.conf /tmp/postgresql.conf
COPY docker/database/pgconfig.sh /docker-entrypoint-initdb.d/_pgconfig.sh
COPY --chown=postgres:postgres docker/database/schema.sql /docker-entrypoint-initdb.d/schema.sql
RUN cp /mnt/fradrive/docker/database/schema.sql /schema.sql && chown postgres:postgres /schema.sql
RUN cp /mnt/fradrive/docker/database/initdb.sh /etc/fradrive-db && chmod 755 /etc/fradrive-db
# RUN cp /mnt/fradrive/docker/database/schema.sql /schema.sql && chown postgres:postgres /schema.sql
# RUN cp /mnt/fradrive/docker/database/initdb.sh /etc/fradrive-db && chmod 755 /etc/fradrive-db
USER postgres
@ -17,5 +19,4 @@ USER postgres
# ADD ./schema.sql /schema.sql
# ADD --chmod=755 ./initdb.sh /etc/fradrive-db
ENTRYPOINT /etc/fradrive-db
EXPOSE 5432/tcp

6
docker/database/pgconfig.sh Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
cat /tmp/pg_hba.conf > /var/lib/postgresql/data/pg_hba.conf
cat /tmp/postgresql.conf > /var/lib/postgresql/data/postgresql.conf
echo "Custom pg_hba.conf and postgresql.conf successfully deployed."