Skip to content

Commit

Permalink
ci: Cache layers in Docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
ivov committed Jan 19, 2025
1 parent 0992b2e commit 603eead
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:
with:
context: .
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/arm64
# Disable provenance to prevent multi-platform index with unused layers like `unknown/unknown`
# https://github.com/docker/buildx/issues/1509#issuecomment-1378538197
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

FROM golang:1.23-alpine AS builder
WORKDIR /builder-dir
COPY go.mod go.sum ./
RUN go mod download
COPY . ./
ENV CGO_ENABLED=1
RUN apk add --no-cache git build-base sqlite
RUN go mod download
RUN BUILD_TIME=$(date +"%Y-%m-%dT%H:%M:%S%z") && \
GIT_COMMIT=$(git describe --always --dirty) && \
GIT_COMMIT=$(git rev-parse --short HEAD) && \
go build -ldflags="-s -X main.commitSha=$GIT_COMMIT -X main.buildTime=$BUILD_TIME" -o bin cmd/server/main.go

FROM alpine:latest
Expand All @@ -17,4 +19,3 @@ COPY --from=builder /builder-dir/bin bin
COPY --from=builder /builder-dir/internal/db/migrations internal/db/migrations
EXPOSE 3001
CMD ["./bin/main"]

0 comments on commit 603eead

Please sign in to comment.