Skip to content

Commit

Permalink
with cache and platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
sergicastro committed Aug 12, 2024
1 parent b082fcd commit 7d00950
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ jobs:
steps:
- uses: docker/setup-qemu-action@v3
with:
platforms: amd64,arm64
platforms: ${{ env.PLATFORMS }}
- uses: docker/setup-buildx-action@v3
id: setup-buildx
with:
platforms: ${{ env.PLATFORMS }}
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
Expand All @@ -27,4 +30,6 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- run: make docker-build-push
- env:
DOCKER_BUILDER_NAME: ${{ steps.setup-buildx.outputs.name }}
run: make docker-build-push
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot

ARG BUILDPLATFORM
ARG TARGETPLATFORM

WORKDIR /
Expand Down
10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,18 @@ build/%: PLATFORM=$(*)
build/%: GOARCH=$(notdir $(PLATFORM))
build/%: GOOS=$(subst /,,$(dir $(PLATFORM)))
build/%: ## Build manager binary for a specific platform.
GOOS=${GOOS} GOARCH=${GOARCH} go build -o build/bin/$(PLATFORM)/manager main.go
CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build -o build/bin/$(PLATFORM)/manager main.go

.PHONY: run
run: install ## Run a controller from your host.
go run ./main.go

DOCKER_BUILDER_NAME=kubegres
DOCKER_BUILDER_NAME?=kubegres
.PHONY: run
docker-buildx:
docker buildx inspect $(DOCKER_BUILDER_NAME) || \
docker buildx create --name $(DOCKER_BUILDER_NAME) --driver docker-container --driver-opt network=host \
--buildkitd-flags '--allow-insecure-entitlement network.host' --platform linux/amd64,linux/arm64
--buildkitd-flags '--allow-insecure-entitlement network.host' --platform ${PLATFORMS}

#docker-build: test ## Build docker image with the manager.
.PHONY: docker-build-push
Expand All @@ -114,9 +114,7 @@ docker-build/%: PLATFORM=$(*)
docker-build/%: DOCKER_OS=$(subst /,,$(dir $(PLATFORM)))
docker-build/%: DOCKER_ARCH=$(notdir $(PLATFORM))
docker-build/%: docker-buildx ## Build docker image with ARCH as image tag suffix.
docker buildx build --builder $(DOCKER_BUILDER_NAME) --platform ${PLATFORM} \
--build-arg TARGETOS=$(DOCKER_OS) --build-arg TARGETARCH=$(DOCKER_ARCH) \
-t ${IMG}-${DOCKER_ARCH} --load .
docker buildx build --builder $(DOCKER_BUILDER_NAME) --platform ${PLATFORM} -t ${IMG}-${DOCKER_ARCH} --load .

.PHONY: scan-local
scan-local: IMG=local/kubegres:scan-${LOCAL_ARCH}
Expand Down

0 comments on commit 7d00950

Please sign in to comment.