Dockerfile (view raw)
1# syntax=docker/dockerfile:1
2
3FROM golang:1.23-alpine AS builder
4
5WORKDIR /build
6
7# Download Go modules
8COPY go.mod go.sum ./
9RUN go mod download
10RUN go mod verify
11
12# Transfer source code
13COPY src ./src
14COPY *.go ./
15
16# Build
17RUN CGO_ENABLED=0 go build -trimpath -o /dist/piggy
18
19
20# Test
21FROM builder AS run-test-stage
22RUN go test -v ./...
23
24FROM scratch AS build-release-stage
25
26WORKDIR /app
27
28COPY static ./static
29COPY --from=builder /dist .
30
31ENTRYPOINT ["./piggy"]