Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve docker entrypoint #624

Merged
merged 1 commit into from
Dec 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}"