mirror of
https://github.com/wahyd4/passkey-auth.git
synced 2026-08-08 20:15:44 +10:00
fix: Speed up docker build
This commit is contained in:
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user