Merge pull request #296 from gis-ops/nn_optional_startup_lockfile2

Optional execution of startup scripts on every container start
pull/303/head
mazano 2021-03-02 13:26:02 +02:00 zatwierdzone przez GitHub
commit 0beb1ece8f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
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 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 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 #### 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. 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_USER=<PGUSER>`
* `-e POSTGRES_PASS=<PGPASSWORD>` * `-e POSTGRES_PASS=<PGPASSWORD>`
**NB** You should use a strong passwords. If you are using docker-compose make sure **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 `$$` need to escape it ie `$$`
* `-e POSTGRES_DBNAME=<PGDBNAME>` * `-e POSTGRES_DBNAME=<PGDBNAME>`
* `-e POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology,postgis_raster,pgrouting` * `-e POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology,postgis_raster,pgrouting`
@ -218,7 +218,7 @@ You can pass a comma separated value of schema names which will be created when
database specified in the environment variable `POSTGRES_DBNAME`. If you need to database specified in the environment variable `POSTGRES_DBNAME`. If you need to
create matching schemas in all the databases that will be created you use create matching schemas in all the databases that will be created you use
the environment variable `ALL_DATABASES=TRUE` the environment variable `ALL_DATABASES=TRUE`
#### Configures archive mode #### Configures archive mode
This image uses the initial PostgreSQL values which disables the archiving option by default. This image uses the initial PostgreSQL values which disables the archiving option by default.
@ -340,7 +340,7 @@ database. Since the environment variable POSTGRES_DB allows
us to specify multiple database that can be created on startup. us to specify multiple database that can be created on startup.
When running scripts they will only be executed against the When running scripts they will only be executed against the
first database ie POSTGRES_DB=gis,data,sample 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. Currently you can pass `.sql` , `.sql.gz` and `.sh` files as mounted volumes.
@ -441,7 +441,7 @@ with the following SQL assuming the ${REPLICATION_USER} is called replicator
ALTER DEFAULT PRIVILEGES IN SCHEMA data GRANT SELECT ON TABLES TO 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` 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) To experiment with the replication abilities, you can see a [docker-compose.yml](sample/replication/docker-compose.yml)
@ -563,7 +563,7 @@ For a detailed example see the docker-compose in the folder `sample/logical_repl
### Support ### Support
If you require more substantial assistance from [kartoza](https://kartoza.com) (because our work and interaction on docker-postgis is pro bono), 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 ## Credits
@ -571,4 +571,4 @@ Tim Sutton (tim@kartoza.com)
Gavin Fleming (gavin@kartoza.com) Gavin Fleming (gavin@kartoza.com)
Rizky Maulana (rizky@kartoza.com) Rizky Maulana (rizky@kartoza.com)
Admire Nyakudya (admire@kartoza.com) Admire Nyakudya (admire@kartoza.com)
March 2021 March 2021

Wyświetl plik

@ -246,6 +246,10 @@ if [ -z "${REPLICATION_PASS}" ]; then
fi fi
if [ -z "$IGNORE_INIT_HOOK_LOCKFILE" ]; then
IGNORE_INIT_HOOK_LOCKFILE=false
fi
if [ -z "$EXTRA_CONF" ]; then if [ -z "$EXTRA_CONF" ]; then
EXTRA_CONF="" EXTRA_CONF=""
fi fi
@ -324,7 +328,7 @@ function restart_postgres {
function entry_point_script { function entry_point_script {
SETUP_LOCKFILE="/docker-entrypoint-initdb.d/.entry_point.lock" SETUP_LOCKFILE="/docker-entrypoint-initdb.d/.entry_point.lock"
# If lockfile doesn't exists, proceed. # 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 if find "/docker-entrypoint-initdb.d" -mindepth 1 -print -quit 2>/dev/null | grep -q .; then
for f in /docker-entrypoint-initdb.d/*; do for f in /docker-entrypoint-initdb.d/*; do
export PGPASSWORD=${POSTGRES_PASS} export PGPASSWORD=${POSTGRES_PASS}
@ -365,4 +369,3 @@ until su - postgres -c "${PG_BASEBACKUP} -X stream -h ${REPLICATE_FROM} -p ${REP
done done
} }