From 0f1699c763e35e51ef717c0fe63d666d4303e5c2 Mon Sep 17 00:00:00 2001 From: mrrishi Date: Tue, 3 Dec 2024 13:25:50 +0530 Subject: [PATCH] fix controlplane dockerfile and deployment --- build/Containerfile.controlplane | 23 ++++++++++++++++++----- config/manager/manager.yaml | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/build/Containerfile.controlplane b/build/Containerfile.controlplane index 68d88dcf..6b0a6124 100644 --- a/build/Containerfile.controlplane +++ b/build/Containerfile.controlplane @@ -1,16 +1,29 @@ FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx-tools -FROM --platform=$BUILDPLATFORM rust:alpine -ARG TARGETPLATFORM -ARG PROJECT_DIR=/workspace -ARG BUILD_DIR=$PROJECT_DIR/build +FROM --platform=$BUILDPLATFORM rust:alpine AS builder RUN apk add --no-cache clang lld -COPY --from=xx-tools / / WORKDIR /workspace + +COPY --from=xx-tools / / + +ARG TARGETPLATFORM +ARG PROJECT_DIR=/workspace +ARG BUILD_DIR=$PROJECT_DIR/build + RUN --mount=type=bind,source=../controlplane/src/,target=src \ --mount=type=bind,source=../controlplane/Cargo.toml,target=Cargo.toml \ --mount=type=bind,source=../controlplane/Cargo.lock,target=Cargo.lock \ xx-cargo build --release --target-dir $BUILD_DIR && \ xx-verify ./build/$(xx-cargo --print-target-triple)/release/controller + +RUN cp ./build/$(xx-cargo --print-target-triple)/release/controller /workspace/manager + +FROM alpine:latest + +WORKDIR / + +COPY --from=builder /workspace/manager /manager + +RUN chmod +x /manager diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index b4ce8028..25227b10 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -43,6 +43,7 @@ spec: name: manager securityContext: allowPrivilegeEscalation: false + runAsUser: 1000 capabilities: drop: - "ALL"