From 6bbfdebe97c09bc72d2f9dacd4e47b6aeb36d0a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20L=C3=B6nnegren?= Date: Fri, 13 Sep 2024 13:08:33 +0200 Subject: [PATCH] Fix docker build warnings when using buildx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The following warnings are fixed in the example flavors + cli Dockerfile: ``` - StageNameCasing: Stage name 'TOOLKIT' should be lowercase (line 7) - StageNameCasing: Stage name 'OS' should be lowercase (line 10) - InvalidDefaultArgInFrom: Default value for ARG ${TOOLKIT_REPO}:${VERSION} results in empty or invalid base image name (line 7) - JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals (line 97) - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 4) ``` Signed-off-by: Fredrik Lönnegren --- Dockerfile | 2 +- examples/blue/Dockerfile | 12 ++++++------ examples/green/Dockerfile | 12 ++++++------ examples/orange/Dockerfile | 15 ++++++--------- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2a211f26c21..f6d5ee31e4c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ ARG BASE_OS_IMAGE=registry.opensuse.org/opensuse/tumbleweed ARG GO_VERSION=1.22 -FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine as elemental-bin +FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS elemental-bin ENV CGO_ENABLED=0 WORKDIR /src/ diff --git a/examples/blue/Dockerfile b/examples/blue/Dockerfile index 400a3ad9bce..b87ed30fb70 100644 --- a/examples/blue/Dockerfile +++ b/examples/blue/Dockerfile @@ -1,10 +1,10 @@ # run `make build` to build local/elemental-toolkit image -ARG TOOLKIT_REPO -ARG VERSION -FROM ${TOOLKIT_REPO}:${VERSION} as TOOLKIT +ARG TOOLKIT_REPO=local/elemental-toolkit +ARG VERSION=latest +FROM ${TOOLKIT_REPO}:${VERSION} AS toolkit # OS base image of our choice -FROM fedora:40 as OS +FROM fedora:40 AS os ARG REPO ARG VERSION ENV VERSION=${VERSION} @@ -51,7 +51,7 @@ RUN dnf install -y \ RUN mkdir -p /oem /system # Just add the elemental cli -COPY --from=TOOLKIT /usr/bin/elemental /usr/bin/elemental +COPY --from=toolkit /usr/bin/elemental /usr/bin/elemental # This is for automatic testing purposes, do not do this in production. RUN echo "PermitRootLogin yes" > /etc/ssh/sshd_config.d/rootlogin.conf @@ -70,4 +70,4 @@ RUN echo IMAGE_REPO=\"${REPO}\" >> /etc/os-release && \ echo GRUB_ENTRY_NAME=\"Elemental\" >> /etc/os-release # Good for validation after the build -CMD /bin/bash +CMD ["/bin/bash"] diff --git a/examples/green/Dockerfile b/examples/green/Dockerfile index d3b434dfe8f..a5a2c4aba6b 100644 --- a/examples/green/Dockerfile +++ b/examples/green/Dockerfile @@ -1,13 +1,13 @@ # run `make build` to build local/elemental-toolkit image -ARG TOOLKIT_REPO -ARG VERSION +ARG TOOLKIT_REPO=local/elemental-toolkit +ARG VERSION=latest ARG OS_IMAGE=registry.opensuse.org/opensuse/tumbleweed ARG OS_VERSION=latest -FROM ${TOOLKIT_REPO}:${VERSION} AS TOOLKIT +FROM ${TOOLKIT_REPO}:${VERSION} AS toolkit # OS base image of our choice -FROM ${OS_IMAGE}:${OS_VERSION} AS OS +FROM ${OS_IMAGE}:${OS_VERSION} AS os ARG REPO ARG VERSION ENV REPO=${REPO} @@ -68,7 +68,7 @@ RUN ARCH=$(uname -m); \ zypper clean --all # Just add the elemental cli -COPY --from=TOOLKIT /usr/bin/elemental /usr/bin/elemental +COPY --from=toolkit /usr/bin/elemental /usr/bin/elemental # Enable essential services RUN systemctl enable NetworkManager.service && \ @@ -94,4 +94,4 @@ RUN echo IMAGE_REPO=\"${REPO}\" >> /etc/os-release && \ echo GRUB_ENTRY_NAME=\"Elemental\" >> /etc/os-release # Good for validation after the build -CMD /bin/bash +CMD ["/bin/bash"] diff --git a/examples/orange/Dockerfile b/examples/orange/Dockerfile index 62af7d71f35..8ae2e55c259 100644 --- a/examples/orange/Dockerfile +++ b/examples/orange/Dockerfile @@ -1,10 +1,10 @@ # run `make build` to build local/elemental-toolkit image -ARG TOOLKIT_REPO -ARG VERSION -FROM ${TOOLKIT_REPO}:${VERSION} as TOOLKIT +ARG TOOLKIT_REPO=local/elemental-toolkit +ARG VERSION=latest +FROM ${TOOLKIT_REPO}:${VERSION} AS toolkit # OS base image of our choice -FROM ubuntu:24.04 as OS +FROM ubuntu:24.04 AS os ARG REPO ARG VERSION ENV VERSION=${VERSION} @@ -62,11 +62,8 @@ RUN curl -L https://mirrors.edge.kernel.org/pub/linux/utils/kbd/kbd-${KBD}.tar.x # Symlink grub2-editenv RUN ln -sf /usr/bin/grub-editenv /usr/bin/grub2-editenv -# Create non FHS paths -RUN mkdir -p /oem /system - # Just add the elemental cli -COPY --from=TOOLKIT /usr/bin/elemental /usr/bin/elemental +COPY --from=toolkit /usr/bin/elemental /usr/bin/elemental # Enable essential services RUN systemctl enable systemd-networkd.service @@ -99,4 +96,4 @@ RUN mkdir -p /usr/lib/elemental/bootloader && \ cp /usr/lib/shim/mmx64.efi /usr/lib/elemental/bootloader/mmx64.efi # Good for validation after the build -CMD /bin/bash +CMD ["/bin/bash"]