Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
Use BuildX's cache mount for caching.
Browse files Browse the repository at this point in the history
  • Loading branch information
FireMasterK committed Mar 4, 2022
1 parent 779777b commit e44f1e5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
13 changes: 2 additions & 11 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ jobs:
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get hash of latest image
run: docker pull golang:alpine && docker inspect --format='{{index .RepoDigests 0}}' golang:alpine > dockerhash.txt
- name: cache docker cache
uses: actions/[email protected]
with:
path: ${{ github.workspace }}/cache
key: ${{ runner.os }}-docker-${{ hashFiles('**/go.mod') }}-${{ hashFiles('**/go.sum') }}-${{ hashFiles('**/dockerhash.txt') }}
restore-keys: |
${{ runner.os }}-docker-
- name: Build and push
uses: docker/build-push-action@v2
with:
Expand All @@ -43,5 +34,5 @@ jobs:
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8
push: true
tags: 1337kavin/ytproxy:latest
cache-from: type=local,src=cache
cache-to: type=local,dest=cache
cache-from: type=gha
cache-to: type=gha,mode=max
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ WORKDIR /app/

COPY . .

RUN go build -ldflags "-s -w" main.go
RUN --mount=type=cache,target=/root/.cache/go-build \
go build -ldflags "-s -w" main.go

FROM alpine:edge

Expand Down

0 comments on commit e44f1e5

Please sign in to comment.