run.sh 1013 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/bash
  2. set -eo pipefail
  3. dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
  4. image="$1"
  5. # Use a client image with curl for testing
  6. clientImage='buildpack-deps:buster-curl'
  7. # ensure the clientImage is ready and available
  8. if ! docker image inspect "$clientImage" &> /dev/null; then
  9. docker pull "$clientImage" > /dev/null
  10. fi
  11. serverImage="$("$dir/../image-name.sh" librarytest/tomcat-hello-world "$image")"
  12. "$dir/../docker-build.sh" "$dir" "$serverImage" <<EOD
  13. FROM $image
  14. COPY dir/index.jsp \$CATALINA_HOME/webapps/ROOT/
  15. EOD
  16. # Create an instance of the container-under-test
  17. cid="$(docker run -d "$serverImage")"
  18. trap "docker rm -vf $cid > /dev/null" EXIT
  19. _request() {
  20. local url="${1#/}"
  21. shift
  22. docker run --rm \
  23. --link "$cid":tomcat \
  24. "$clientImage" \
  25. curl -fsSL "$@" "http://tomcat:8080/$url"
  26. }
  27. # Make sure that Tomcat is listening
  28. . "$dir/../../retry.sh" '_request / &> /dev/null'
  29. # Check that our simple servlet works
  30. helloWorld="$(_request '/')"
  31. [[ "$helloWorld" == *'Hello Docker World!'* ]]