-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
42 lines (31 loc) · 1.16 KB
/
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
36
37
38
39
40
41
42
# syntax = docker/dockerfile:experimental
# Build the manager binary
FROM golang:1.15-alpine as builder
WORKDIR /workspace
RUN apk add --no-cache gcc libc-dev git
# Copy the Go Modules manifests
COPY go.mod go.sum /workspace/
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download
# Copy the go source
COPY main.go main.go
COPY clair clair
COPY listener listener
# Build
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o collector-clair
# Test
RUN go test -v -cover -tags unit ./...
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot as runner
WORKDIR /
COPY --from=builder /workspace/collector-clair .
USER nonroot:nonroot
ENTRYPOINT ["./collector-clair"]
EXPOSE 8080
# - docker build -t collector-clair:buildID --target=builder
# - copy coverage out
# - docker run collector-clair:buildID
# - docker cp collector-clair:buildID coverage.txt .
# - docker rm collector-clair
# - docker build -t collector-clair --target=artifact