Skip to content

Commit

Permalink
Install Python and Node.js in the UBI contaienrs using pyenv and fnm
Browse files Browse the repository at this point in the history
Use fnm to install Node.js and pyenv to install Python. This ensures we can install all versions, and are not limited to what is provided by the RedHat UBI software catalog.
  • Loading branch information
julienp committed Nov 14, 2024
1 parent 1d2c6e7 commit b748712
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 63 deletions.
14 changes: 1 addition & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 1 addition & 13 deletions .github/workflows/sync-ecr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 1 addition & 13 deletions .github/workflows/sync-ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 12 additions & 8 deletions docker/nodejs/Dockerfile.ubi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions docker/nodejs/dnf/nodejs.module

This file was deleted.

34 changes: 25 additions & 9 deletions docker/python/Dockerfile.ubi
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,34 @@ 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 \
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}/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 -
Expand Down
4 changes: 2 additions & 2 deletions tests/containers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,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/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
}

t.Run("PATH when running in bash", func(t *testing.T) {
Expand Down

0 comments on commit b748712

Please sign in to comment.