Skip to content

Commit eee914e

Browse files
mnencialeonardoce
authored andcommitted
fix: rebase changes
Signed-off-by: Marco Nenciarini <[email protected]>
1 parent 3ccd3fe commit eee914e

File tree

3 files changed

+32
-17
lines changed

3 files changed

+32
-17
lines changed

containers/Dockerfile.plugin

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.23 AS builder
2+
FROM --platform=$BUILDPLATFORM golang:1.23.1 AS gobuilder
33
ARG TARGETOS
44
ARG TARGETARCH
55

@@ -42,7 +42,7 @@ LABEL summary="$SUMMARY" \
4242
release="1"
4343

4444
WORKDIR /
45-
COPY --from=builder /workspace/manager .
45+
COPY --from=gobuilder /workspace/manager .
4646
USER 65532:65532
4747

4848
ENTRYPOINT ["/manager"]

containers/Dockerfile.sidecar

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,32 @@
44
# * instance plugin
55
# Both components are built before going into a distroless container
66

7+
# Build the manager binary
8+
FROM --platform=$BUILDPLATFORM golang:1.23.1 AS gobuilder
9+
ARG TARGETOS
10+
ARG TARGETARCH
11+
12+
WORKDIR /workspace
13+
# Copy the Go Modules manifests
14+
COPY ../go.mod go.mod
15+
COPY ../go.sum go.sum
16+
# cache deps before building and copying source so that we don't need to re-download as much
17+
# and so that source changes don't invalidate our downloaded layer
18+
RUN go mod download
19+
20+
# Copy the go source
21+
COPY ../cmd/manager/main.go cmd/manager/main.go
22+
COPY ../api/ api/
23+
COPY ../internal/ internal/
24+
25+
# Build
26+
# the GOARCH has not a default value to allow the binary be built according to the host where the command
27+
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
28+
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
29+
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
30+
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build \
31+
CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/manager/main.go
32+
733
# Build barman-cloud
834
# pip will build everything inside /usr/ since this is the case
935
# we should build and then copy every file into a destination that will
@@ -19,17 +45,6 @@ RUN mkdir /new-usr/ && \
1945
cp -r --parents /usr/local/lib/ /usr/lib/*-linux-gnu/ /usr/local/bin/ \
2046
/new-usr/
2147

22-
# Build instance
23-
# This step builds a simple instance app that will manage and handle
24-
# the barman-cloud commands inside the sidecar
25-
FROM --platform=$BUILDPLATFORM golang:1.23.1 AS gobuilder
26-
ENV CGO_ENABLED=0
27-
COPY .. /src
28-
ARG TARGETOS
29-
ARG TARGETARCH
30-
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build \
31-
GOOS=$TARGETOS GOARCH=$TARGETARCH go build -C /src -o /build/instance /src/cmd/instance/main.go
32-
3348
# Joint process
3449
# Now we put everything that was build from the origin into our
3550
# distroless container
@@ -49,6 +64,6 @@ LABEL summary="$SUMMARY" \
4964
release="1"
5065

5166
COPY --from=pythonbuilder /new-usr/* /usr/
52-
COPY --from=gobuilder /build/instance /usr/local/bin/instance
67+
COPY --from=gobuilder /workspace/manager /manager
5368
USER 26:26
54-
ENTRYPOINT ["/usr/local/bin/instance"]
69+
ENTRYPOINT ["/manager"]

internal/cnpgi/operator/lifecycle.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ func reconcilePodSpec(
231231
sidecarConfig.Name = "plugin-barman-cloud"
232232
sidecarConfig.Image = viper.GetString("sidecar-image")
233233
sidecarConfig.ImagePullPolicy = cluster.Spec.ImagePullPolicy
234-
sidecarConfig.Command= []string{
235-
"/usr/local/bin/instance",
234+
sidecarConfig.Command = []string{
235+
"/manager",
236236
}
237237

238238
// merge the main container envs if they aren't already set

0 commit comments

Comments
 (0)