diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1646db4a..bc8a416c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -434,20 +434,8 @@ jobs: - uses: actions/checkout@master - name: Define Matrix for UBI SDK Manifests id: define-matrix-sdk-manifests - # Filter out the nodejs 22 and 23 versions from the matrix, as they are not supported on UBI. - # https://access.redhat.com/articles/3376841 - # Filter out the python 3.10 and 3.13 versions from the matrix, as they are supported on UBI. - # https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/installing_and_using_dynamic_programming_languages/assembly_introduction-to-python_installing-and-using-dynamic-programming-languages#con_python-versions_assembly_introduction-to-python run: | - echo matrix=$(python ./.github/scripts/matrix/gen-matrix.py --no-arch | - jq '.include |= map( - select( - (.sdk != "nodejs" or .language_version != "22") and - (.sdk != "nodejs" or .language_version != "23") and - (.sdk != "python" or .language_version != "3.10") and - (.sdk != "python" or .language_version != "3.13") - ) - )') >> "$GITHUB_OUTPUT" + echo matrix=$(python ./.github/scripts/matrix/gen-matrix.py --no-arch) >> "$GITHUB_OUTPUT" ubi-sdk: name: UBI SDK images diff --git a/.github/workflows/sync-ecr.yml b/.github/workflows/sync-ecr.yml index b69dd869..a7231948 100644 --- a/.github/workflows/sync-ecr.yml +++ b/.github/workflows/sync-ecr.yml @@ -155,20 +155,8 @@ jobs: - uses: actions/checkout@master - name: Define Matrix id: define-matrix - # Filter out the nodejs 22 and 23 versions from the matrix, as they are not supported on UBI. - # https://access.redhat.com/articles/3376841 - # Filter out the python 3.10 and 3.13 versions from the matrix, as they are not supported on UBI. - # https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/installing_and_using_dynamic_programming_languages/assembly_introduction-to-python_installing-and-using-dynamic-programming-languages#con_python-versions_assembly_introduction-to-python run: | - echo matrix=$(python ./.github/scripts/matrix/gen-matrix.py --no-arch | - jq '.include |= map( - select( - (.sdk != "nodejs" or .language_version != "22") and - (.sdk != "nodejs" or .language_version != "23") and - (.sdk != "python" or .language_version != "3.10") and - (.sdk != "python" or .language_version != "3.13") - ) - )') >> "$GITHUB_OUTPUT" + echo matrix=$(python ./.github/scripts/matrix/gen-matrix.py --no-arch) >> "$GITHUB_OUTPUT" # NOTE: If UBI images become multi platform, this job can be replaced by adding a similar step to "-debian" for "-ubi" the previous job. ubi-images: diff --git a/.github/workflows/sync-ghcr.yml b/.github/workflows/sync-ghcr.yml index 9a5967ee..7efa5d72 100644 --- a/.github/workflows/sync-ghcr.yml +++ b/.github/workflows/sync-ghcr.yml @@ -134,20 +134,8 @@ jobs: - uses: actions/checkout@master - name: Define Matrix id: define-matrix - # Filter out the nodejs 22 and 23 versions from the matrix, as they are not supported on UBI. - # https://access.redhat.com/articles/3376841 - # Filter out the python 3.10 and 3.13 versions from the matrix, as they are not supported on UBI. - # https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/installing_and_using_dynamic_programming_languages/assembly_introduction-to-python_installing-and-using-dynamic-programming-languages#con_python-versions_assembly_introduction-to-python run: | - echo matrix=$(python ./.github/scripts/matrix/gen-matrix.py --no-arch | - jq '.include |= map( - select( - (.sdk != "nodejs" or .language_version != "22") and - (.sdk != "nodejs" or .language_version != "23") and - (.sdk != "python" or .language_version != "3.10") and - (.sdk != "python" or .language_version != "3.13") - ) - )') >> "$GITHUB_OUTPUT" + echo matrix=$(python ./.github/scripts/matrix/gen-matrix.py --no-arch) >> "$GITHUB_OUTPUT" # NOTE: If UBI images become multi platform, this job can be replaced by adding a similar step to "-debian" for "-ubi" the previous job. ubi-images: diff --git a/CHANGELOG.md b/CHANGELOG.md index 232accf9..5d027758 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +- Install Python and Node.js in the UBI containers using pyenv and fnm + ([326])https://github.com/pulumi/pulumi-docker-containers/pull/326)) + - Update default language versions ([324](https://github.com/pulumi/pulumi-docker-containers/pull/324)) diff --git a/docker/nodejs/Dockerfile.ubi b/docker/nodejs/Dockerfile.ubi index 227940ab..7a95949f 100644 --- a/docker/nodejs/Dockerfile.ubi +++ b/docker/nodejs/Dockerfile.ubi @@ -15,18 +15,22 @@ ARG LANGUAGE_VERSION LABEL org.opencontainers.image.description="Pulumi CLI container for nodejs" WORKDIR /pulumi/projects -COPY dnf/nodejs.module /etc/dnf/modules.d/nodejs.module -RUN sed -i s"/__LANGUAGE_VERSION_PLACEHOLDER__/${LANGUAGE_VERSION}/g" /etc/dnf/modules.d/nodejs.module -RUN cat /etc/dnf/modules.d/nodejs.module - RUN microdnf install -y \ ca-certificates \ curl \ git \ - nodejs \ - tar && \ - npm install -g npm@10.5.1 && \ - npm install -g corepack && \ + tar \ + unzip + +# Install nodejs using fnm +RUN curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir "/usr/local/share/fnm" --skip-shell && \ + ln -s /usr/local/share/fnm/fnm /usr/local/bin/fnm +ENV FNM_COREPACK_ENABLED="true" +ENV FNM_DIR=/usr/local/share/fnm +RUN fnm install ${LANGUAGE_VERSION} && \ + fnm alias ${LANGUAGE_VERSION} default +ENV PATH=/usr/local/share/fnm/aliases/default/bin:$PATH +RUN npm install -g corepack && \ corepack install -g yarn@1 # Uses the workdir, copies from pulumi interim container diff --git a/docker/nodejs/dnf/nodejs.module b/docker/nodejs/dnf/nodejs.module deleted file mode 100644 index 0a190bd5..00000000 --- a/docker/nodejs/dnf/nodejs.module +++ /dev/null @@ -1,5 +0,0 @@ -[nodejs] -name=nodejs -stream=__LANGUAGE_VERSION_PLACEHOLDER__ -profiles= -state=enabled diff --git a/docker/python/Dockerfile.ubi b/docker/python/Dockerfile.ubi index 100ef5dc..bf08119a 100644 --- a/docker/python/Dockerfile.ubi +++ b/docker/python/Dockerfile.ubi @@ -14,18 +14,36 @@ ARG LANGUAGE_VERSION LABEL org.opencontainers.image.description="Pulumi CLI container for python" WORKDIR /pulumi/projects - -# Set the shell to bash so we can do the shell substitution below -SHELL ["/bin/bash", "-c"] -# Install needed tools, like git +# Install needed tools, like git, and build dependencies RUN microdnf install -y \ + bzip2 \ + bzip2-devel \ ca-certificates \ + findutils \ + gcc \ + gdbm-libs \ git \ - # For Python 3.9 we need the package names python39 and python39-pip - python${LANGUAGE_VERSION//3.9/39} \ - python${LANGUAGE_VERSION//3.9/39}-pip \ - tar && \ - pip3 install --user pipenv + libffi-devel \ + libnsl2 \ + libuuid-devel \ + make \ + ncurses \ + ncurses-devel \ + openssl-devel \ + patch \ + readline \ + sqlite \ + sqlite-devel \ + tar \ + xz-devel \ + zlib-devel + +# Install python using pyenv +RUN git clone --depth=1 https://github.com/pyenv/pyenv.git /usr/local/share/pyenv +ENV PYENV_ROOT=/usr/local/share/pyenv +ENV PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PATH}" +RUN pyenv install ${LANGUAGE_VERSION} +RUN pyenv global ${LANGUAGE_VERSION} # Install poetry RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/usr/local/share/pypoetry python3 - diff --git a/tests/containers_test.go b/tests/containers_test.go index a1aac2d9..a4b05a5c 100644 --- a/tests/containers_test.go +++ b/tests/containers_test.go @@ -291,12 +291,9 @@ func TestEnvironment(t *testing.T) { } t.Parallel() expected := "/usr/local/bin/python" - if isKitchenSink(t) { + if isKitchenSink(t) || isUBI(t) { expected = "/usr/local/share/pyenv/shims/python" } - if isUBI(t) { - expected = "/usr/bin/python" - } p, err := exec.LookPath("python") require.NoError(t, err) require.Equal(t, expected, p) @@ -327,26 +324,26 @@ func TestEnvironment(t *testing.T) { { name: "node", expectedDebian: "/usr/local/bin/node", - expectedUbi: "/usr/bin/node", + expectedUbi: "/usr/local/share/fnm/aliases/default/bin/node", expectedKitchen: "/usr/local/share/fnm/aliases/default/bin/node", }, { name: "npm", expectedDebian: "/usr/local/bin/npm", - expectedUbi: "/usr/local/bin/npm", + expectedUbi: "/usr/local/share/fnm/aliases/default/bin/npm", expectedKitchen: "/usr/local/share/fnm/aliases/default/bin/npm", }, { name: "yarn", expectedDebian: "/usr/local/bin/yarn", - expectedUbi: "/usr/local/bin/yarn", + expectedUbi: "/usr/local/share/fnm/aliases/default/bin/yarn", expectedKitchen: "/usr/local/share/fnm/aliases/default/bin/yarn", }, { name: "corepack", expectedDebian: "/usr/local/bin/corepack", - expectedUbi: "/usr/local/bin/corepack", + expectedUbi: "/usr/local/share/fnm/aliases/default/bin/corepack", expectedKitchen: "/usr/local/share/fnm/aliases/default/bin/corepack", }, } { @@ -383,8 +380,8 @@ func TestEnvironment(t *testing.T) { "pulumi-ubi-dotnet": "/root/.dotnet:/pulumi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "pulumi-ubi-go": "/pulumi/bin:/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "pulumi-ubi-java": "/pulumi/bin:/root/.sdkman/candidates/maven/current/bin:/root/.sdkman/candidates/gradle/current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", - "pulumi-ubi-nodejs": "/pulumi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", - "pulumi-ubi-python": "/pulumi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", + "pulumi-ubi-nodejs": "/pulumi/bin:/usr/local/share/fnm/aliases/default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", + "pulumi-ubi-python": "/pulumi/bin:/usr/local/share/pyenv/shims:/usr/local/share/pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", } t.Run("PATH when running in bash", func(t *testing.T) {