Skip to content

Instantly share code, notes, and snippets.

@andy51002000
Created June 3, 2020 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andy51002000/3e807221ea54540ccc0f6d9b12313298 to your computer and use it in GitHub Desktop.
Save andy51002000/3e807221ea54540ccc0f6d9b12313298 to your computer and use it in GitHub Desktop.
check health of service in docker
- name: 'gcr.io/cloud-builders/docker'
id: build
entrypoint: bash
args:
- "-c"
- |
docker run --net=cloudbuild -p 8080:8080 --name srv -d gcr.io/${_PROJECT_NAME}/myapp:${SHORT_SHA}
API_STATUS=$(curl --fail -i --retry 3 --retry-delay 2 --retry-connrefused 'http://srv:8080/api/status' | grep HTTP | cut -d' ' -f2)
echo "API Status: $$API_STATUS"
if [ "200" != "$$API_STATUS" ]; then
echo "Error [API status: $$API_STATUS]"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment