From 69ce0ba1c1aa54d99682fd14f20a97ecd7dbde2c Mon Sep 17 00:00:00 2001 From: JeremJR Date: Fri, 8 Sep 2017 18:58:42 +0200 Subject: [PATCH 1/2] add docker-compose example for bonita --- bonita/content.md | 4 ++++ bonita/stack.yml | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 bonita/stack.yml diff --git a/bonita/content.md b/bonita/content.md index ad1266ef1..c195c0a60 100644 --- a/bonita/content.md +++ b/bonita/content.md @@ -75,6 +75,10 @@ $ docker run --name=bonita -e "TENANT_LOGIN=tech_user" -e "TENANT_PASSWORD=secre Now you can access the Bonita BPM Portal on localhost:8080/bonita and login using: tech_user / secret +## %%STACK%% + +Run `docker stack deploy -c stack.yml %%REPO%%` (or `docker-compose -f stack.yml up`), wait for it to initialize completely, and visit `http://swarm-ip:8080`, `http://localhost:8080`, or `http://host-ip:8080` (as appropriate). + ## Where to store data Most of the data are stored in a database and can be stored outside the Bonita container as described above using the PostgreSQL or MySQL container. However, some data remains inside the Bonita bundle. Bonita Home is a folder, called `bonita`, which contains configuration, working, and temporary folders and files. There are also log files inside the `logs` folder. diff --git a/bonita/stack.yml b/bonita/stack.yml new file mode 100644 index 000000000..9b4263d29 --- /dev/null +++ b/bonita/stack.yml @@ -0,0 +1,56 @@ +# Use tech_user/secret as user/password credentials +version: '3' + +services: + + db: + image: postgres:9.3 + environment: + POSTGRES_PASSWORD: example + entrypoint: &postgres-script + - sh + - -c + - | + 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: + image: bonita + ports: + - 8080:8080 + environment: + - POSTGRES_ENV_POSTGRES_PASSWORD=example + - DB_VENDOR=postgres + - DB_HOST=db + - TENANT_LOGIN=tech_user + - TENANT_PASSWORD=secret + - PLATFORM_LOGIN=pfadmin + - PLATFORM_PASSWORD=pfsecret + depends_on: + - db + entrypoint: &bonita-script + - sh + - -c + - | + set -e + cat > /wait-for-postgres.sh <<- EOM + #!/bin/bash + # wait-for-postgres.sh + set -e + host="\$$1" + shift + cmd="\$$@" + PGPASSWORD=\$$POSTGRES_ENV_POSTGRES_PASSWORD + export PGPASSWORD + until psql -h "\$$host" -U "postgres" -c '\l'; do + >&2 echo "Postgres is unavailable - sleeping" + sleep 1 + 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 From 911024a3d9f3d3695a748103c7b94cd60ed18805 Mon Sep 17 00:00:00 2001 From: JeremJR Date: Wed, 1 Nov 2017 17:53:21 +0100 Subject: [PATCH 2/2] apply yosifkit's advice --- bonita/stack.yml | 56 +++++++++++++++++++----------------------------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/bonita/stack.yml b/bonita/stack.yml index 9b4263d29..23960027f 100644 --- a/bonita/stack.yml +++ b/bonita/stack.yml @@ -2,21 +2,14 @@ version: '3' services: - db: image: postgres:9.3 environment: POSTGRES_PASSWORD: example - entrypoint: &postgres-script - - sh - - -c - - | - 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 - + restart: always + command: + - -c + - max_prepared_transactions=100 bonita: image: bonita ports: @@ -29,28 +22,23 @@ services: - TENANT_PASSWORD=secret - PLATFORM_LOGIN=pfadmin - PLATFORM_PASSWORD=pfsecret + restart: always depends_on: - db - entrypoint: &bonita-script - - sh - - -c - - | - set -e - cat > /wait-for-postgres.sh <<- EOM - #!/bin/bash - # wait-for-postgres.sh - set -e - host="\$$1" - shift - cmd="\$$@" - PGPASSWORD=\$$POSTGRES_ENV_POSTGRES_PASSWORD - export PGPASSWORD - until psql -h "\$$host" -U "postgres" -c '\l'; do - >&2 echo "Postgres is unavailable - sleeping" - sleep 1 - 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 + entrypoint: + - bash + - -c + - | + set -e + echo 'Waiting for Postgres to be available' + export PGPASSWORD="$$POSTGRES_ENV_POSTGRES_PASSWORD" + maxTries=10 + while [ "$$maxTries" -gt 0 ] && ! psql -h "$$DB_HOST" -U 'postgres' -c '\l'; do + sleep 1 + done + echo + if [ "$$maxTries" -le 0 ]; then + echo >&2 'error: unable to contact Postgres after 10 tries' + exit 1 + fi + exec /opt/files/startup.sh