-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix docker not available when Jenkins calls it too early (#275)
- Loading branch information
Showing
7 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
touch /tmp/container_initialized | ||
|
||
exec -- "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
devcontainer/rootfs/etc/s6-overlay/s6-rc.d/dind/check_readiness.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/bin/bash | ||
|
||
export SKIP_CONTAINER_INITIALIZATION_CHECK="true" | ||
exec docker version &>/dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
# | ||
# Works around situations where the docker cli is called before the container | ||
# is fully initialized. For example, Jenkins does not wait for the entrypoint | ||
# script to finish before proceding with the build. | ||
|
||
set -euo pipefail | ||
|
||
function log_color() { | ||
color_code="$1" | ||
shift | ||
|
||
printf "\033[${color_code}m%s\033[0m\n" "$*" >&2 | ||
} | ||
|
||
function log_red() { | ||
log_color "0;31" "$@" | ||
} | ||
|
||
function log_blue() { | ||
log_color "0;34" "$@" | ||
} | ||
|
||
function log_task() { | ||
log_blue "🔃" "$@" | ||
} | ||
|
||
function log_error() { | ||
log_red "❌" "$@" | ||
} | ||
|
||
function error() { | ||
log_error "$@" | ||
exit 1 | ||
} | ||
|
||
if [[ "${SKIP_CONTAINER_INITIALIZATION_CHECK:-"false"}" == "false" ]]; then | ||
# Wait for 10s until the /tmp/container_initialized file is created | ||
for attempt in {1..10}; do | ||
if [[ -f /tmp/container_initialized ]]; then | ||
break | ||
elif [[ "${attempt}" -eq 5 ]]; then | ||
log_task "Waiting more 5s for the /tmp/container_initialized file to be created" | ||
elif [[ "${attempt}" -eq 10 ]]; then | ||
error "The /tmp/container_initialized file was not created after 10s" | ||
fi | ||
sleep 1 | ||
done | ||
fi | ||
|
||
exec -- docker.orig "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters