forked from openclarity/openclarity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.runtime_k8s_scanner
43 lines (33 loc) · 1.35 KB
/
Dockerfile.runtime_k8s_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
# syntax=docker/dockerfile:1.2
FROM golang:1.21.6-alpine AS builder
RUN apk add --update --no-cache gcc g++ git ca-certificates build-base
# Copy runtime scan api code
WORKDIR /build/runtime_scan/api
COPY runtime_scan/api .
# Copy sbom db api code
WORKDIR /build/sbom_db
COPY sbom_db/api ./api
# Copy shared code
WORKDIR /build/shared
COPY shared .
# Copy scanner code
WORKDIR /build/runtime_k8s_scanner
COPY runtime_k8s_scanner .
# Build 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 \
go build -ldflags="-s -w \
-X 'github.com/openclarity/kubeclarity/runtime_k8s_scanner/pkg/version.Version=${VERSION}' \
-X 'github.com/openclarity/kubeclarity/runtime_k8s_scanner/pkg/version.CommitHash=${COMMIT_HASH}' \
-X 'github.com/openclarity/kubeclarity/runtime_k8s_scanner/pkg/version.BuildTimestamp=${BUILD_TIMESTAMP}'" \
-o runtime_k8s_scanner ./cmd/main.go
FROM alpine:3.19
WORKDIR /app
COPY --from=builder ["/build/runtime_k8s_scanner/runtime_k8s_scanner", "./runtime_k8s_scanner"]
ENTRYPOINT ["/app/runtime_k8s_scanner"]