Skip to content

Commit

Permalink
Use github actions cache for docker workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Sylvain Rabot <[email protected]>
  • Loading branch information
sylr committed Jul 6, 2024
1 parent 998765d commit 4e7055e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
image=moby/buildkit:master
network=host
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
Expand Down
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,16 @@ DOCKER_BUILD_LABELS += --label org.opencontainers.image.version=$(GIT_VERSIO
DOCKER_BUILD_LABELS += --label org.opencontainers.image.created=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
DOCKER_BUILD_BUILD_ARGS ?= --build-arg=GO_VERSION=$(DOCKER_BUILD_GO_VERSION)
DOCKER_BUILDX_PLATFORMS ?= linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
DOCKER_BUILDX_CACHE ?= /tmp/.buildx-cache

ifeq ($(CI),true)
DOCKER_BUILD_BUILD_ARGS += --cache-to=type=gha,mode=max
DOCKER_BUILD_BUILD_ARGS += --cache-from=type=gha
DOCKER_BUILD_BUILD_ARGS += --progress=plain
else
DOCKER_BUILDX_CACHE_DIR ?= /tmp/.buildx-cache
DOCKER_BUILD_BUILD_ARGS += --cache-to=type=local,dest=$(DOCKER_BUILDX_CACHE_DIR)
DOCKER_BUILD_BUILD_ARGS += --cache-from=type=local,src=$(DOCKER_BUILDX_CACHE_DIR)
endif

# ------------------------------------------------------------------------------

Expand Down Expand Up @@ -235,15 +244,13 @@ $(GO_TOOLS_GOLANGCI_LINT):
docker-buildx-build:
@docker buildx build . -f Dockerfile \
-t $(DOCKER_BUILD_IMAGE):$(DOCKER_BUILD_VERSION) \
--cache-to=type=local,dest=$(DOCKER_BUILDX_CACHE) \
--platform=$(DOCKER_BUILDX_PLATFORMS) \
$(DOCKER_BUILD_BUILD_ARGS) \
$(DOCKER_BUILD_LABELS)

docker-buildx-push:
@docker buildx build . -f Dockerfile \
-t $(DOCKER_BUILD_IMAGE):$(DOCKER_BUILD_VERSION) \
--cache-from=type=local,src=$(DOCKER_BUILDX_CACHE) \
--platform=$(DOCKER_BUILDX_PLATFORMS) \
$(DOCKER_BUILD_BUILD_ARGS) \
$(DOCKER_BUILD_LABELS) \
Expand Down

0 comments on commit 4e7055e

Please sign in to comment.