From ac013910f6433e268349b1e071be92a790252446 Mon Sep 17 00:00:00 2001 From: Stephan Linz Date: Fri, 11 Oct 2024 12:25:48 +0200 Subject: [PATCH] feat: use of finely graded multi-stages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In preparation for a differentiated CI pipeline, the Dockerfile can now be used with finer-grained multi-stages to build multi- platform Docker images. ubuntu:noble-20240904.1 | `–[base] | - Ubuntu system package upgrades | - Ubuntu APT software management utils | - Ubuntu localization for 'en_US.UTF-8' and 'de_DE.UTF-8' | - TSN workspace user in '/home/tsn' ('UID=1005' and 'GID=205') | - Set main entry point to '/bin/bash' | - Switch to TSN workspace user in '/home/tsn' | `–[asdf-all] | - Ubuntu system packages for ASDF | - Install ASDF | - Install ASDF Plugin Manager | - Switch to TSN workspace user in '/home/tsn' | +–[asdf-amd64] | | - Empty, nothing to do. ,–:–´ | | | +–[asdf-arm] | | | - Empty, nothing to do. +–:–´ | | | +–[asdf-arm64] | | | - Empty, nothing to do. +–:–´ | | | +–[asdf-riscv64] | | | - Empty, nothing to do. +–:–´ | | | +–[asdf-ppc64le] | | | - Empty, nothing to do. +–:–´ | | | `–[asdf-s390x] | | - Empty, nothing to do. +–––´ | `–[asdf]: - Verify ASDF, execute CLI. - Verify ASDF Plugin Manager, execute CLI. Signed-off-by: Stephan Linz --- Dockerfile | 158 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 100 insertions(+), 58 deletions(-) diff --git a/Dockerfile b/Dockerfile index b2c01fb..10233b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,7 +26,7 @@ FROM ubuntu:noble-20240904.1 AS base # overwrite Ubuntu default metadata LABEL mantainer="Stephan Linz " -LABEL version="2024.10.0" +LABEL version="unstable" # ############################################################################ @@ -42,30 +42,13 @@ SHELL ["/bin/sh", "-ex", "-c"] # ############################################################################ -# -# ASDF runtime version -# https://asdf-vm.com/ -# https://github.com/asdf-vm/asdf/blob/master/CHANGELOG.md -# - -# Define ASDF branch to be installed via git-clone -ENV TSN_ASDF_BRANCH=v0.14.1 - -# -# ASDF Plugin Manager runtime version -# https://github.com/asdf-community/asdf-plugin-manager -# https://github.com/asdf-community/asdf-plugin-manager/blob/main/CHANGELOG.md -# - -# Define ASDF Plugin Manager version to be installed via ASDF -ENV TSN_ASDF_PM_VERSION=1.4.0 - -# ############################################################################ - ENV DEBIAN_FRONTEND=noninteractive ENV DEBCONF_NONINTERACTIVE_SEEN=true ENV LANG=C.UTF-8 +# ############################################################################ + +# switch to superuser USER root WORKDIR / @@ -82,23 +65,23 @@ RUN apt-get --assume-yes update RUN apt-get --assume-yes dist-upgrade RUN apt-get --assume-yes install --no-install-recommends \ apt-utils \ + bash \ + bash-completion \ software-properties-common \ vim RUN apt-get --assume-yes autoremove --purge RUN apt-get clean -# Install requirements -RUN apt-get --assume-yes install --no-install-recommends \ - bash \ - bash-completion \ - bsdmainutils \ - coreutils \ - curl \ - git-core \ - grep \ - sed -RUN apt-get --assume-yes autoremove --purge -RUN apt-get clean +# ############################################################################ + +# make /bin/sh symlink to bash instead of dash: +RUN echo "dash dash/sh boolean false" | debconf-set-selections +RUN dpkg-reconfigure --frontend=readline --priority=critical dash + +# HOTFIX: The construct above has no effect, do it manually! +RUN ln -sf bash /bin/sh + +SHELL ["/bin/sh", "-exo", "pipefail", "-c"] # ############################################################################ @@ -120,25 +103,75 @@ RUN locale -a # ############################################################################ -# make /bin/sh symlink to bash instead of dash: -RUN echo "dash dash/sh boolean false" | debconf-set-selections -RUN dpkg-reconfigure --frontend=readline --priority=critical dash +# Set executable for main entry point +CMD ["/bin/bash"] -# HOTFIX: The construct above has no effect, do it manually! -RUN ln -sf bash /bin/sh +# ############################################################################ -SHELL ["/bin/sh", "-exo", "pipefail", "-c"] +# switch to workspace user +USER $WSUSER_NAME +WORKDIR $WSUSER_HOME + +# ############################################################################ +# +# All architectures maintenance for ASDF and ASDF Plugin Manager +# +# ############################################################################ + +FROM base AS asdf-all # ############################################################################ # -# Manage multiple runtime versions with the -# ASDF version manager in workspace user space. +# ASDF runtime version +# https://asdf-vm.com/ +# https://github.com/asdf-vm/asdf/blob/master/CHANGELOG.md +# + +# Define ASDF branch to be installed via git-clone +ENV TSN_ASDF_BRANCH=v0.14.1 + +# +# ASDF Plugin Manager runtime version +# https://github.com/asdf-community/asdf-plugin-manager +# https://github.com/asdf-community/asdf-plugin-manager/blob/main/CHANGELOG.md # +# Define ASDF Plugin Manager version to be installed via ASDF +ENV TSN_ASDF_PM_VERSION=1.4.0 + +# ############################################################################ + +# switch to superuser +USER root +WORKDIR / + +# ############################################################################ + +# Install requirements +RUN apt-get --assume-yes install --no-install-recommends \ + bsdmainutils \ + coreutils \ + curl \ + git-core \ + grep \ + sed +RUN apt-get --assume-yes autoremove --purge +RUN apt-get clean + +# ############################################################################ + +# switch to workspace user USER $WSUSER_NAME WORKDIR $WSUSER_HOME +# ############################################################################ + +# +# Manage multiple runtime versions with the +# ASDF version manager in workspace user space. +# + # Install ASDF RUN git clone https://github.com/asdf-vm/asdf.git ~/.asdf --depth 1 --branch $TSN_ASDF_BRANCH RUN echo ". ~/.asdf/asdf.sh" >> $WSUSER_HOME/.bashrc @@ -182,65 +215,74 @@ RUN asdf-plugin-manager export > $WSUSER_HOME/.plugin-versions # ############################################################################ # -# AMD/x86 64-bit architecture maintenance +# AMD/x86 64-bit architecture maintenance for ASDF and ASDF Plugin Manager # # ############################################################################ -FROM base AS build-amd64 +FROM asdf-all AS asdf-amd64 # ############################################################################ # -# ARMv7 32-bit architecture maintenance +# ARMv7 32-bit architecture maintenance for ASDF and ASDF Plugin Manager # # ############################################################################ -FROM base AS build-arm +FROM asdf-all AS asdf-arm # ############################################################################ # -# ARMv8 64-bit architecture maintenance +# ARMv8 64-bit architecture maintenance for ASDF and ASDF Plugin Manager # # ############################################################################ -FROM base AS build-arm64 +FROM asdf-all AS asdf-arm64 # ############################################################################ # -# RISC-V 64-bit architecture maintenance +# RISC-V 64-bit architecture maintenance for ASDF and ASDF Plugin Manager # # ############################################################################ -FROM base AS build-riscv64 +FROM asdf-all AS asdf-riscv64 # ############################################################################ # -# IBM POWER8 architecture maintenance +# IBM POWER8 architecture maintenance for ASDF and ASDF Plugin Manager # # ############################################################################ -FROM base AS build-ppc64le +FROM asdf-all AS asdf-ppc64le # ############################################################################ # -# IBM z-Systems architecture maintenance +# IBM z-Systems architecture maintenance for ASDF and ASDF Plugin Manager # # ############################################################################ -FROM base AS build-s390x +FROM asdf-all AS asdf-s390x # ############################################################################ # -# All architectures maintenance +# Final maintenance for ASDF and ASDF Plugin Manager # # ############################################################################ -FROM build-${TARGETARCH} AS build +FROM asdf-${TARGETARCH} AS asdf + +# ############################################################################ + +# +# ASDF runtime version +# RUN asdf version RUN asdf list +# ############################################################################ + +# +# ASDF Plugin Manager runtime version +# + RUN asdf-plugin-manager version RUN asdf-plugin-manager list - -# Set executable for main entry point -CMD ["/bin/bash"]