Sample docker-compose.yml:
version: '3'services:
startup_services:
image: fusionauth/wait-for-jsondepends_on:
- fusionauthnetworks:
- fusionauthcommand: fusionauth:9011/api/statusdb:
image: postgres:9.6environment:
POSTGRES_USER: ${POSTGRES_USER}POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}ports:
- 54320:5432networks:
- dbrestart: unless-stoppedsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.3.1environment:
cluster.name: fusionauthbootstrap.memory_lock: "true"ES_JAVA_OPTS: "${ES_JAVA_OPTS}"ports:
- 9200:9200
- 9300:9300networks:
- searchrestart: unless-stoppedulimits:
memlock:
soft: -1hard: -1fusionauth:
image: fusionauth/fusionauth-app:latestdepends_on:
- db
- searchenvironment:
DATABASE_URL: jdbc:postgresql://db:5432/fusionauthDATABASE_ROOT_USER: ${POSTGRES_USER}DATABASE_ROOT_PASSWORD: ${POSTGRES_PASSWORD}DATABASE_USER: ${DATABASE_USER}DATABASE_PASSWORD: ${DATABASE_PASSWORD}FUSIONAUTH_MEMORY: ${FUSIONAUTH_MEMORY}FUSIONAUTH_SEARCH_SERVERS: http://search:9200FUSIONAUTH_URL: http://fusionauth:9010FUSIONAUTH_KICKSTART: /usr/local/fusionauth/kickstart.jsonFUSIONAUTH_APP_INSTALLATION_SOURCE: fusionauth-wait-for-jsonnetworks:
- db
- fusionauth
- searchrestart: unless-stoppedports:
- 9010:9011volumes:
- ./kickstart.json:/usr/local/fusionauth/kickstart.jsonnetworks:
db:
driver: bridgefusionauth:
driver: bridgesearch:
driver: bridgeThen, to guarantee that fusionauth and its dependencies are ready before running proceeding by waiting on a JSON response from fusionauth:9011/api/status:
$ docker-compose run --rm startup_servicesYou may specify multiple endpoints to wait for JSON response from by seperating them with spaces in the command directive:
startup_services:
image: fusionauth/wait-for-jsondepends_on:
- fusionauthnetworks:
- fusionauthcommand: fusionauth:9011/api/foo fusionauth:9011/api/bar fusionauth:9011/api/bazstart_dependencies:
image: fusionauth/wait-for-jsonenvironment:
- SLEEP_LENGTH: 1
- TIMEOUT_LENGTH: 60
- JSON_TYPE: arrayBy default, there will be a 2 second sleep time between each check. You can modify this by setting the SLEEP_LENGTH environment variable:
start_dependencies:
image: fusionauth/wait-for-jsonenvironment:
- SLEEP_LENGTH: 0.5By default, there will be a 300 seconds timeout before cancelling the wait_for. You can modify this by setting the TIMEOUT_LENGTH environment variable:
start_dependencies:
image: fusionauth/wait-for-jsonenvironment:
- SLEEP_LENGTH: 1
- TIMEOUT_LENGTH: 60By default, we will wait for a JSON object to be returned from the specified endpoints. You can modify this by setting the JSON_TYPE environment variable to one of null, boolean, number, string, array or object:
start_dependencies:
image: fusionauth/wait-for-jsonenvironment:
- SLEEP_LENGTH: 1
- TIMEOUT_LENGTH: 60
- JSON_TYPE: array