diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 948b6b513..48c591daf 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -95,11 +95,27 @@ jobs: uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - - name: Login to DockerHub + - name: Docker Metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: powerhome/redis-operator + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha,prefix=,suffix=,format=long + - name: Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and Release Image - run: make image-release + - name: Build + uses: docker/bake-action@v3 + with: + files: | + ./docker-bake.hcl + ${{ steps.meta.outputs.bake-file }} + targets: build + push: true diff --git a/Makefile b/Makefile index 0e1e27457..d369eb173 100644 --- a/Makefile +++ b/Makefile @@ -98,36 +98,6 @@ image: deps-development -f $(APP_DIR)/Dockerfile \ . -.PHONY: image-release -image-release: - docker buildx build \ - --platform linux/amd64,linux/arm64,linux/arm/v7 \ - --push \ - --build-arg VERSION=$(TAG) \ - -t $(REPOSITORY):latest \ - -t $(REPOSITORY):$(COMMIT) \ - -t $(REPOSITORY):$(TAG) \ - -f $(APP_DIR)/Dockerfile \ - . - -.PHONY: testing -testing: image - docker push $(REPOSITORY):$(BRANCH) - -.PHONY: tag -tag: - git tag $(VERSION) - -.PHONY: publish -publish: - @COMMIT_VERSION="$$(git rev-list -n 1 $(VERSION))"; \ - docker tag $(REPOSITORY):"$$COMMIT_VERSION" $(REPOSITORY):$(VERSION) - docker push $(REPOSITORY):$(VERSION) - docker push $(REPOSITORY):latest - -.PHONY: release -release: tag image-release - # Test stuff in dev .PHONY: unit-test unit-test: docker-build diff --git a/docker-bake.hcl b/docker-bake.hcl new file mode 100644 index 000000000..2fff7711b --- /dev/null +++ b/docker-bake.hcl @@ -0,0 +1,28 @@ +// Special target: https://github.com/docker/metadata-action#bake-definition +target "docker-metadata-action" {} + +// Default target if none specified +group "default" { + targets = ["build-local"] +} + +target "build-operator" { + inherits = ["docker-metadata-action"] + dockerfile = "docker/app/Dockerfile" +} + +target "build-local" { + inherits = ["build-operator"] + output = ["type=docker"] +} + +target "build" { + inherits = ["build-operator"] + platforms = [ + "linux/amd64", + "linux/arm/v6", + "linux/arm/v7", + "linux/arm64", + "linux/386" + ] +}