Skip to content

Commit

Permalink
feat: use of finely graded multi-stages
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rexut committed Oct 13, 2024
1 parent 3383e86 commit ac01391
Showing 1 changed file with 100 additions and 58 deletions.
158 changes: 100 additions & 58 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ FROM ubuntu:noble-20240904.1 AS base

# overwrite Ubuntu default metadata
LABEL mantainer="Stephan Linz <[email protected]>"
LABEL version="2024.10.0"
LABEL version="unstable"

# ############################################################################

Expand All @@ -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 /

Expand All @@ -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"]

# ############################################################################

Expand All @@ -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
Expand Down Expand Up @@ -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"]

0 comments on commit ac01391

Please sign in to comment.