Skip to content

Commit

Permalink
Fix docker build warnings when using buildx
Browse files Browse the repository at this point in the history
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 <fredrik.lonnegren@suse.com>
  • Loading branch information
frelon committed Sep 16, 2024
1 parent b1a7dbc commit 8b78ec4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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/
Expand Down
12 changes: 6 additions & 6 deletions examples/blue/Dockerfile
Original file line number Diff line number Diff line change
@@ -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}
Expand Down Expand Up @@ -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
Expand All @@ -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"]
12 changes: 6 additions & 6 deletions examples/green/Dockerfile
Original file line number Diff line number Diff line change
@@ -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}
Expand Down Expand Up @@ -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 && \
Expand All @@ -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"]
15 changes: 6 additions & 9 deletions examples/orange/Dockerfile
Original file line number Diff line number Diff line change
@@ -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}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"]

0 comments on commit 8b78ec4

Please sign in to comment.