postgis / docker-postgis

Docker image for PostGIS
https://hub.docker.com/r/postgis/postgis/
MIT License
1.35k stars 462 forks source link

Support `POSTGRES_INITDB_ARGS` env var #327

Open jvacek opened 1 year ago

jvacek commented 1 year ago

I want to init the DB with --nosync as I'm using it in CI for testing, and I do not care for persistence.

Currently I do this in my job to achieve something similar

    - name: Change Postgresql Settings
      run: |
        docker exec -i postgres_test bash << EOF
          sed -i -e 's/fsync = off/fsync = on/' /var/lib/postgresql/data/postgresql.conf
          sed -i -e 's/synchronous_commit = off/synchronous_commit = on/' /var/lib/postgresql/data/postgresql.conf
          sed -i -e 's/full_page_writes = off/full_page_writes = on/' /var/lib/postgresql/data/postgresql.conf
          sed -i -e 's/shared_buffers = 128MB/shared_buffers = 2GB/' /var/lib/postgresql/data/postgresql.conf
        EOF
        docker restart --time 0 postgres_test
        sleep 5

The official postgres has support for passing the env var POSTGRES_INITDB_ARGS, which would be a lot less hacky than this and would allow me to shave off the extra time.

https://github.com/docker-library/postgres/search?q=POSTGRES_INITDB_ARGS

ImreSamu commented 1 year ago

Hi @jvacek !

The official postgres has support for passing the env var POSTGRES_INITDB_ARGS, which would be a lot less hacky than this and would allow me to shave off the extra time.

This repo based on the official "upstream" postgres images, so all official "upstream" - "Environment Variables" extensions should work with the postgis/postgis images!

see: https://hub.docker.com/_/postgres/

So you can replace the postgres:15-bullseye with postgis/postgis:15-3.3 and everything should work!