From 8315904427d8e43eeb3f345eaeba2d184ad6b135 Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Sun, 28 Jul 2024 15:07:29 -0400 Subject: [PATCH] fix: ensure healthy node20, corepack, python3.12 --- images/ubuntu-2204/Dockerfile | 71 +++++++++++++++++++++++++++-------- 1 file changed, 56 insertions(+), 15 deletions(-) diff --git a/images/ubuntu-2204/Dockerfile b/images/ubuntu-2204/Dockerfile index d849963..c11c8d6 100644 --- a/images/ubuntu-2204/Dockerfile +++ b/images/ubuntu-2204/Dockerfile @@ -1,6 +1,12 @@ FROM ubuntu:22.04 as skeleton -ENV NODE_VERSION="20.12.2" +ENV NODE_VERSION "20.12.2" +ENV NVM_VERSION "0.37.2" + +ENV PYTHON_VERSION "3.12" + +ENV DEBIAN_FRONTEND noninteractive +ENV TZ Etc/UTC RUN apt update && \ apt upgrade -y && \ @@ -11,28 +17,63 @@ RUN apt update && \ git \ xz-utils \ ca-certificates \ - python3 \ - python3-pip \ - python3-venv \ --no-install-recommends \ - --autoremove + --autoremove && \ + apt-get clean -FROM skeleton as build-node +COPY ./files/registries.conf /etc/containers/registries.conf -WORKDIR tmp +FROM skeleton AS build-python -# Install node. -RUN curl https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz \ - --output /tmp/node-v$NODE_VERSION-linux-x64.tar.xz && \ - tar -xf /tmp/node-v$NODE_VERSION-linux-x64.tar.xz +RUN apt update && \ + apt upgrade -y && \ + apt install -y \ + build-essential \ + libssl-dev \ + zlib1g-dev \ + libbz2-dev \ + libreadline-dev \ + libsqlite3-dev \ + libncursesw5-dev \ + tk-dev \ + libxml2-dev \ + libxmlsec1-dev \ + libffi-dev \ + liblzma-dev \ + --no-install-recommends \ + --autoremove && \ + apt-get clean + +RUN curl https://pyenv.run | bash + +ENV PATH /root/.pyenv/bin:$PATH + +RUN pyenv install $PYTHON_VERSION FROM skeleton as runner WORKDIR /runner -COPY --from=build-node /tmp/node-v$NODE_VERSION-linux-x64/bin/* /bin/ -COPY --from=build-node /tmp/node-v$NODE_VERSION-linux-x64/lib/* /lib/ +RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v$NVM_VERSION/install.sh | bash -RUN python3 -m pip install pipx +RUN . $HOME/.nvm/nvm.sh && \ + nvm install $NODE_VERSION && \ + nvm use $NODE_VERSION && \ + nvm cache clear -COPY ./files/registries.conf /etc/containers/registries.conf +ENV NVM_DIR $HOME/.nvm +ENV PATH /root/.nvm/versions/node/v$NODE_VERSION/bin:$PATH + +RUN node --version + +RUN corepack enable + +COPY --from=build-python /root/.pyenv /root/.pyenv + +ENV PATH /root/.pyenv/bin:/root/.pyenv/shims:$PATH + +RUN pyenv global $PYTHON_VERSION + +RUN python --version + +RUN pip install pipx