diff --git a/action.yml b/action.yml index 3ef06ee..ba83cc5 100644 --- a/action.yml +++ b/action.yml @@ -7,10 +7,14 @@ outputs: new_tag: description: "The new tag which was generated" value: ${{ steps.generate-and-push-tag.outputs.new_tag }} -runs-on: ubuntu-latest runs: using: 'composite' steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver-opts: | + network=host - name: Build And Push Tag id: generate-and-push-tag run: | diff --git a/build.sh b/build.sh index 3cca3df..9f50173 100644 --- a/build.sh +++ b/build.sh @@ -27,13 +27,33 @@ else fi echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT +# Set up Docker Buildx for optimized builds +docker buildx create --use --driver docker-container --name multiarch --bootstrap 2>/dev/null || docker buildx use multiarch + docker login --username $DOCKERHUB_USERNAME --password $DOCKERHUB_PASSWORD + +echo "Building optimized Docker image with registry caching..."; +# Use registry cache for better compatibility with composite actions +CACHE_TAG="$DOCKERHUB_USERNAME/$IMAGE_NAME:buildcache" + if [ -n "$SENTRY_AUTH_TOKEN" ]; then - docker build -t $DOCKERHUB_USERNAME/$IMAGE_NAME:$NEW_TAG --build-arg SENTRY_AUTH_TOKEN="$SENTRY_AUTH_TOKEN" . + docker buildx build \ + --platform linux/amd64 \ + --cache-from type=registry,ref=$CACHE_TAG \ + --cache-to type=registry,ref=$CACHE_TAG,mode=max \ + --build-arg BUILDKIT_INLINE_CACHE=1 \ + --build-arg SENTRY_AUTH_TOKEN="$SENTRY_AUTH_TOKEN" \ + -t $DOCKERHUB_USERNAME/$IMAGE_NAME:$NEW_TAG \ + --push . else - docker build -t $DOCKERHUB_USERNAME/$IMAGE_NAME:$NEW_TAG . + docker buildx build \ + --platform linux/amd64 \ + --cache-from type=registry,ref=$CACHE_TAG \ + --cache-to type=registry,ref=$CACHE_TAG,mode=max \ + --build-arg BUILDKIT_INLINE_CACHE=1 \ + -t $DOCKERHUB_USERNAME/$IMAGE_NAME:$NEW_TAG \ + --push . fi -echo "Pushing Docker Image to Docker Hub"; -docker push $DOCKERHUB_USERNAME/$IMAGE_NAME:$NEW_TAG + echo "NEW_TAG=v$(git rev-parse --short HEAD)" >> $GITHUB_ENV echo "New tag: $NEW_TAG";