Skip to content

Commit

Permalink
Use buildx multi-stage cache (#33)
Browse files Browse the repository at this point in the history
* Use buildx cache

* Update Makefile

* Use GITHUB_TOKEN
  • Loading branch information
int128 authored Mar 26, 2021
1 parent aae85d3 commit 0169445
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@ jobs:
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- uses: actions/cache@v2
with:
path: /tmp/buildx
key: buildx-${{ runner.os }}-${{ github.sha }}
restore-keys: |
buildx-${{ runner.os }}-
- uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: make docker-build
if: github.event_name == 'pull_request'
- run: make docker-build-push
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,19 @@ DOCKER_REPOSITORY := ghcr.io/int128/slack-docker
.PHONY: docker-build
docker-build: Dockerfile
docker buildx build . \
--cache-from=type=registry,ref=$(DOCKER_REPOSITORY):latest \
--output=type=image,push=false \
--cache-from=type=local,src=/tmp/buildx \
--cache-to=type=local,mode=max,dest=/tmp/buildx.new \
--platform=linux/amd64,linux/arm64
rm -fr /tmp/buildx
mv /tmp/buildx.new /tmp/buildx

.PHONY: docker-build-push
docker-build-push: Dockerfile
docker buildx build . \
--build-arg=VERSION=$(VERSION) \
--tag=$(DOCKER_REPOSITORY):$(VERSION) \
--cache-from=type=registry,ref=$(DOCKER_REPOSITORY):latest \
--cache-to=type=inline \
--cache-from=type=local,src=/tmp/buildx \
--platform=linux/amd64,linux/arm64 \
--push

Expand Down

0 comments on commit 0169445

Please sign in to comment.