forked from openclarity/openclarity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.cis_docker_benchmark_scanner
49 lines (37 loc) · 1.63 KB
/
Dockerfile.cis_docker_benchmark_scanner
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
43
44
45
46
47
48
49
# syntax=docker/dockerfile:1.2
FROM golang:1.21.0-alpine AS builder
RUN apk add --update --no-cache gcc g++ git ca-certificates build-base
# Copy shared code
WORKDIR /build/shared
COPY shared .
# Copy sbom db api code
WORKDIR /build/sbom_db/api
COPY sbom_db/api .
# Copy runtime_k8s_scanner code
WORKDIR /build/runtime_k8s_scanner
COPY runtime_k8s_scanner .
# Copy runtime scan api code
WORKDIR /build/runtime_scan/api
COPY runtime_scan/api .
# Copy cis docker benchmark scanner code
WORKDIR /build/cis_docker_benchmark_scanner
COPY cis_docker_benchmark_scanner .
# Build cis docker benchmark scanner code
# NOTE(sambetts) Declare ARGs where they are used to prevent Docker rerunning
# all the previous steps when they change, and use buildkit inline cache to
# keep go mod cache and compilation cache between docker runs.
ARG VERSION
ARG BUILD_TIMESTAMP
ARG COMMIT_HASH
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 go build -ldflags="-s -w \
-X 'github.com/openclarity/kubeclarity/cis_docker_benchmark_scanner/pkg/version.Version=${VERSION}' \
-X 'github.com/openclarity/kubeclarity/cis_docker_benchmark_scanner/pkg/version.CommitHash=${COMMIT_HASH}' \
-X 'github.com/openclarity/kubeclarity/cis_docker_benchmark_scanner/pkg/version.BuildTimestamp=${BUILD_TIMESTAMP}'" \
-o cis_docker_benchmark_scanner ./cmd/main.go
FROM alpine:3.18
WORKDIR /app
COPY --from=builder ["/build/cis_docker_benchmark_scanner/cis_docker_benchmark_scanner", "./cis_docker_benchmark_scanner"]
RUN chmod +x /app/cis_docker_benchmark_scanner
ENTRYPOINT ["/app/cis_docker_benchmark_scanner"]