π OpenHands: AI-Driven Development
use caching for docker builds (#1340)
Robert Brennan8828d9836d01
diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.ymlindex 2aa3f96891..e1e348ccd8 100644--- a/.github/workflows/ghcr.yml+++ b/.github/workflows/ghcr.yml@@ -30,7 +30,7 @@ jobs:- name: Log-in to ghcr.iorun: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin-+- name: Delete huge unnecessary tools folderrun: rm -rf /opt/hostedtoolcachediff --git a/containers/README.md b/containers/README.mdnew file mode 100644index 0000000000..3094259c80--- /dev/null+++ b/containers/README.md@@ -0,0 +1,13 @@+# Docker Containers+Each folder here contains a Dockerfile, and a config.sh describing how to build+the image and where to push it. These are images are built and pushed in GitHub Actions+by the `ghcr.yml` workflow.++## Building Manually++```+docker build -f containers/app/Dockerfile -t opendevin .+docker build -f containers/sandbox/Dockerfile -t sandbox .+docker build -f containers/evaluation/Dockerfile -t evaluation evaluation/SWE-bench/++```diff --git a/containers/build.sh b/containers/build.shindex 9f5e1d7844..172137c6db 100755--- a/containers/build.sh+++ b/containers/build.sh@@ -9,7 +9,9 @@ if [[ $3 == "--push" ]]; thenfiecho -e "Building: $image_name"-tags=(latest)+tags=()+cache_tag_base="buildcache"+cache_tag="$cache_tag_base"if [[ -n $GITHUB_REF_NAME ]]; then# check if ref name is a version numberif [[ $GITHUB_REF_NAME =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then@@ -18,6 +20,7 @@ if [[ -n $GITHUB_REF_NAME ]]; thentags+=($major_version $minor_version)fisanitized=$(echo $GITHUB_REF_NAME | sed 's/[^a-zA-Z0-9.-]\+/-/g')+ cache_tag+="-${sanitized}"tags+=($sanitized)fiecho "Tags: ${tags[@]}"@@ -38,7 +41,7 @@ fiDOCKER_REPOSITORY=$DOCKER_REGISTRY/$DOCKER_ORG/$DOCKER_IMAGEecho "Repo: $DOCKER_REPOSITORY"echo "Base dir: $DOCKER_BASE_DIR"-#docker pull $DOCKER_REPOSITORY:main || true # try to get any cached layers+args=""for tag in ${tags[@]}; doargs+=" -t $DOCKER_REPOSITORY:$tag"@@ -49,6 +52,9 @@ fidocker buildx build \$args \+ --cache-to=type=registry,ref=$DOCKER_REPOSITORY:$cache_tag,mode=max \+ --cache-from=type=registry,ref=$DOCKER_REPOSITORY:$cache_tag \+ --cache-from=type=registry,ref=$DOCKER_REPOSITORY:$cache_tag_base-main \--platform linux/amd64,linux/arm64 \--provenance=false \-f $dir/Dockerfile $DOCKER_BASE_DIR