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