Skip to content

Commit

Permalink
✨ Refactor Dockerfiles for Ubuntu based flavors (#1656)
Browse files Browse the repository at this point in the history
* POC with ubuntu dockerfiles

Signed-off-by: Mauro Morales <[email protected]>

* oops

Signed-off-by: Mauro Morales <[email protected]>

* Remove comment

Signed-off-by: Mauro Morales <[email protected]>

---------

Signed-off-by: Mauro Morales <[email protected]>
  • Loading branch information
mauromorales authored Jul 31, 2023
1 parent 81f3280 commit adbba85
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 205 deletions.
6 changes: 5 additions & 1 deletion Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,11 @@ base-image:
ARG BUILD_INITRD="true"
IF [ "$BASE_IMAGE" = "" ]
# Source the flavor-provided docker file
FROM DOCKERFILE --build-arg MODEL=$MODEL -f images/Dockerfile.$FLAVOR .
IF [[ "$FLAVOR" =~ ^ubuntu* ]] && [ "$TARGETARCH" != "arm64" ]
FROM DOCKERFILE --build-arg MODEL=$MODEL --build-arg FLAVOR=$FLAVOR -f images/Dockerfile.ubuntu .
ELSE
FROM DOCKERFILE --build-arg MODEL=$MODEL -f images/Dockerfile.$FLAVOR .
END
ELSE
FROM $BASE_IMAGE
END
Expand Down
76 changes: 60 additions & 16 deletions images/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# rolling tag points to the latest release (regardless of LTS status)
ARG BASE_IMAGE=ubuntu:rolling
ARG FLAVOR

FROM $BASE_IMAGE
# Available flavors
FROM ubuntu:rolling AS ubuntu

ENV DEBIAN_FRONTEND=noninteractive
FROM ubuntu:20.04 AS ubuntu-20-lts

FROM ubuntu:22.04 AS ubuntu-22-lts

# Common packages for all images
FROM ${FLAVOR} AS common
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
gnupg \
Expand All @@ -17,17 +22,13 @@ RUN apt-get update \
coreutils \
cryptsetup \
curl \
dbus-user-session \
debianutils \
dmsetup \
dosfstools \
dracut \
dracut-live \
dracut-network \
e2fsprogs \
efibootmgr \
firmware-sof-signed \
fuse3 \
gawk \
gdisk \
grub2 \
Expand All @@ -41,8 +42,6 @@ RUN apt-get update \
isc-dhcp-common \
jq \
kbd \
krb5-locales \
linux-image-generic-hwe-22.04 \
lvm2 \
mdadm \
nano \
Expand All @@ -57,9 +56,6 @@ RUN apt-get update \
os-prober \
packagekit-tools \
parted \
pigz \
pkg-config \
polkitd \
publicsuffix \
qemu-guest-agent \
rsync \
Expand All @@ -68,8 +64,6 @@ RUN apt-get update \
squashfs-tools \
sudo \
systemd \
systemd-hwe-hwdb \
systemd-resolved \
systemd-timesyncd \
thermald \
xdg-user-dirs \
Expand All @@ -80,6 +74,57 @@ RUN apt-get update \
zstd \
&& apt-get remove -y unattended-upgrades && apt-get clean && rm -rf /var/lib/apt/lists/*

# Packages and scripts only for specific images
FROM common AS ubuntu-specific
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
dbus-user-session \
dracut-live \
firmware-sof-signed \
fuse3 \
krb5-locales \
linux-image-generic-hwe-22.04 \
pigz \
pkg-config \
polkitd \
systemd-hwe-hwdb \
systemd-resolved \
&& apt-get remove -y unattended-upgrades && apt-get clean && rm -rf /var/lib/apt/lists/*

FROM common AS ubuntu-20-lts-specific
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
file \
fuse \
krb5-locales \
linux-image-generic-hwe-20.04 \
lldpd \
patch \
policykit-1 \
snmpd \
ubuntu-advantage-tools \
&& apt-get remove -y unattended-upgrades && apt-get clean && rm -rf /var/lib/apt/lists/*

FROM common AS ubuntu-22-lts-specific
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
dracut-live \
firmware-sof-signed \
fuse3 \
linux-image-generic-hwe-22.04 \
lldpd \
pigz \
polkitd \
snmpd \
systemd-hwe-hwdb \
ubuntu-advantage-tools \
&& apt-get remove -y unattended-upgrades && apt-get clean && rm -rf /var/lib/apt/lists/*

FROM ${FLAVOR}-specific AS all

# Generic steps for all images
FROM all

RUN ln -s /usr/sbin/grub-install /usr/sbin/grub2-install
RUN ln -s /usr/bin/grub-editenv /usr/bin/grub2-editenv
RUN systemctl enable systemd-networkd
Expand All @@ -88,6 +133,5 @@ RUN systemctl enable ssh
# Fixup sudo perms
RUN chown root:root /usr/bin/sudo && chmod 4755 /usr/bin/sudo


# Clear cache
RUN rm -rf /var/cache/* && journalctl --vacuum-size=1K && rm /etc/machine-id && rm /var/lib/dbus/machine-id && rm /etc/hostname
96 changes: 0 additions & 96 deletions images/Dockerfile.ubuntu-20-lts

This file was deleted.

92 changes: 0 additions & 92 deletions images/Dockerfile.ubuntu-22-lts

This file was deleted.

0 comments on commit adbba85

Please sign in to comment.