add IGNORE_INIT_HOOK_LOCKFILE env var to be able to execute scripts on every container startup

pull/295/head
nilsnolde 2021-03-01 13:20:12 +01:00
rodzic 3ca615878c
commit 8edc0d6c1d
2 zmienionych plików z 13 dodań i 10 usunięć

Wyświetl plik

@ -65,7 +65,7 @@ To build the image yourself do:
docker build -t kartoza/postgis git://github.com/kartoza/docker-postgis
```
Alternatively clone the repository and build against any preferred branch
Alternatively clone the repository and build against any preferred branch
```
git clone git://github.com/kartoza/docker-postgis
@ -101,7 +101,7 @@ docker build --build-arg DISTRO=ubuntu --build-arg IMAGE_VERSION=focal --build-a
#### Locales
By default, the image build will include **all** `locales` to cover any value for `locale` settings such as `DEFAULT_COLLATION`, `DEFAULT_CTYPE` or `DEFAULT_ENCODING`.
By default, the image build will include **all** `locales` to cover any value for `locale` settings such as `DEFAULT_COLLATION`, `DEFAULT_CTYPE` or `DEFAULT_ENCODING`.
You can safely delete all `locales` except for the ones you need in `scripts/locale.gen`. This will speed up the build considerably.
@ -190,7 +190,7 @@ username, password and/or default database name(or multiple databases comma sepa
* `-e POSTGRES_USER=<PGUSER>`
* `-e POSTGRES_PASS=<PGPASSWORD>`
**NB** You should use a strong passwords. If you are using docker-compose make sure
docker can interpolate the password. Example using a password with a `$` you will
docker can interpolate the password. Example using a password with a `$` you will
need to escape it ie `$$`
* `-e POSTGRES_DBNAME=<PGDBNAME>`
* `-e POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology,postgis_raster,pgrouting`
@ -326,7 +326,7 @@ database. Since the environment variable POSTGRES_DB allows
us to specify multiple database that can be created on startup.
When running scripts they will only be executed against the
first database ie POSTGRES_DB=gis,data,sample
The SQL script will be executed against the gis database.
The SQL script will be executed against the gis database. Additionally, a lock file is generated in `/docker-entrypoint-initdb.d`, which will prevent the scripts from getting executed after the first container startup. Provide `IGNORE_INIT_HOOK_LOCKFILE=true` to execute the scripts on _every_ container start.
Currently you can pass `.sql` , `.sql.gz` and `.sh` files as mounted volumes.
@ -427,7 +427,7 @@ with the following SQL assuming the ${REPLICATION_USER} is called replicator
ALTER DEFAULT PRIVILEGES IN SCHEMA data GRANT SELECT ON TABLES TO replicator;
**NB** You need to setup a strong password for replication otherwise the
**NB** You need to setup a strong password for replication otherwise the
default password for ${REPLICATION_USER} will default to `replicator`
To experiment with the replication abilities, you can see a [docker-compose.yml](sample/replication/docker-compose.yml)
@ -549,7 +549,7 @@ For a detailed example see the docker-compose in the folder `sample/logical_repl
### Support
If you require more substantial assistance from [kartoza](https://kartoza.com) (because our work and interaction on docker-postgis is pro bono),
please consider taking out a [Support Level Agreeement](https://kartoza.com/en/shop/product/support)
please consider taking out a [Support Level Agreeement](https://kartoza.com/en/shop/product/support)
## Credits
@ -557,4 +557,4 @@ Tim Sutton (tim@kartoza.com)
Gavin Fleming (gavin@kartoza.com)
Rizky Maulana (rizky@kartoza.com)
Admire Nyakudya (admire@kartoza.com)
October 2020
October 2020

Wyświetl plik

@ -245,7 +245,6 @@ if [ -z "${REPLICATION_PASS}" ]; then
REPLICATION_PASS=replicator
fi
if [ -z "$EXTRA_CONF" ]; then
EXTRA_CONF=""
fi
@ -258,11 +257,16 @@ if [ -z "$PASSWORD_AUTHENTICATION" ]; then
PASSWORD_AUTHENTICATION="scram-sha-256"
fi
if [ -z "$IGNORE_INIT_HOOK_LOCKFILE" ]; then
IGNORE_INIT_HOOK_LOCKFILE=false
fi
# Compatibility with official postgres variable
# Official postgres variable gets priority
if [ -n "${POSTGRES_PASSWORD}" ]; then
POSTGRES_PASS=${POSTGRES_PASSWORD}
fi
if [ -n "${PGDATA}" ]; then
DATADIR=${PGDATA}
fi
@ -320,7 +324,7 @@ function restart_postgres {
function entry_point_script {
SETUP_LOCKFILE="/docker-entrypoint-initdb.d/.entry_point.lock"
# If lockfile doesn't exists, proceed.
if [[ ! -f "${SETUP_LOCKFILE}" ]]; then
if [[ ! -f "${SETUP_LOCKFILE}" ]] || [ "${IGNORE_INIT_HOOK_LOCKFILE}" == true ]; then
if find "/docker-entrypoint-initdb.d" -mindepth 1 -print -quit 2>/dev/null | grep -q .; then
for f in /docker-entrypoint-initdb.d/*; do
export PGPASSWORD=${POSTGRES_PASS}
@ -361,4 +365,3 @@ until su - postgres -c "${PG_BASEBACKUP} -X stream -h ${REPLICATE_FROM} -p ${REP
done
}