Skip to content

Commit

Permalink
Improve docker entrypoint (istio#624)
Browse files Browse the repository at this point in the history
* use service instead of daemon, which is much more test by k8s (and our
older image)
* Better cleanup
* Better logging
* Fix the wait loop - before it was always returning true, even if it
failed
  • Loading branch information
howardjohn authored and istio-testing committed Dec 11, 2019
1 parent b7b5001 commit 44353a6
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions docker/build-tools/prow-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,39 @@
set -x

# Start docker daemon and wait for dockerd to start
daemon -U -- dockerd
service docker start

echo "Waiting for dockerd to start..."
while :
do
echo "Checking for running docker daemon."
if [[ $(docker info > /dev/null 2>&1) -eq 0 ]]; then
if docker ps -q > /dev/null 2>&1; then
echo "The docker daemon is running."
break
fi
sleep 1
done

function cleanup() {
# Cleanup all docker artifacts
docker system prune -af || true
}

trap cleanup EXIT

# Authenticate gcloud, allow failures
if [[ -n "${GOOGLE_APPLICATION_CREDENTIALS:-}" ]]; then
# Jobs that need this will fail later and jobs that don't should fail because of this
gcloud auth activate-service-account --key-file="${GOOGLE_APPLICATION_CREDENTIALS}" || true
gcloud auth configure-docker -q || true
fi

set +x
"$@"
EXIT_VALUE=$?
set -x

# Cleanup all docker artifacts
docker ps -aq | xargs -r docker rm -f || true
# We cleanup in the trap as well, but just in case try to clean up here as well
docker system prune -af || true

exit "${EXIT_VALUE}"

0 comments on commit 44353a6

Please sign in to comment.