diff --git a/Dockerfile b/Dockerfile index 2b08349..51c9385 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,106 +1,126 @@ -FROM ubuntu:23.10 +# Stage 1: Base system with common dependencies +FROM ubuntu:24.04 AS base + SHELL ["/bin/bash", "-c"] +ENV TZ='America/New_York' \ + DEBIAN_FRONTEND="noninteractive" \ + PATH="/root/.cargo/bin:/root/.nvm/versions/node/v22.16.0/bin:/usr/local/go/bin:${PATH}" \ + NVM_DIR="/root/.nvm" \ + NODE_VERSION="lts/jod" -ENV TZ='America/New_York' -RUN apt update \ - && apt upgrade -y \ - && apt install software-properties-common -y \ - && DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \ - curl \ - wget \ - sudo \ - apt-utils \ +# Install common packages in a single layer with proper cleanup +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y --no-install-recommends \ apt-transport-https \ + apt-utils \ + ca-certificates \ + curl \ g++ \ gcc \ git \ + gpg \ + gpg-agent \ + jq \ + less \ + # libc6-dev \ make \ - p7zip-full \ + software-properties-common \ + sudo \ + tree \ unzip \ - xz-utils \ - jq \ + zip \ vim \ - tree \ - less \ - libc6-dev \ - dirmngr \ - gpg gpg-agent \ - ca-certificates \ - zsh \ - # PYTHON LATEST - python3 python3-dev python3-venv python3-pip \ - # JAVA LATEST - openjdk-20-jdk-headless \ - # .NET-CORE LATEST - dotnet6 \ - # Ruby LATEST - ruby-full rbenv \ - # CLEAN UP - && apt-get purge --auto-remove -y \ - && apt-get clean \ - && rm -rf \ - /tmp/* \ - /var/lib/apt/lists/* \ - /var/tmp/* + wget \ + # xz-utils \ + zsh && \ + # Clean up in the same layer to reduce image size + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# Zshell Configuration -RUN chsh -s $(which zsh) -RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended -COPY polyglot.zsh-theme /root/.oh-my-zsh/themes/polyglot.zsh-theme -RUN sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="polyglot"/' /root/.zshrc +# Stage 2: Language-specific installations +FROM base AS languages -# Git Configuration -RUN \ - git config --global pull.rebase true \ - && git config --global init.defaultbranch main \ - && git config --global fetch.prune true \ - && git config --global diff.colorMoved zebra - -# Python configuration -RUN \ - ln -s /usr/bin/python3 /usr/bin/python \ - && python -m pip install --upgrade pip setuptools wheel poetry pipenv --break-system-packages - -# GO installation -RUN \ - curl -OL https://go.dev/dl/go1.22.3.linux-amd64.tar.gz \ - && tar -C /usr/local -xvf go1.22.3.linux-amd64.tar.gz \ - && ln -s /usr/local/go/bin/go /usr/bin/go - -# Node installation with nvm -ENV NODE_VERSION lts/iron -RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash \ - && . ~/.nvm/nvm.sh \ - && nvm install $NODE_VERSION \ - && nvm alias default $NODE_VERSION \ - && nvm use default \ - && ln -s $(which node) /usr/bin/node \ - && ln -s $(which npm) /usr/bin/npm - -# Rust installation +# Add repositories and install programming languages in a single layer +RUN apt-get update && \ + # Python + apt-get install -y --no-install-recommends python3 python3-dev python3-venv python3-pip && \ + ln -s /usr/bin/python3 /usr/bin/python && \ + # Java + apt-get install -y --no-install-recommends openjdk-21-jdk && \ + # .NET + apt-get install -y --no-install-recommends dotnet-sdk-8.0 dotnet-runtime-8.0 && \ + # Ruby + apt-get install -y --no-install-recommends ruby-full rbenv && \ + # Clean up + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# Stage 3: Tool installations (Go, Node, Rust, Docker) +FROM languages AS tools + +# Install Go +RUN curl -OL https://go.dev/dl/go1.24.4.linux-amd64.tar.gz && \ + tar -C /usr/local -xf go1.24.4.linux-amd64.tar.gz && \ + rm go1.24.4.linux-amd64.tar.gz && \ + ln -sf /usr/local/go/bin/go /usr/bin/go + +# Install Node.js with nvm +RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash && \ + . $NVM_DIR/nvm.sh && \ + nvm install $NODE_VERSION && \ + nvm alias default $NODE_VERSION && \ + nvm use default && \ + ln -sf $(. $NVM_DIR/nvm.sh && which node) /usr/bin/node && \ + ln -sf $(. $NVM_DIR/nvm.sh && which npm) /usr/bin/npm + +# Install Rust RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y -ENV PATH="/root/.cargo/bin:${PATH}" -# Docker installation +# Install Docker RUN curl -fsSL https://get.docker.com | sh -# Print versions -RUN \ - echo "Tool versions:" \ - && python --version \ - && pip --version \ - && poetry --version \ - && pipenv --version \ - && java -version \ - && go version \ - && dotnet --version \ - && node --version \ - && npm --version \ - && rustup --version \ - && rustc --version \ - && ruby --version \ - && gem --version \ - && rbenv --version \ - && docker --version +# Stage 4: Python packages and configuration +FROM tools AS python-config + +RUN python -m pip install --no-cache-dir pipx poetry pipenv --break-system-packages + +# Stage 5: Final image with configurations +FROM python-config AS final + +# Git Configuration +RUN git config --global pull.rebase true && \ + git config --global init.defaultbranch main && \ + git config --global fetch.prune true && \ + git config --global diff.colorMoved zebra + +# Zshell Configuration +RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended && \ + chsh -s $(which zsh) + +# Copy theme file +COPY polyglot.zsh-theme /root/.oh-my-zsh/themes/polyglot.zsh-theme +RUN sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="polyglot"/' /root/.zshrc + +# Print versions for verification +RUN echo "Tool versions:" && \ + python --version && \ + pip --version && \ + poetry --version && \ + pipenv --version && \ + java -version && \ + go version && \ + dotnet --version && \ + . $NVM_DIR/nvm.sh && \ + node --version && \ + npm --version && \ + rustup --version && \ + rustc --version && \ + ruby --version && \ + gem --version && \ + rbenv --version && \ + docker --version +# Set default shell to zsh +CMD ["zsh"] diff --git a/Makefile b/Makefile index 09b9d58..d5fb5a9 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,32 @@ shell: build: docker build . -t jpwhite3/polyglot:latest --platform linux/amd64 --progress=plain + @echo "Updating README.md with latest tool versions..." + @container_id=$$(docker run -d jpwhite3/polyglot:latest sleep 30) && \ + node_version=$$(docker exec $$container_id bash -c '. /root/.nvm/nvm.sh && node --version' | tr -d 'v') && \ + python_version=$$(docker exec $$container_id python --version | awk '{print $$2}') && \ + java_version=$$(docker exec $$container_id bash -c "java -version 2>&1 | head -1" | awk -F '"' '{print $$2}') && \ + dotnet_version=$$(docker exec $$container_id dotnet --version) && \ + go_version=$$(docker exec $$container_id go version | awk '{print $$3}' | sed 's/go//') && \ + ruby_version=$$(docker exec $$container_id ruby --version | awk '{print $$2}') && \ + rust_version=$$(docker exec $$container_id rustc --version | awk '{print $$2}') && \ + docker_version=$$(docker exec $$container_id docker --version | awk '{print $$3}' | tr -d ',') && \ + docker rm -f $$container_id > /dev/null 2>&1 && \ + sed -i.bak \ + -e "s/| Node |.*|/| Node | $$node_version |/" \ + -e "s/| Python |.*|/| Python | $$python_version |/" \ + -e "s/| Java |.*|/| Java | $$java_version |/" \ + -e "s/| Dotnet |.*|/| Dotnet | $$dotnet_version |/" \ + -e "s/| GO |.*|/| GO | $$go_version |/" \ + -e "s/| Ruby |.*|/| Ruby | $$ruby_version |/" \ + -e "s/| Rust |.*|/| Rust | $$rust_version |/" \ + -e "s/| Docker |.*|/| Docker | $$docker_version |/" \ + README.md && \ + rm README.md.bak && \ + echo "README.md updated with latest tool versions" + +scan: + docker scout quickview publish: docker push jpwhite3/polyglot:latest diff --git a/README.md b/README.md index 42b549a..b53dc5f 100644 --- a/README.md +++ b/README.md @@ -10,24 +10,24 @@ Multi programming language container image built for interactive development env - [GitLab](https://about.gitlab.com) - etc. -_NOTE:_ This image is on the large side, around 2.5GB in total. This makes it too big for most large scale uses. But in small scale it seems to work quite well despite its size. +_NOTE:_ This image is **large**, around 5GB in total. This makes it far too big for most large scale uses. But in small scale it seems to work quite well despite its size. ## Base Image -This image is based on Ubuntu 23.10 (mantic) +This image is based on Ubuntu (latest LTS) ## Included Languages & Tools -| Language Ecosystem | Version | Included Tools | -| ------------------ | -------- | -------------- | -| Node | 20.10.0 | nvm, npm | -| Python | 3.11.5 | Poetry, pipenv | -| Ruby | 3.1.2p20 | gem, rbenv | -| Java | 20.0.2 | | -| Dotnet | 6.0.122 | | -| GO | 1.21.5 | | -| Rust | 1.74.1 | | -| Docker | 24.0.7 | | +| Language Ecosystem | Version | +| ------------------ | ------- | +| Node | 22.16.0 | +| Python | 3.12.3 | +| Java | 21.0.7 | +| Dotnet | 8.0.117 | +| GO | 1.24.4 | +| Ruby | 3.2.3 | +| Rust | 1.87.0 | +| Docker | 28.2.2 | # Build Instructions