-
Notifications
You must be signed in to change notification settings - Fork 22
/
Dockerfile.cr-discovery-server
51 lines (36 loc) · 1.81 KB
/
Dockerfile.cr-discovery-server
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
50
51
# syntax=docker/dockerfile:1@sha256:e87caa74dcb7d46cd820352bfea12591f3dba3ddc4285e19c7dcd13359f7cefd
# xx is a helper for cross-compilation
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.4.0@sha256:0cd3f05c72d6c9b038eb135f91376ee1169ef3a330d34e418e65e2a5c2e9c0d4 AS xx
FROM --platform=$BUILDPLATFORM golang:1.22.4-bullseye@sha256:067c5c7fe6d79f900c5ebe8351166356d6e3bbfcc6f807030e89b9a929252273 AS builder
COPY --from=xx / /
ARG TARGETPLATFORM
RUN --mount=type=cache,id=${TARGETPLATFORM}-apt,target=/var/cache/apt,sharing=locked \
apt-get update \
&& xx-apt-get install -y --no-install-recommends \
gcc \
libc6-dev
WORKDIR /build/containerruntimediscovery/server
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=bind,source=.,target=/build,ro \
xx-go mod download -x
ARG VERSION
ARG BUILD_TIMESTAMP
ARG COMMIT_HASH
ARG BUILD_OPTS
ENV CGO_ENABLED=1
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=bind,source=.,target=/build,ro \
xx-go build ${BUILD_OPTS} -ldflags="-s -w -extldflags -static \
-X 'github.com/openclarity/vmclarity/core/version.Version=${VERSION}' \
-X 'github.com/openclarity/vmclarity/core/version.CommitHash=${COMMIT_HASH}' \
-X 'github.com/openclarity/vmclarity/core/version.BuildTimestamp=${BUILD_TIMESTAMP}'" \
-o /bin/vmclarity-cr-discovery-server cmd/main.go
RUN xx-verify /bin/vmclarity-cr-discovery-server
FROM alpine:3.20@sha256:b89d9c93e9ed3597455c90a0b88a8bbb5cb7188438f70953fede212a0c4394e0
COPY --from=builder ["/bin/vmclarity-cr-discovery-server", "/bin/vmclarity-cr-discovery-server"]
RUN apk add --update --no-cache \
ca-certificates \
libc6-compat
ENTRYPOINT ["/bin/vmclarity-cr-discovery-server"]