This commit is contained in:
2025-12-08 19:38:15 +01:00
parent 864987dc75
commit 6cd465640c

View File

@@ -5,10 +5,16 @@ FROM ubuntu:${UBUNTU_VERSION}
LABEL maintainer="thommyho"
LABEL description="An Ubuntu image with essential tools for git development and CI/CD pipelines."
# Re-declare ARG to make it available inside the build stages (optional, but good practice)
ARG UBUNTU_VERSION
ENV NVM_DIR=/usr/local/nvm \
NODE_VERSION=24.11.1 \
NODE_PATH=/usr/local/nvm/v24.11.1/lib/node_modules \
PATH=/usr/local/nvm/versions/node/v24.11.1/bin:$PATH
PATH=/usr/local/nvm/versions/node/v24.11.1/bin:$PATH \
# This variable fixes the issue: it allows system-wide pip installs on Ubuntu 24.04+
# and is safely ignored by older Ubuntu versions (22.04, 20.04).
PIP_BREAK_SYSTEM_PACKAGES=1
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
@@ -20,15 +26,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
python3-pip \
&& rm -rf /var/lib/apt/lists/*
# Install conan only for Ubuntu 24.04 or newer
RUN UBUNTU_MAJOR_VERSION=$(cut -d'.' -f1 <<<"$UBUNTU_VERSION") && \
if [ "$UBUNTU_MAJOR_VERSION" -ge 24 ]; then \
pip install conan --break-system-packages; \
fi
# Consolidated conan installation into one step.
# The PIP_BREAK_SYSTEM_PACKAGES environment variable handles the version logic automatically.
RUN pip install conan
RUN mkdir -p $NVM_DIR && \
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash && \
. $NVM_DIR/nvm.sh && \
nvm install $NODE_VERSION && \
nvm use $NODE_VERSION && \
nvm alias default $NODE_VERSION
nvm alias default $NODE_VERSION