Skip to content

Commit

Permalink
Don't break docker build when /lib/modules etc are not found
Browse files Browse the repository at this point in the history
because "[ -z ... ]` returns "1" and fails the build

Signed-off-by: Dimitris Karakasilis <[email protected]>
  • Loading branch information
jimmykarily committed Oct 11, 2024
1 parent 0ff22fe commit 1c17cd6
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions images/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
# for UKI, install the linux-modules pkg if no modules are found
RUN [ -z "$(ls -A /lib/modules/)" ] && apt-get update && apt-get install -y --no-install-recommends \
"$(apt-cache search linux-modules | grep -oP 'linux-modules-\d+.\d+.\d+-\d+-generic' | sort -V | tail -1)" \
&& apt-get remove -y unattended-upgrades && apt-get clean && rm -rf /var/lib/apt/lists/*
&& apt-get remove -y unattended-upgrades && apt-get clean && rm -rf /var/lib/apt/lists/* || true
# for UKI, install the linux-image pkg if no kernel is found
RUN [ -z "$(ls -A /boot/vmlinuz*)" ] && apt-get update && apt-get install -y --no-install-recommends \
"$(apt-cache search linux-image | grep -oP 'linux-image-\d+.\d+.\d+-\d+-generic' | sort -V | tail -1)" \
&& apt-get remove -y unattended-upgrades && apt-get clean && rm -rf /var/lib/apt/lists/*
&& apt-get remove -y unattended-upgrades && apt-get clean && rm -rf /var/lib/apt/lists/* || true

# This target is aimed at non-UKI images where size is not a concern
FROM common AS grub
Expand All @@ -141,18 +141,14 @@ RUN apt-get update \
&& apt-get remove -y unattended-upgrades && apt-get clean && rm -rf /var/lib/apt/lists/*

FROM systemd-boot AS systemd-boot-amd64
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
shared-mime-info \
&& apt-get remove -y unattended-upgrades && apt-get clean && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y --no-install-recommends shared-mime-info || true
RUN apt-get remove -y unattended-upgrades && apt-get clean && rm -rf /var/lib/apt/lists/* || true
RUN [ -z "$(ls -A /lib/firmware/amd/)" ] && apt-get update && apt-get install -y --no-install-recommends \
&& apt-get install -y --no-install-recommends \
amd64-microcode \
&& apt-get remove -y unattended-upgrades && apt-get clean && rm -rf /var/lib/apt/lists/*
&& apt-get install -y --no-install-recommends amd64-microcode || true
RUN apt-get remove -y unattended-upgrades && apt-get clean && rm -rf /var/lib/apt/lists/* || true
RUN [ -z "$(ls -A /lib/firmware/intel-ucode/)" ] && apt-get update && apt-get install -y --no-install-recommends \
&& apt-get install -y --no-install-recommends \
intel-microcode \
&& apt-get remove -y unattended-upgrades && apt-get clean && rm -rf /var/lib/apt/lists/*
&& apt-get install -y --no-install-recommends intel-microcode || true
RUN apt-get remove -y unattended-upgrades && apt-get clean && rm -rf /var/lib/apt/lists/* || true

FROM systemd-boot AS systemd-boot-arm64

Expand Down

0 comments on commit 1c17cd6

Please sign in to comment.