run.sh 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. set -eo pipefail
  3. dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
  4. serverImage="$1"
  5. # Use a client image with curl for testing
  6. clientImage='buildpack-deps:stretch-curl'
  7. # Create an instance of the container-under-test
  8. cid="$(docker run -d "$serverImage")"
  9. trap "docker rm -vf $cid > /dev/null" EXIT
  10. _request() {
  11. local method="$1"
  12. shift
  13. local url="${1}"
  14. shift
  15. docker run --rm --link "$cid":ghost "$clientImage" \
  16. curl -fs -X"$method" "$@" "http://ghost:2368/$url"
  17. }
  18. # Make sure that Ghost is listening and ready
  19. . "$dir/../../retry.sh" '_request GET / --output /dev/null'
  20. # Check that /ghost/ redirects to setup (the image is unconfigured by default)
  21. ghostVersion="$(docker inspect --format '{{range .Config.Env}}{{ . }}{{"\n"}}{{end}}' "$serverImage" | awk -F= '$1 == "GHOST_VERSION" { print $2 }')"
  22. case "$ghostVersion" in
  23. 0.*) _request GET '/ghost/' -I |tac|tac| grep -q '^Location: .*setup' ;;
  24. *) _request GET '/ghost/api/v0.1/authentication/setup/' |tac|tac| grep -q 'status":false' ;;
  25. esac