You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FROM --platform=$TARGETPLATFORM gcc:latest as utils-builder
2
-
3
-
RUN apt-get update && apt-get install -y flex libkeyutils-dev
1
+
# === Stage 1: Build DRBD utilities ===
2
+
FROM --platform=$TARGETPLATFORM gcc:13 as utils-builder
3
+
4
+
# Install only necessary tools in minimal environment
5
+
# - flex: needed for parsing in DRBD utils build
6
+
# - libkeyutils-dev: required by DRBD
7
+
# - curl, tar: to fetch and extract source
8
+
# - make: to compile tools
9
+
RUN apt-get update && apt-get install -y \
10
+
flex \
11
+
libkeyutils-dev \
12
+
curl \
13
+
tar \
14
+
make \
15
+
&& apt-get clean
4
16
5
17
ARG DRBD_UTILS_VERSION=9.27.0
6
18
RUN curl -fsSL "https://pkg.linbit.com/downloads/drbd/utils/drbd-utils-$DRBD_UTILS_VERSION.tar.gz" | tar -xzv \
@@ -9,11 +21,11 @@ RUN curl -fsSL "https://pkg.linbit.com/downloads/drbd/utils/drbd-utils-$DRBD_UTI
9
21
&& make tools \
10
22
&& mv user/v9/drbdsetup /drbdsetup
11
23
24
+
# === Stage 2: Build Go binary ===
12
25
FROM --platform=$BUILDPLATFORM golang:1 as go-builder
13
26
14
27
WORKDIR /work
15
28
COPY go.mod go.sum /work/
16
-
17
29
RUN go mod download -x
18
30
19
31
COPY main.go main.go
@@ -22,12 +34,19 @@ COPY pkg/ pkg/
22
34
ARG VERSION=devel
23
35
ARG TARGETARCH
24
36
ARG TARGETOS
25
-
RUN --mount=type=cache,target=/root/.cache/go-build CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -a -ldflags "-X github.com/piraeusdatastore/drbd-shutdown-guard/pkg/vars.Version=$VERSION" -o drbd-shutdown-guard main.go
37
+
RUN --mount=type=cache,target=/root/.cache/go-build \
38
+
CGO_ENABLED=0 \
39
+
GOOS=$TARGETOS \
40
+
GOARCH=$TARGETARCH \
41
+
go build -a -ldflags "-X github.com/piraeusdatastore/drbd-shutdown-guard/pkg/vars.Version=$VERSION" -o drbd-shutdown-guard main.go
26
42
27
-
FROM --platform=$TARGETPLATFORM registry.access.redhat.com/ubi9/ubi:latest
43
+
# === Stage 3: Final minimal runtime image ===
44
+
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
28
45
46
+
# Copy only the built binaries from previous stages
0 commit comments