diff --git a/.github/actions/clp-build-runtime-image/action.yaml b/.github/actions/clp-build-runtime-image/action.yaml index 60ed42af2d..454dd19394 100644 --- a/.github/actions/clp-build-runtime-image/action.yaml +++ b/.github/actions/clp-build-runtime-image/action.yaml @@ -14,17 +14,14 @@ inputs: default: "" description: "Container image registry password" required: false - platform_id: - description: "Platform ID of the container (e.g. ubuntu)" - required: false - platform_version_id: - description: "Platform VERSION_ID / VERSION_CODENAME of the container - (e.g. jammy, focal, etc.)" - required: false arch: description: "Target architecture (amd64 or arm64)" default: "amd64" required: false + platform_version_codename: + description: >- + Platform version codename (e.g. jammy, noble) used as the runtime image base version. + required: true runs: using: "composite" @@ -94,3 +91,5 @@ runs: push: true tags: "${{steps.extract-gh-meta.outputs.tags}}" labels: "${{steps.extract-gh-meta.outputs.labels}}" + build-args: | + UBUNTU_VERSION_CODENAME=${{inputs.platform_version_codename}} diff --git a/.github/workflows/clp-artifact-build.yaml b/.github/workflows/clp-artifact-build.yaml index 5c739eb883..9aeb978d0e 100644 --- a/.github/workflows/clp-artifact-build.yaml +++ b/.github/workflows/clp-artifact-build.yaml @@ -739,6 +739,7 @@ jobs: image_registry_username: "${{github.actor}}" image_registry_password: "${{secrets.GITHUB_TOKEN}}" arch: "${{matrix.arch}}" + platform_version_codename: "jammy" package-image-multiarch-manifest: name: "package-image-multiarch-manifest" diff --git a/docs/src/dev-docs/building-package.md b/docs/src/dev-docs/building-package.md index 1f8acbb095..02ceb76759 100755 --- a/docs/src/dev-docs/building-package.md +++ b/docs/src/dev-docs/building-package.md @@ -5,11 +5,10 @@ prebuilt version instead, check out the [releases](https://github.com/y-scope/cl ## Requirements -* An x86_64 Ubuntu 22.04 (Jammy) machine or container - * At runtime, the CLP package uses an Ubuntu Jammy container, so we need to build in a matching - environment. - * It should be possible to build a package for a different environment, it just requires a some - extra configuration. +* An amd64 or arm64 Ubuntu machine or container + * The package build creates a runtime image using the host Ubuntu version codename by default, so + host-built artifacts and the runtime image use matching Ubuntu environments. + * To reproduce official release package tarballs, use an amd64 Ubuntu 22.04 (Jammy) environment. * [Docker] * `containerd.io` >= 1.7.18 * `docker-buildx-plugin` >= 0.15.1 diff --git a/tools/docker-images/clp-package/Dockerfile b/tools/docker-images/clp-package/Dockerfile index e9e0e49d30..26c02e7028 100644 --- a/tools/docker-images/clp-package/Dockerfile +++ b/tools/docker-images/clp-package/Dockerfile @@ -1,6 +1,7 @@ # syntax=docker/dockerfile:1 -FROM ubuntu:jammy AS base +ARG UBUNTU_VERSION_CODENAME=jammy +FROM ubuntu:${UBUNTU_VERSION_CODENAME} AS base WORKDIR /root @@ -23,7 +24,10 @@ ENV LD_LIBRARY_PATH="${CLP_HOME}/lib" \ PYTHONPATH="${CLP_HOME}/lib/python3/site-packages" \ USER="clp-user" -RUN useradd --uid ${UID} --shell /bin/bash --home-dir ${CLP_HOME} ${USER} +RUN existing_user="$(getent passwd "${UID}" | cut --delimiter=: --fields=1)" || true; \ + [ -z "${existing_user}" ] || userdel --remove "${existing_user}" \ + || { echo "ERROR: Cannot delete user '${existing_user}' that occupies UID ${UID}"; exit 1; }; \ + useradd --uid ${UID} --shell /bin/bash --home-dir ${CLP_HOME} ${USER} USER ${USER} WORKDIR ${CLP_HOME} diff --git a/tools/docker-images/clp-package/build.sh b/tools/docker-images/clp-package/build.sh index bade7e52cf..8bb9136bb5 100755 --- a/tools/docker-images/clp-package/build.sh +++ b/tools/docker-images/clp-package/build.sh @@ -36,6 +36,15 @@ build_cmd=( --file "${script_dir}/Dockerfile" ) +ubuntu_version_codename="jammy" +if [[ -f /etc/os-release ]]; then + host_codename="$(. /etc/os-release && echo "$VERSION_CODENAME")" + if [[ -n "$host_codename" ]]; then + ubuntu_version_codename="$host_codename" + fi +fi +build_cmd+=(--build-arg "UBUNTU_VERSION_CODENAME=${ubuntu_version_codename}") + if command -v git >/dev/null && git -C "$script_dir" rev-parse --is-inside-work-tree >/dev/null; then build_cmd+=(