Some checks failed
Build & Push Docker Image / build-and-push (push) Has been cancelled
36 lines
735 B
Docker
36 lines
735 B
Docker
# ------------------------------------------------------------
|
|
# 1. Build stage
|
|
# ------------------------------------------------------------
|
|
FROM golang:1.25-alpine AS builder
|
|
|
|
RUN apk add --no-cache git
|
|
|
|
WORKDIR /app
|
|
|
|
# Dependencies first (cache friendly)
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
# Copy the entire codebase
|
|
COPY . .
|
|
|
|
# Build for the architecture of the host (ARM64 runner)
|
|
RUN CGO_ENABLED=0 go build -o server .
|
|
|
|
# ------------------------------------------------------------
|
|
# 2. Final minimal runtime image
|
|
# ------------------------------------------------------------
|
|
FROM alpine:3.20
|
|
|
|
RUN adduser -D -g '' appuser
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=builder /app/server .
|
|
|
|
EXPOSE 8080
|
|
|
|
USER appuser
|
|
|
|
CMD ["./server"]
|