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 Aug 28, 2024
1 parent 261e43d commit 658d286
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/testnode.bash
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ done
# TODO once develop is merged into nitro-contract's master, remove the NITRO_CONTRACTS_BRANCH env var
if [ "$pos" = true ]; then
echo "Running with --pos"
./test-node.bash --init-force --l3node --no-simple --detach --pos
./test-node.bash --ci --init-force --l3node --no-simple --detach --pos
else
./test-node.bash --init-force --l3node --no-simple --detach
./test-node.bash --ci --init-force --l3node --no-simple --detach
fi

if [ $? -ne 0 ]; then
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"
]
}
}
}
12 changes: 11 additions & 1 deletion 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
force_build=false
validate=false
detach=false
Expand Down Expand Up @@ -90,6 +91,10 @@ while [[ $# -gt 0 ]]; do
done
fi
;;
--ci)
ci=true
shift
;;
--build)
force_build=true
shift
Expand Down Expand Up @@ -292,7 +297,12 @@ if $force_build; then
if $tokenbridge || $l3_token_bridge; then
LOCAL_BUILD_NODES="$LOCAL_BUILD_NODES tokenbridge"
fi
docker compose build --no-rm $LOCAL_BUILD_NODES
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
docker compose build --no-rm $LOCAL_BUILD_NODES
fi
fi

if $dev_build_nitro; then
Expand Down

0 comments on commit 658d286

Please sign in to comment.