apply yosifkit's advice

This commit is contained in:
JeremJR 2017-11-01 17:53:21 +01:00
parent 69ce0ba1c1
commit 911024a3d9
1 changed files with 22 additions and 34 deletions

View File

@ -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