-
Notifications
You must be signed in to change notification settings - Fork 15
/
Dockerfile
35 lines (21 loc) · 866 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
32
33
34
35
# syntax=docker/dockerfile:experimental
FROM golang:1.13-alpine AS builder
ENV deps "git curl"
RUN apk update && apk upgrade
RUN apk add --no-cache $deps
ENV CGO_ENABLED 0
ENV TRIVY_VERSION 0.12.0
RUN curl -sSL https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz | tar -zx -C /tmp
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 alpine:3.9
COPY --from=builder /usr/local/bin/main /usr/local/bin/main
COPY --from=builder /tmp/trivy /usr/local/bin/trivy
RUN apk add --no-cache git
ENTRYPOINT ["/usr/local/bin/main"]
CMD ["server"]