Skip to content

Commit 0d0d94e

Browse files
committed
ci: add Docker build cache
1 parent dbd4040 commit 0d0d94e

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

.github/workflows/docker.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ jobs:
5454
tags: ${{ steps.meta.outputs.tags }}
5555
labels: ${{ steps.meta.outputs.labels }}
5656
platforms: linux/amd64,linux/arm64
57+
cache-from: type=gha
58+
cache-to: type=gha,mode=max
5759

5860
- name: Generate artifact attestation
5961
uses: actions/attest-build-provenance@main

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ RUN mkdir /src
33
WORKDIR /src
44

55
COPY go.mod go.sum* ./
6-
RUN go mod download
6+
RUN --mount=type=cache,target=/go/pkg/mod \
7+
go mod download
78
COPY . /src/
8-
ENV CGO_ENABLED=0
99

10-
RUN go build -o ./bin/server
10+
ENV CGO_ENABLED=0
11+
RUN --mount=type=cache,target=/go/pkg/mod \
12+
go build -ldflags="-s -w" -trimpath -o ./bin/server
1113

1214
FROM alpine AS runtime
1315
LABEL org.opencontainers.image.source="https://github.com/database-playground/sqlrunner-v2"

0 commit comments

Comments
 (0)