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 *.go ./
14
15# Build
16RUN CGO_ENABLED=0 go build -trimpath -o /dist/app
17
18# Test
19FROM build-stage AS run-test-stage
20RUN go test -v ./...
21
22FROM scratch AS build-release-stage
23
24COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
25COPY --from=builder /dist /app
26
27WORKDIR /app
28
29ENTRYPOINT ["/app/app"]