Skip to content

Commit

Permalink
Fix image tags
Browse files Browse the repository at this point in the history
The git HEAD SHA should be the tag of the image.
  • Loading branch information
indiebrain committed Dec 20, 2023
1 parent f8902ea commit 702d9ca
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 34 deletions.
24 changes: 20 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 0 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -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"
]
}

0 comments on commit 702d9ca

Please sign in to comment.