-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
28 lines (17 loc) · 617 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
# syntax=docker/dockerfile:experimental
FROM golang:1.14-alpine AS builder
ENV deps "git"
RUN apk update && apk upgrade
RUN apk add --no-cache $deps
ENV CGO_ENABLED 0
WORKDIR /build/
COPY go.mod go.sum /build/
RUN --mount=type=cache,target=/root/go/pkg/mod go mod download
RUN apk del --purge $deps
COPY cmd /build/cmd
COPY pkg /build/pkg
RUN --mount=type=cache,target=/root/.cache/go-build go build -trimpath -o /usr/local/bin/main -ldflags="-s -w" /build/cmd/main.go
FROM gcr.io/distroless/base
COPY --from=builder /usr/local/bin/main /usr/local/bin/main
ENTRYPOINT ["/usr/local/bin/main"]
CMD ["server"]