apply yosifkit's advice
This commit is contained in:
parent
69ce0ba1c1
commit
911024a3d9
|
|
@ -2,21 +2,14 @@
|
||||||
version: '3'
|
version: '3'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
|
||||||
db:
|
db:
|
||||||
image: postgres:9.3
|
image: postgres:9.3
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_PASSWORD: example
|
POSTGRES_PASSWORD: example
|
||||||
entrypoint: &postgres-script
|
restart: always
|
||||||
- sh
|
command:
|
||||||
- -c
|
- -c
|
||||||
- |
|
- max_prepared_transactions=100
|
||||||
set -e
|
|
||||||
echo '#!/bin/bash' > /docker-entrypoint-initdb.d/bonita.sh
|
|
||||||
echo 'sed -i "s/^.*max_prepared_transactions\s*=\s*\(.*\)$$/max_prepared_transactions = 100/" "$$PGDATA"/postgresql.conf' >> /docker-entrypoint-initdb.d/bonita.sh
|
|
||||||
chmod +x /docker-entrypoint-initdb.d/bonita.sh
|
|
||||||
/docker-entrypoint.sh postgres
|
|
||||||
|
|
||||||
bonita:
|
bonita:
|
||||||
image: bonita
|
image: bonita
|
||||||
ports:
|
ports:
|
||||||
|
|
@ -29,28 +22,23 @@ services:
|
||||||
- TENANT_PASSWORD=secret
|
- TENANT_PASSWORD=secret
|
||||||
- PLATFORM_LOGIN=pfadmin
|
- PLATFORM_LOGIN=pfadmin
|
||||||
- PLATFORM_PASSWORD=pfsecret
|
- PLATFORM_PASSWORD=pfsecret
|
||||||
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
entrypoint: &bonita-script
|
entrypoint:
|
||||||
- sh
|
- bash
|
||||||
- -c
|
- -c
|
||||||
- |
|
- |
|
||||||
set -e
|
set -e
|
||||||
cat > /wait-for-postgres.sh <<- EOM
|
echo 'Waiting for Postgres to be available'
|
||||||
#!/bin/bash
|
export PGPASSWORD="$$POSTGRES_ENV_POSTGRES_PASSWORD"
|
||||||
# wait-for-postgres.sh
|
maxTries=10
|
||||||
set -e
|
while [ "$$maxTries" -gt 0 ] && ! psql -h "$$DB_HOST" -U 'postgres' -c '\l'; do
|
||||||
host="\$$1"
|
sleep 1
|
||||||
shift
|
done
|
||||||
cmd="\$$@"
|
echo
|
||||||
PGPASSWORD=\$$POSTGRES_ENV_POSTGRES_PASSWORD
|
if [ "$$maxTries" -le 0 ]; then
|
||||||
export PGPASSWORD
|
echo >&2 'error: unable to contact Postgres after 10 tries'
|
||||||
until psql -h "\$$host" -U "postgres" -c '\l'; do
|
exit 1
|
||||||
>&2 echo "Postgres is unavailable - sleeping"
|
fi
|
||||||
sleep 1
|
exec /opt/files/startup.sh
|
||||||
done
|
|
||||||
>&2 echo "Postgres is up - executing command"
|
|
||||||
exec \$$cmd
|
|
||||||
EOM
|
|
||||||
chmod +x /wait-for-postgres.sh
|
|
||||||
/wait-for-postgres.sh $$DB_HOST /opt/files/startup.sh
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue