Skip to content

Commit

Permalink
Workaround to cache docker layers in CI when using docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoximenes committed Oct 1, 2024
1 parent 3552cb8 commit 8916287
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testnode.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Start the test node and get PID, to terminate it once send-l2 is done.
cd ${GITHUB_WORKSPACE}

./test-node.bash "$@"
./test-node.bash "$@" --ci

if [ $? -ne 0 ]; then
echo "test-node.bash failed"
Expand Down
37 changes: 37 additions & 0 deletions docker-compose-ci-cache.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"target": {
"scripts": {
"cache-from": [
"type=local,src=/tmp/.buildx-cache"
],
"cache-to": [
"type=local,dest=/tmp/.buildx-cache,mode=max"
],
"output": [
"type=docker"
]
},
"rollupcreator": {
"cache-from": [
"type=local,src=/tmp/.buildx-cache"
],
"cache-to": [
"type=local,dest=/tmp/.buildx-cache,mode=max"
],
"output": [
"type=docker"
]
},
"tokenbridge": {
"cache-from": [
"type=local,src=/tmp/.buildx-cache"
],
"cache-to": [
"type=local,dest=/tmp/.buildx-cache,mode=max"
],
"output": [
"type=docker"
]
}
}
}
17 changes: 14 additions & 3 deletions test-node.bash
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ else
fi

run=true
ci=false
validate=false
detach=false
blockscout=false
Expand Down Expand Up @@ -107,6 +108,10 @@ while [[ $# -gt 0 ]]; do
done
fi
;;
--ci)
ci=true
shift
;;
--build)
build_dev_nitro=true
build_dev_blockscout=true
Expand Down Expand Up @@ -342,11 +347,17 @@ if $build_utils; then
if $tokenbridge || $l3_token_bridge; then
LOCAL_BUILD_NODES="$LOCAL_BUILD_NODES tokenbridge"
fi
UTILS_NOCACHE=""
if $force_build_utils; then

if [ "$ci" == true ]; then
# workaround to cache docker layers and keep using docker-compose in CI
docker buildx bake --file docker-compose.yaml --file docker-compose-ci-cache.json $LOCAL_BUILD_NODES
else
UTILS_NOCACHE=""
if $force_build_utils; then
UTILS_NOCACHE="--no-cache"
fi
docker compose build --no-rm $UTILS_NOCACHE $LOCAL_BUILD_NODES
fi
docker compose build --no-rm $UTILS_NOCACHE $LOCAL_BUILD_NODES
fi

if $dev_nitro; then
Expand Down

0 comments on commit 8916287

Please sign in to comment.