You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
937 B

  1. #!/usr/bin/env bash
  2. CMD_ARGS=$1
  3. KEYCLOAK_DOCKER_IMAGE="quay.io/keycloak/keycloak:latest"
  4. echo "${CMD_ARGS}"
  5. function keycloak_stop() {
  6. docker stop unittest_keycloak &> /dev/null
  7. docker rm unittest_keycloak &> /dev/null
  8. }
  9. function keycloak_start() {
  10. echo "Starting keycloak docker container"
  11. docker run -d --name unittest_keycloak -e KEYCLOAK_ADMIN="${KEYCLOAK_ADMIN}" -e KEYCLOAK_ADMIN_PASSWORD="${KEYCLOAK_ADMIN_PASSWORD}" -p "${KEYCLOAK_PORT}:8080" "${KEYCLOAK_DOCKER_IMAGE}" start-dev
  12. SECONDS=0
  13. until curl --silent --output /dev/null localhost:$KEYCLOAK_PORT; do
  14. sleep 5;
  15. if [ ${SECONDS} -gt 180 ]; then
  16. echo "Timeout exceeded";
  17. exit 1;
  18. fi
  19. done
  20. }
  21. # Ensuring that keycloak is stopped in case of CTRL-C
  22. trap keycloak_stop err exit
  23. keycloak_stop # In case it did not shut down correctly last time.
  24. keycloak_start
  25. eval ${CMD_ARGS}
  26. RETURN_VALUE=$?
  27. exit ${RETURN_VALUE}