fix: Speed up docker build

This commit is contained in:
2025-08-04 21:59:17 +10:00
parent 91a35c750b
commit 827a103cee
2 changed files with 13 additions and 5 deletions
+4
View File
@@ -105,6 +105,10 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILDKIT_INLINE_CACHE=1
GOCACHE=/root/.cache/go-build
GOMODCACHE=/go/pkg/mod
lint:
runs-on: ubuntu-latest
+9 -5
View File
@@ -1,22 +1,26 @@
# Build stage
FROM golang:1.23-alpine AS builder
# Install git for Go modules (no need for gcc or sqlite-dev anymore)
# Install git for Go modules
RUN apk add --no-cache git
WORKDIR /app
# Copy go mod files
# Copy go mod files first for better layer caching
COPY go.mod go.sum ./
# Download dependencies
# Download dependencies (this will be cached if go.mod/go.sum don't change)
RUN go mod download
# Copy source code
COPY . .
# Build the application with pure Go (no CGO needed)
RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o passkey-auth .
# Build the application with optimized flags and build cache
# Remove -a flag to avoid rebuilding standard library
# Remove unnecessary static linking flags since CGO is disabled
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o passkey-auth .
# Final stage
FROM alpine:latest