forked from openclarity/vmclarity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.cli
38 lines (29 loc) · 1.21 KB
/
Dockerfile.cli
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
# syntax=docker/dockerfile:1.2
ARG VMCLARITY_TOOLS_BASE=ghcr.io/openclarity/vmclarity-tools-base:v0.2.0@sha256:0e0ed706dc297366af44d736c71aefa350b54a0214290aa81b3603462e39872b
FROM --platform=$BUILDPLATFORM golang:1.20.7-alpine AS builder
RUN apk add --update --no-cache ca-certificates git
RUN apk add build-base
# Copy vmclarity code to /build and move to that directory
COPY . /build
WORKDIR /build
ARG VERSION
ARG BUILD_TIMESTAMP
ARG COMMIT_HASH
ARG TARGETOS
ARG TARGETARCH
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 \
go build \
-ldflags="-s -w \
-X 'github.com/openclarity/vmclarity/pkg/version.Version=${VERSION}' \
-X 'github.com/openclarity/vmclarity/pkg/version.CommitHash=${COMMIT_HASH}' \
-X 'github.com/openclarity/vmclarity/pkg/version.BuildTimestamp=${BUILD_TIMESTAMP}'" \
-o bin/vmclarity-cli cmd/vmclarity-cli/main.go
FROM ${VMCLARITY_TOOLS_BASE}
RUN apk upgrade
RUN apk add util-linux
WORKDIR /app
COPY --from=builder /build/bin/vmclarity-cli ./vmclarity-cli
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
ENTRYPOINT ["/app/vmclarity-cli"]