-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDockerfile
31 lines (21 loc) · 836 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
FROM golang:1-alpine as builder
RUN apk update
# Add required certificates to be able to call HTTPS endpoints.
RUN apk add --no-cache ca-certificates git tzdata
WORKDIR /app
COPY go.* ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
COPY . .
# CGO_ENABLED=0 == Don't depend on libc (bigger but more independent binary)
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
env GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o main
FROM scratch
WORKDIR /app
# Import the Certificate-Authority certificates for enabling HTTPS.
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /usr/share/zoneinfo/Europe/Oslo /usr/share/zoneinfo/Europe/Oslo
COPY --from=builder /app/main .
COPY --from=builder /app/index.html .
CMD ["./main"]