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
19
20# Test
21FROM build-stage AS run-test-stage
22RUN go test -v ./...
23
24FROM scratch AS build-release-stage
25
26COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
27COPY --from=builder /dist /app
28
29WORKDIR /app
30
31ENTRYPOINT ["/app/app"]