From 9d3e4b4767512638270d7688fefdcba29a585fb5 Mon Sep 17 00:00:00 2001 From: ashu8912 Date: Tue, 17 Dec 2024 14:37:05 +0530 Subject: [PATCH] Dockerfile: add target platform Signed-off-by: ashu8912 --- Dockerfile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Dockerfile b/Dockerfile index c07e626a6e..3e6efd7b3c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,10 @@ FROM node:18@sha256:d0bbfdbad0bff8253e6159dcbee42141db4fc309365d5b8bcfce46ed7156 WORKDIR /headlamp-plugins # Add a build argument for the desired plugin to be built +# Add multi-arch build arguments ARG PLUGIN +ARG TARGETPLATFORM +ARG TARGETARCH # Check if the PLUGIN argument is provided RUN if [ -z "$PLUGIN" ]; then \ @@ -13,6 +16,12 @@ RUN if [ -z "$PLUGIN" ]; then \ exit 1; \ fi +# Enforce that TARGETARCH is specified +RUN if [ -z "$TARGETARCH" ]; then \ + echo "Error: TARGETARCH argument is required"; \ + exit 1; \ + fi + # Create a directory for the plugin build RUN mkdir -p /headlamp-plugins/build/${PLUGIN} @@ -41,6 +50,7 @@ COPY --from=builder /headlamp-plugins/build/ /plugins/ LABEL org.opencontainers.image.source=https://github.com/headlamp-k8s/plugins LABEL org.opencontainers.image.licenses=MIT +LABEL org.opencontainers.image.platform=$TARGETPLATFORM # Set the default command to list the installed plugins CMD ["sh", "-c", "echo Plugins installed at /plugins/:; ls /plugins/"]