diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr.yml index 2aa3f96891..e1e348ccd8 100644 --- a/.github/workflows/ghcr.yml +++ b/.github/workflows/ghcr.yml @@ -30,7 +30,7 @@ jobs: - name: Log-in to ghcr.io run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - + - name: Delete huge unnecessary tools folder run: rm -rf /opt/hostedtoolcache diff --git a/containers/README.md b/containers/README.md new file mode 100644 index 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.sh index 9f5e1d7844..172137c6db 100755 --- a/containers/build.sh +++ b/containers/build.sh @@ -9,7 +9,9 @@ if [[ $3 == "--push" ]]; then fi echo -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 number if [[ $GITHUB_REF_NAME =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then @@ -18,6 +20,7 @@ if [[ -n $GITHUB_REF_NAME ]]; then tags+=($major_version $minor_version) fi sanitized=$(echo $GITHUB_REF_NAME | sed 's/[^a-zA-Z0-9.-]\+/-/g') + cache_tag+="-${sanitized}" tags+=($sanitized) fi echo "Tags: ${tags[@]}" @@ -38,7 +41,7 @@ fi DOCKER_REPOSITORY=$DOCKER_REGISTRY/$DOCKER_ORG/$DOCKER_IMAGE echo "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[@]}; do args+=" -t $DOCKER_REPOSITORY:$tag" @@ -49,6 +52,9 @@ fi docker 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