-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Working support for earthy-in-earthly (eine). * Add test for parallel loads. Fix race condition in dind creation in parallel. * Performance improvement: reuse solves if they are for the same targets or docker tags. * Move the dockerd wrapper into an .sh file. * Fix dockerd start lock being held for too long. Co-authored-by: Vlad A. Ionescu <vladaionescu@users.noreply.github.com>
- Loading branch information
1 parent
cb80375
commit 489ac3c
Showing
10 changed files
with
204 additions
and
89 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
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
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,69 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
if [ -z "$EARTHLY_DOCKERD_DATA_ROOT" ]; then | ||
echo "EARTHLY_DOCKERD_DATA_ROOT not set" | ||
exit 1 | ||
fi | ||
|
||
function start_dockerd() { | ||
mkdir -p "$EARTHLY_DOCKERD_DATA_ROOT" | ||
dockerd --data-root="$EARTHLY_DOCKERD_DATA_ROOT" &>/var/log/docker.log & | ||
let i=1 | ||
timeout=30 | ||
while ! docker ps &>/dev/null; do | ||
sleep 1 | ||
if [ "$i" -gt "$timeout" ]; then | ||
# Print dockerd logs on start failure. | ||
cat /var/log/docker.log | ||
exit 1 | ||
fi | ||
let i+=1 | ||
done | ||
} | ||
|
||
function stop_dockerd() { | ||
dockerd_pid="$(cat /var/run/docker.pid)" | ||
timeout=10 | ||
if [ -n "$dockerd_pid" ]; then | ||
kill "$dockerd_pid" &>/dev/null | ||
let i=1 | ||
while kill -0 "$dockerd_pid" &>/dev/null; do | ||
sleep 1 | ||
if [ "$i" -gt "$timeout" ]; then | ||
kill -9 "$dockerd_pid" &>/dev/null || true | ||
fi | ||
let i+=1 | ||
done | ||
fi | ||
# Wipe dockerd data when done. | ||
rm -rf "$EARTHLY_DOCKERD_DATA_ROOT" | ||
} | ||
|
||
function load_images() { | ||
if [ -n "$EARTHLY_DOCKER_LOAD_IMAGES" ]; then | ||
echo "Loading images..." | ||
for img in $EARTHLY_DOCKER_LOAD_IMAGES; do | ||
docker load -i "$img" || (stop_dockerd; exit 1) | ||
done | ||
echo "...done" | ||
fi | ||
} | ||
|
||
export EARTHLY_WITH_DOCKER=1 | ||
|
||
# Lock the creation of the docker daemon - only one daemon can be started at a time | ||
# (dockerd race conditions in handling networking setup). | ||
( | ||
flock -x 200 | ||
start_dockerd | ||
flock -u 200 | ||
) 200>/var/earthly/dind/lock | ||
load_images | ||
set +e | ||
"$@" | ||
exit_code="$?" | ||
set -e | ||
stop_dockerd | ||
exit "$exit_code" |
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
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
Oops, something went wrong.