From 08a54ab52253e975ecfa7e09f892066c0f77a251 Mon Sep 17 00:00:00 2001 From: kvrigor Date: Fri, 30 Jan 2026 16:59:51 +0100 Subject: [PATCH 1/9] Convert eCLM Dockerfile to Ubuntu --- eclm/Dockerfile | 115 +++++++++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 56 deletions(-) diff --git a/eclm/Dockerfile b/eclm/Dockerfile index 5046c55..0d88881 100644 --- a/eclm/Dockerfile +++ b/eclm/Dockerfile @@ -1,67 +1,70 @@ # escape=` -FROM centos:8.4.2105 +FROM ubuntu:24.04 -# Image metadata for documentation purposes. Has no effect on docker build behavior. -LABEL ` - org.label-schema.schema-version="1.0" ` - org.label-schema.name="eCLM" ` - org.label-schema.version="0.1" ` - org.label-schema.vendor="IBG-3" ` - org.label-schema.license="GPLv2" ` - org.label-schema.build-date="2021-09-27" ` - eclm.version.major="alpha" ` - eclm.env.compiler="GCC" ` - eclm.env.compiler.version="8.4.1-1" ` - eclm.env.mpi="OpenMPI" ` - eclm.env.mpi.version="4.0.5" ` - eclm.env.cmake.version="3.18.2" ` - eclm.env.pnetcdf.version="1.12.1" ` - eclm.env.netcdf-c.version="4.7.0" ` - eclm.env.netcdf-fortran.version="4.5.2" +# +# TODO: Specify image metadata following OCI format spec: https://github.com/opencontainers/image-spec/blob/main/spec.md +# +# LABEL ... -# Install required packages from base repo -RUN dnf update -y ` - && dnf group install -y "Development Tools" ` - && dnf install -y glibc-langpack-en libcurl-devel ` - man-db man-pages passwd sudo vim wget which tree ` - python39 python39-pip cmake` - epel-release ` - && dnf config-manager --set-enabled powertools ` - ` -# Install required packages from EPEL and SCL repos - && dnf install -y hdf5-devel lapack-devel openssl-devel ` - openmpi openmpi-devel ` - netcdf-devel netcdf-fortran netcdf-fortran-devel ` - && dnf clean all ` - ` -# Add python symlinks to /usr/local - && python3 -m pip install --upgrade pip ` - && ln -s /usr/bin/python3 /usr/local/bin/python + +# Download basic utilities and compilers from Ubuntu apt repo +RUN DEBIAN_FRONTEND=noninteractive apt-get update ` + && apt-get install -y sudo nano git wget tree cmake python3.12 ` + && apt-get install -y gfortran g++ openmpi-bin libopenmpi-dev ` + && apt-get install -y libxml++2.6-dev libhdf5-openmpi-dev libhdf5-openmpi-hl-fortran-100t64 hdf5-helpers liblapack-dev libblas-dev + + +ENV VER_NETCDF_C="4.9.2" +ENV VER_NETCDF_F90="4.6.1" +ENV VER_PNETCDF="1.14.0" +ENV CC=mpicc FC=mpifort CXX=mpicxx +ENV TMP=/tmp/bld +ENV INSTALL_PREFIX=/usr/local +ENV MAKEFLAGS=-j8 + +# Build prep +RUN mkdir -vp $TMP + +# Install netCDF +RUN cd $TMP ` + && wget -c https://github.com/Unidata/netcdf-c/archive/refs/tags/v${VER_NETCDF_C}.tar.gz ` + && tar zxf v${VER_NETCDF_C}.tar.gz ` + && cd netcdf-c-${VER_NETCDF_C} ` + && CPPFLAGS=-I/usr/include/hdf5/openmpi LDFLAGS=-L/usr/lib/x86_64-linux-gnu/hdf5/openmpi ./configure --prefix=${INSTALL_PREFIX} ` + && make install + +# Install netCDF Fortran +RUN cd $TMP ` + && wget -c https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v${VER_NETCDF_F90}.tar.gz ` + && tar zxf v${VER_NETCDF_F90}.tar.gz ` + && cd netcdf-fortran-${VER_NETCDF_F90} ` + && ./configure --prefix=${INSTALL_PREFIX} ` + && make install # Install PnetCDF -ENV PATH="/usr/lib64/openmpi/bin:${PATH}" -RUN mkdir -vp /tmp/bld ` - && cd /tmp/bld ` - && wget -c https://github.com/Parallel-NetCDF/PnetCDF/archive/checkpoint.1.12.1.tar.gz ` - && tar zxf checkpoint.1.12.1.tar.gz ` - && cd PnetCDF-checkpoint.1.12.1 ` +RUN cd $TMP ` + && wget -c https://github.com/Parallel-NetCDF/PnetCDF/archive/checkpoint.${VER_PNETCDF}.tar.gz ` + && tar zxf checkpoint.${VER_PNETCDF}.tar.gz ` + && cd PnetCDF-checkpoint.${VER_PNETCDF} ` && autoreconf -i ` - && ./configure --prefix=/usr/local && make -j && make install ` - && cd / && rm -rf /tmp/bld + && ./configure --prefix=${INSTALL_PREFIX} ` + && make install + +# Delete build artifacts +RUN cd / && rm -rvf $TMP # Add user account -RUN groupadd -g 1555 clm5docker ` - && useradd clmuser -g clm5docker` - && echo clm5 | passwd --stdin clmuser ` - && usermod -aG wheel clmuser ` - && rm /run/nologin ` +RUN groupadd hpscterrsys ` + && useradd user -g hpscterrsys -m ` + && usermod -aG hpscterrsys user ` + && adduser user sudo ` ` # Set default envs - && echo "export PATH=/usr/lib64/openmpi/bin:/home/clmuser/.local/bin:$PATH" >> /home/clmuser/.bash_profile ` - && echo "export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib64/pkgconfig" >> /home/clmuser/.bash_profile ` - && echo "export CC=mpicc" >> /home/clmuser/.bash_profile ` - && echo "export FC=mpifort" >> /home/clmuser/.bash_profile ` - && echo "alias ll='ls -phAlv'" >> /home/clmuser/.bash_profile -USER clmuser -WORKDIR /home/clmuser + && echo "export CC=$CC" >> /home/user/.bash_profile ` + && echo "export FC=$FC" >> /home/user/.bash_profile ` + && echo "export CXX=$CXX" >> /home/user/.bash_profile ` + && echo "alias ll='ls -phAlv'" >> /home/user/.bash_profile + +USER user +WORKDIR /home/user CMD ["/bin/bash","-l"] From 940eb1ef243a72cca3da10e684401e2b53f0b9e3 Mon Sep 17 00:00:00 2001 From: kvrigor Date: Tue, 3 Feb 2026 22:06:20 +0100 Subject: [PATCH 2/9] Uploaded hpscterrsys/eclm:0.2 --- README.md | 2 +- eclm/README.md | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6d190d2..c1db217 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Run `docker pull :` to retrieve the desired image. | Image | Version | `docker pull` command | Usage guide | |:-----:|:-------:|:-------------------------------------:|:------------------:| | CLM5 | 0.4 | `docker pull hpscterrsys/clm5:latest` | [link][clm5-usage] | -| eCLM | 0.1 | `docker pull hpscterrsys/eclm:latest` | [link][eclm-usage] | +| eCLM | 0.2 | `docker pull hpscterrsys/eclm:latest` | [link][eclm-usage] | [HPSCTerrSys DockerHub repository]: https://hub.docker.com/u/hpscterrsys diff --git a/eclm/README.md b/eclm/README.md index 99e06f0..6ddf039 100644 --- a/eclm/README.md +++ b/eclm/README.md @@ -3,15 +3,15 @@ 1. Build Docker image ```sh -IMG_VERSION="0.1" -docker build --tag hpscterrsys/eclm:latest --tag hpscterrsys/eclm:$IMG_VERSION . +IMG_VERSION="0.2" +podman build --tag hpscterrsys/eclm:latest --tag hpscterrsys/eclm:$IMG_VERSION . ``` 2. Commit image to DockerHub ```sh -docker login -docker push hpscterrsys/eclm:latest -docker push hpscterrsys/eclm:$IMG_VERSION -docker logout +podman login docker.io +podman push hpscterrsys/eclm:latest +podman push hpscterrsys/eclm:$IMG_VERSION +podman logout ``` From 24d1b12c510d005d864d001f95d5c58760baf8e0 Mon Sep 17 00:00:00 2001 From: kvrigor Date: Thu, 5 Feb 2026 14:42:28 +0100 Subject: [PATCH 3/9] Changed CLM5 base image to Ubuntu --- clm5/Dockerfile | 140 +++++++++----------------- clm5/README.md | 12 +-- clm5/cime_config/config_compilers.xml | 6 +- clm5/cime_config/config_machines.xml | 8 +- 4 files changed, 62 insertions(+), 104 deletions(-) diff --git a/clm5/Dockerfile b/clm5/Dockerfile index d1ced2d..0c65256 100644 --- a/clm5/Dockerfile +++ b/clm5/Dockerfile @@ -1,106 +1,64 @@ # escape=` -FROM centos:8.2.2004 +FROM ubuntu:22.04 -# Image metadata for documentation purposes. Has no effect on docker build behavior. -LABEL ` - org.label-schema.schema-version="1.0" ` - org.label-schema.name="CLM5.0 Development Environment" ` - org.label-schema.version="0.4" ` - org.label-schema.vendor="IBG-3" ` - org.label-schema.license="GPLv2" ` - org.label-schema.build-date="20201111" ` - clm.version.major="5" ` - clm.env.compiler="GCC" ` - clm.env.compiler.version="8.3.1" ` - clm.env.mpi="OpenMPI" ` - clm.env.mpi.version="4.0.2-2" ` - clm.env.cmake.version="3.18" ` - clm.env.pnetcdf.version="1.12.1" ` - clm.env.netcdf-c.version="4.7.0" ` - clm.env.netcdf-fortran.version="4.5.2-3" ` - clm.env.esmf.version="8.0.1" +# +# TODO: Specify image metadata following OCI format spec: https://github.com/opencontainers/image-spec/blob/main/spec.md +# +# LABEL ... -# Import cime config files to image -WORKDIR /tmp/.cime -COPY cime_config/* /tmp/.cime/ -# Install required packages from base repo -RUN dnf update -y ` - && dnf group install -y "Development Tools" ` - && dnf install -y glibc-langpack-en libcurl-devel man-db man-pages passwd sudo vim wget which tree ` - perl-App-cpanminus python38 python38-pip ` - epel-release ` - && dnf config-manager --set-enabled PowerTools ` - ` -# Install required packages from EPEL and SCL repos - && dnf install -y hdf5-devel lapack-devel ncl nco netcdf-devel netcdf-fortran netcdf-fortran-devel openssl-devel openmpi openmpi-devel ` - && dnf clean all ` - ` -# misc - && ln -s /usr/bin/python3 /usr/bin/python ` +# Download basic utilities and compilers from Ubuntu apt repo +RUN DEBIAN_FRONTEND=noninteractive apt-get update ` + && apt-get install -y sudo nano git wget tree cmake python3.10 ` + && apt-get install -y gcc-10 gfortran-10 g++-10 openmpi-bin libopenmpi-dev ` + && apt-get install -y libhdf5-openmpi-dev libhdf5-openmpi-hl-fortran-100 hdf5-helpers liblapack-dev libblas-dev ` + && apt-get install -y netcdf-bin libnetcdf-dev libnetcdff-dev libpnetcdf-dev nco + +RUN apt-get install -y libxml++2.6-dev libxml2-utils cpanminus ` && cpanm bigint && cpanm XML::LibXML -# Required envs for building libraries -ENV ESMF_DIR=/tmp/bld/esmf-ESMF_8_0_1 -ENV ESMF_INSTALL_PREFIX=/usr/local -ENV ESMF_INSTALL_MODDIR=include -ENV ESMF_INSTALL_LIBDIR=lib -ENV ESMF_INSTALL_BINDIR=bin -ENV PATH="/usr/lib64/openmpi/bin:${PATH}" +RUN ln -sf /usr/bin/python3 /usr/bin/python ` + && ln -sf /usr/bin/gcc-10 /usr/bin/gcc ` + && ln -sf /usr/bin/g++-10 /usr/bin/g++ ` + && ln -sf /usr/bin/gfortran-10 /usr/bin/gfortran + +ENV CC=mpicc FC=mpifort CXX=mpicxx -# Install CMake -RUN mkdir -vp /tmp/bld ` - && cd /tmp/bld ` - && wget -c https://github.com/Kitware/CMake/releases/download/v3.18.4/cmake-3.18.4.tar.gz ` - && tar zxf cmake-3.18.4.tar.gz && cd cmake-3.18.4 ` - && ./bootstrap && make && make install ` - ` -# PnetCDF - && cd /tmp/bld ` - && wget -c https://github.com/Parallel-NetCDF/PnetCDF/archive/checkpoint.1.12.1.tar.gz ` - && tar zxf checkpoint.1.12.1.tar.gz ` - && cd PnetCDF-checkpoint.1.12.1 ` - && autoreconf -i ` - && ./configure --prefix=/usr/local && make -j && make install ` - ` -# Build and install ESMF libraries - && cd /tmp/bld ` +# Install ESMF +RUN cd /tmp ` && wget -c https://github.com/esmf-org/esmf/archive/ESMF_8_0_1.tar.gz ` && tar zxf ESMF_8_0_1.tar.gz ` && cd esmf-ESMF_8_0_1 ` - && make -j && make install ` - ` -# Cleanup - && cd /tmp && rm -rf /tmp/bld + && export ESMF_DIR=$(pwd) ` + && export ESMF_PREFIX=/usr ESMF_INSTALL_MODDIR=include ESMF_INSTALL_LIBDIR=lib ESMF_INSTALL_BINDIR=bin ` + && export ESMF_F90COMPILEOPTS_ENV="-fallow-argument-mismatch" ` + && make -j8 && make install ` + && cd / && rm -rvf ESMF_8_0_1.tar.gz esmf-ESMF_8_0_1 # Add user account -WORKDIR /home +RUN groupadd hpscterrsys ` + && useradd user -g hpscterrsys -m ` + && usermod -aG hpscterrsys user ` + && adduser user sudo ` + && printf "clm\nclm" | passwd user + +# Set default envs +RUN cd /home/user ` + && echo "export CC=$CC" >> .bash_profile ` + && echo "export FC=$FC" >> .bash_profile ` + && echo "export CXX=$CXX" >> .bash_profile ` + && echo "export USER=$(whoami)" >> .bash_profile ` + && echo "export CESMDATAROOT=/home/user/CESMDATAROOT" >> .bash_profile ` + && echo "export CCSMROOT=/home/user" >> .bash_profile ` + && echo "alias ll='ls -phAlv'" >> .bash_profile -RUN groupadd -g 1555 clm5docker ` - && useradd clmuser -g clm5docker` - && echo clm5 | passwd --stdin clmuser ` - && usermod -aG wheel clmuser ` - && rm /run/nologin ` - ` -# Set compiler and library paths for CLM5 - && echo "" >> /home/clmuser/.bash_profile ` - && echo "# Set compiler and library paths for CLM5" >> /home/clmuser/.bash_profile ` - && echo "export PATH=/usr/lib64/openmpi/bin:$PATH" >> /home/clmuser/.bash_profile >> /home/clmuser/.bash_profile ` - && echo "source /etc/profile.d/ncarg.sh" >> /home/clmuser/.bash_profile ` - ` -# Set CLM5 environment variables - && echo "" >> /home/clmuser/.bash_profile ` - && echo "# CLM5 environment variables" >> /home/clmuser/.bash_profile ` - && echo "" >> /home/clmuser/.bash_profile ` - && echo "export PROJECT=/p/project" >> /home/clmuser/.bash_profile ` - && echo "export SCRATCH=/p/scratch" >> /home/clmuser/.bash_profile ` - && echo "export BUDGET_ACCOUNTS=slts" >> /home/clmuser/.bash_profile ` - && echo "export CESMDATAROOT=/p/scratch/CESMDATAROOT" >> /home/clmuser/.bash_profile ` - && echo "export CSMDATA=\$CESMDATAROOT/inputdata" >> /home/clmuser/.bash_profile ` - ` -# Copy cime config files to home directory - && mv /tmp/.cime /home/clmuser/.cime +# .cime folder +RUN mkdir /home/user/.cime && cd /home/user/.cime ` + && wget https://raw.githubusercontent.com/HPSCTerrSys/containers/refs/heads/master/clm5/cime_config/config_compilers.xml ` + && wget https://raw.githubusercontent.com/HPSCTerrSys/containers/refs/heads/master/clm5/cime_config/config_machines.xml ` + && mkdir -p /home/user/CESMDATAROOT/inputdata ` + && chown -R user /home/user -USER clmuser -WORKDIR /home/clmuser +USER user +WORKDIR /home/user CMD ["/bin/bash","-l"] diff --git a/clm5/README.md b/clm5/README.md index 6bbef00..b7722da 100644 --- a/clm5/README.md +++ b/clm5/README.md @@ -3,15 +3,15 @@ 1. Build Docker image ```sh -$ IMG_VERSION="0.4" -$ docker build --tag hpscterrsys/clm5:latest --tag hpscterrsys/clm5:$IMG_VERSION . +IMG_VERSION="0.5" +podman build --tag hpscterrsys/clm5:latest --tag hpscterrsys/clm5:$IMG_VERSION . ``` 2. Commit image to DockerHub ```sh -$ docker login -$ docker push hpscterrsys/clm5:latest -$ docker push hpscterrsys/clm5:$IMG_VERSION -$ docker logout +podman login docker.io +podman push hpscterrsys/eclm:latest +podman push hpscterrsys/eclm:$IMG_VERSION +podman logout ``` diff --git a/clm5/cime_config/config_compilers.xml b/clm5/cime_config/config_compilers.xml index ef02ec1..f76c9cb 100644 --- a/clm5/cime_config/config_compilers.xml +++ b/clm5/cime_config/config_compilers.xml @@ -1,12 +1,12 @@ - + /usr /usr /usr - /usr/local + /usr - -I/usr/lib64/gfortran/modules + -I/usr/lib64/gfortran/modules -fallow-argument-mismatch -llapack -lblas diff --git a/clm5/cime_config/config_machines.xml b/clm5/cime_config/config_machines.xml index 277dd88..e654e2f 100644 --- a/clm5/cime_config/config_machines.xml +++ b/clm5/cime_config/config_machines.xml @@ -1,9 +1,9 @@ - + CLM5 Docker container - clm5-docker.* + .* LINUX gnu openmpi @@ -12,11 +12,11 @@ $ENV{CESMDATAROOT}/ForcingData $ENV{CESMDATAROOT}/Archive $ENV{CESMDATAROOT}/BaselineTests - $CCSMROOT/tools/cprnc/build/cprnc + $ENV{CESMDATAROOT}/tools/cprnc/build/cprnc make 8 none - kvrigor + HPSCTerrSys 8 8 From 1715c9dbfb8ad84bff7dc2ecf909ff583c3f066d Mon Sep 17 00:00:00 2001 From: kvrigor Date: Fri, 6 Feb 2026 17:47:12 +0100 Subject: [PATCH 4/9] Improved UX in eCLM container --- eclm/Dockerfile | 115 +++++++++++++++++++++++++++++++----------------- 1 file changed, 74 insertions(+), 41 deletions(-) diff --git a/eclm/Dockerfile b/eclm/Dockerfile index 0d88881..ce1e7cf 100644 --- a/eclm/Dockerfile +++ b/eclm/Dockerfile @@ -7,13 +7,17 @@ FROM ubuntu:24.04 # LABEL ... -# Download basic utilities and compilers from Ubuntu apt repo -RUN DEBIAN_FRONTEND=noninteractive apt-get update ` - && apt-get install -y sudo nano git wget tree cmake python3.12 ` - && apt-get install -y gfortran g++ openmpi-bin libopenmpi-dev ` - && apt-get install -y libxml++2.6-dev libhdf5-openmpi-dev libhdf5-openmpi-hl-fortran-100t64 hdf5-helpers liblapack-dev libblas-dev - +# Download compiler toolchain and libraries +RUN <> /home/user/.bash_profile ` - && echo "export FC=$FC" >> /home/user/.bash_profile ` - && echo "export CXX=$CXX" >> /home/user/.bash_profile ` - && echo "alias ll='ls -phAlv'" >> /home/user/.bash_profile +groupadd hpscterrsys +useradd user -g hpscterrsys -m +usermod -aG hpscterrsys user +adduser user sudo +printf "clm\nclm" | passwd user +EOF USER user WORKDIR /home/user +RUN <> .bash_profile +echo "export LD_LIBRARY_PATH=/usr/local/lib" >> .bash_profile +echo "export eCLM=$HOME/eCLM" >> .bash_profile +echo "export PATH=$PATH:$HOME/.local/bin" >> .bash_profile +echo "alias ll='ls -phAlv'" >> .bash_profile +cat <> .bash_profile +function bld_eclm() { + if [[ ! -d \$eCLM ]]; then + git clone https://github.com/HPSCTerrSys/eCLM.git \$eCLM + fi + if git -C \$eCLM status >/tmp/eclm_status 2>&1; then + if [[ \$1 == "-f" ]]; then rm -rf bld; fi + if [[ ! -f bld/CMakeCache.txt ]]; then + cmake -S \$eCLM/src -B bld + fi + cmake --build bld --parallel 8 + cmake --install bld --prefix=\$HOME/.local + pip install --user --break-system-packages \$eCLM/namelist_generator + else + echo "\$eCLM is not a valid eCLM repository." + echo " Failing command: git -C \$eCLM status" + echo " Error message: \$(cat /tmp/eclm_status)" + exit 1 + fi +} +eof +mkdir -vp .local/bin share +EOF + CMD ["/bin/bash","-l"] From b504391d634b2fce9db69ea827695f98666ec5e2 Mon Sep 17 00:00:00 2001 From: kvrigor Date: Mon, 30 Mar 2026 16:04:33 +0200 Subject: [PATCH 5/9] Removed non-root user This allows mounting directories from the host without encountering permission issues. Basically root user in a podman container == host user --- eclm/Dockerfile | 47 ++--------------------------------------------- 1 file changed, 2 insertions(+), 45 deletions(-) mode change 100644 => 100755 eclm/Dockerfile diff --git a/eclm/Dockerfile b/eclm/Dockerfile old mode 100644 new mode 100755 index ce1e7cf..8b3bf5a --- a/eclm/Dockerfile +++ b/eclm/Dockerfile @@ -11,10 +11,9 @@ FROM ubuntu:24.04 RUN <> .bash_profile -echo "export LD_LIBRARY_PATH=/usr/local/lib" >> .bash_profile -echo "export eCLM=$HOME/eCLM" >> .bash_profile -echo "export PATH=$PATH:$HOME/.local/bin" >> .bash_profile -echo "alias ll='ls -phAlv'" >> .bash_profile -cat <> .bash_profile -function bld_eclm() { - if [[ ! -d \$eCLM ]]; then - git clone https://github.com/HPSCTerrSys/eCLM.git \$eCLM - fi - if git -C \$eCLM status >/tmp/eclm_status 2>&1; then - if [[ \$1 == "-f" ]]; then rm -rf bld; fi - if [[ ! -f bld/CMakeCache.txt ]]; then - cmake -S \$eCLM/src -B bld - fi - cmake --build bld --parallel 8 - cmake --install bld --prefix=\$HOME/.local - pip install --user --break-system-packages \$eCLM/namelist_generator - else - echo "\$eCLM is not a valid eCLM repository." - echo " Failing command: git -C \$eCLM status" - echo " Error message: \$(cat /tmp/eclm_status)" - exit 1 - fi -} -eof -mkdir -vp .local/bin share -EOF - CMD ["/bin/bash","-l"] From 8456f0c3e16802f9c12076b71285958fe3a6a2ac Mon Sep 17 00:00:00 2001 From: kvrigor Date: Mon, 30 Mar 2026 17:20:43 +0200 Subject: [PATCH 6/9] Added env variables for build convenience --- eclm/Dockerfile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/eclm/Dockerfile b/eclm/Dockerfile index 8b3bf5a..5faa208 100755 --- a/eclm/Dockerfile +++ b/eclm/Dockerfile @@ -57,4 +57,17 @@ make install cd / && rm -rvf $TMP EOF +USER root +WORKDIR /root +RUN <> .bash_profile +echo "export OMPI_ALLOW_RUN_AS_ROOT=1" >> .bash_profile +echo "export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1" >> .bash_profile +echo "export PIP_BREAK_SYSTEM_PACKAGES=1" >> .bash_profile +echo "export CMAKE_INSTALL_PREFIX=/root/.local" >> .bash_profile +echo "export LD_LIBRARY_PATH=/usr/local/lib:/root/.local/lib" >> .bash_profile +echo "export PATH=${PATH}:/root/.local/bin" >> .bash_profile +echo "export SW=/root/.local" >> .bash_profile +mkdir -vp .local/{bin,lib} +EOF CMD ["/bin/bash","-l"] From b5a6b4e4f77cca28ee175c8e4ef4cf3a76c2cae1 Mon Sep 17 00:00:00 2001 From: kvrigor Date: Thu, 2 Apr 2026 16:01:05 +0200 Subject: [PATCH 7/9] Add dev versoin of eCLM image --- eclm/Dockerfile | 13 +------------ eclm/Dockerfile_dev | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 12 deletions(-) create mode 100755 eclm/Dockerfile_dev diff --git a/eclm/Dockerfile b/eclm/Dockerfile index 5faa208..437ac68 100755 --- a/eclm/Dockerfile +++ b/eclm/Dockerfile @@ -11,7 +11,7 @@ FROM ubuntu:24.04 RUN <> .bash_profile -echo "export OMPI_ALLOW_RUN_AS_ROOT=1" >> .bash_profile -echo "export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1" >> .bash_profile -echo "export PIP_BREAK_SYSTEM_PACKAGES=1" >> .bash_profile -echo "export CMAKE_INSTALL_PREFIX=/root/.local" >> .bash_profile -echo "export LD_LIBRARY_PATH=/usr/local/lib:/root/.local/lib" >> .bash_profile -echo "export PATH=${PATH}:/root/.local/bin" >> .bash_profile -echo "export SW=/root/.local" >> .bash_profile -mkdir -vp .local/{bin,lib} -EOF CMD ["/bin/bash","-l"] diff --git a/eclm/Dockerfile_dev b/eclm/Dockerfile_dev new file mode 100755 index 0000000..5660c82 --- /dev/null +++ b/eclm/Dockerfile_dev @@ -0,0 +1,32 @@ +# escape=` +FROM hpscterrsys/eclm:0.2 + +# +# TODO: Specify image metadata following OCI format spec: https://github.com/opencontainers/image-spec/blob/main/spec.md +# +# LABEL ... + + +# Install dev tools +RUN <> .bash_profile +echo "export OMPI_ALLOW_RUN_AS_ROOT=1" >> .bash_profile +echo "export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1" >> .bash_profile +echo "export PIP_BREAK_SYSTEM_PACKAGES=1" >> .bash_profile +echo "export CMAKE_INSTALL_PREFIX=/root/.local" >> .bash_profile +echo "export LD_LIBRARY_PATH=/usr/local/lib:/root/.local/lib" >> .bash_profile +echo "export PATH=${PATH}:/root/.local/bin" >> .bash_profile +echo "export SW=/root/.local" >> .bash_profile +echo "export EDITOR=vim" >> .bash_profile +mkdir -vp .local/{bin,lib} +EOF +CMD ["/bin/bash","-l"] From 2516ddd113116d1910a9e6e15ee907e844006141 Mon Sep 17 00:00:00 2001 From: kvrigor Date: Wed, 8 Apr 2026 12:02:03 +0200 Subject: [PATCH 8/9] Updated eCLM image/container setup recipe --- eclm/README.md | 80 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 73 insertions(+), 7 deletions(-) mode change 100644 => 100755 eclm/README.md diff --git a/eclm/README.md b/eclm/README.md old mode 100644 new mode 100755 index 6ddf039..1da58b7 --- a/eclm/README.md +++ b/eclm/README.md @@ -1,17 +1,83 @@ -## Manual build steps +# eCLM Docker Build Guide -1. Build Docker image +This guide requires [Podman](https://docs.podman.io/en/v4.6.1/index.html). If you're on Debian/Ubuntu, run ```sh -IMG_VERSION="0.2" -podman build --tag hpscterrsys/eclm:latest --tag hpscterrsys/eclm:$IMG_VERSION . +sudo apt update +sudo apt-get install -y podman ``` -2. Commit image to DockerHub +Otherwise, head over to the [Podman install guide](http://podman.io/docs/installation) and follow the instructions +specific to your system. + +## Building the eCLM container + +> [!NOTE] +> This section is only relevant for developers who have push access rights to the [HPSCTerrSys DockerHub](https://hub.docker.com/u/hpscterrsys). + +1. Build eCLM base image. ```sh -podman login docker.io +podman build --tag hpscterrsys/eclm:latest --tag hpscterrsys/eclm:0.2 . +``` + +2. Push eCLM base image to DockerHub. + +```sh +podman login --username $USER docker.io podman push hpscterrsys/eclm:latest -podman push hpscterrsys/eclm:$IMG_VERSION +podman push hpscterrsys/eclm:0.2 +``` + +3. Build eCLM dev image. + +```sh +podman build --tag hpscterrsys/eclm:latest-dev --tag hpscterrsys/eclm:0.2-dev -f Dockerfile_dev +``` + +4. Push eCLM dev image to DockerHub. + +```sh +podman push hpscterrsys/eclm:latest-dev +podman push hpscterrsys/eclm:0.2-dev podman logout ``` + +## Using the container image for local development + +First we configure file sharing between the host machine and the container image. Decide which +local folder you'd like to expose to the container image, then save its full path to `WORKDIR`: + +```sh +WORKDIR=/home/user/shared_folder +``` + +Then create a container named `eclm-dev`. + +```sh +podman run --name eclm-dev -it -v ${WORKDIR}:/root/$(basename ${WORKDIR}) hpscterrsys/eclm:latest-dev +``` + +The command above will also start `eclm-dev`. Verify that everything works by running these commands: + +```sh +root@e06d13d06436:~# pwd # $HOME directory +/root +root@e06d13d06436:~# ls # Should see your WORKDIR here +shared_folder +root@e06d13d06436:~# echo $CC $FC $CXX # Preset compilers in this dev image +mpicc mpif90 mpicxx +``` + +If the container has been stopped, simply run `podman start -ai eclm-dev` to restart it. `podman run` is only done once, *i.e.* during +container creation. It's also important to know these commands: + +- `podman ps -a`: list created containers +- `podman images`: list downloaded images +- `podman rm`: Delete existing container +- `podman rmi`: Delete existing image + +The mentioned `podman` commands are sufficient to manage your local `eclm-dev` image. For more information regarding `podman` usage, visit the [Podman tutorial](https://docs.podman.io/en/v4.6.1/Tutorials.html). + + + From da4bfde0516fed50d637bf4e7d6f8397b32e7b2a Mon Sep 17 00:00:00 2001 From: kvrigor Date: Thu, 9 Apr 2026 07:37:09 +0200 Subject: [PATCH 9/9] Revert CLM5 to v0.1 --- clm5/Dockerfile | 140 +++++++++++++++++--------- clm5/README.md | 12 +-- clm5/cime_config/config_compilers.xml | 6 +- clm5/cime_config/config_machines.xml | 8 +- 4 files changed, 104 insertions(+), 62 deletions(-) diff --git a/clm5/Dockerfile b/clm5/Dockerfile index 0c65256..d1ced2d 100644 --- a/clm5/Dockerfile +++ b/clm5/Dockerfile @@ -1,64 +1,106 @@ # escape=` -FROM ubuntu:22.04 +FROM centos:8.2.2004 -# -# TODO: Specify image metadata following OCI format spec: https://github.com/opencontainers/image-spec/blob/main/spec.md -# -# LABEL ... +# Image metadata for documentation purposes. Has no effect on docker build behavior. +LABEL ` + org.label-schema.schema-version="1.0" ` + org.label-schema.name="CLM5.0 Development Environment" ` + org.label-schema.version="0.4" ` + org.label-schema.vendor="IBG-3" ` + org.label-schema.license="GPLv2" ` + org.label-schema.build-date="20201111" ` + clm.version.major="5" ` + clm.env.compiler="GCC" ` + clm.env.compiler.version="8.3.1" ` + clm.env.mpi="OpenMPI" ` + clm.env.mpi.version="4.0.2-2" ` + clm.env.cmake.version="3.18" ` + clm.env.pnetcdf.version="1.12.1" ` + clm.env.netcdf-c.version="4.7.0" ` + clm.env.netcdf-fortran.version="4.5.2-3" ` + clm.env.esmf.version="8.0.1" +# Import cime config files to image +WORKDIR /tmp/.cime +COPY cime_config/* /tmp/.cime/ -# Download basic utilities and compilers from Ubuntu apt repo -RUN DEBIAN_FRONTEND=noninteractive apt-get update ` - && apt-get install -y sudo nano git wget tree cmake python3.10 ` - && apt-get install -y gcc-10 gfortran-10 g++-10 openmpi-bin libopenmpi-dev ` - && apt-get install -y libhdf5-openmpi-dev libhdf5-openmpi-hl-fortran-100 hdf5-helpers liblapack-dev libblas-dev ` - && apt-get install -y netcdf-bin libnetcdf-dev libnetcdff-dev libpnetcdf-dev nco - -RUN apt-get install -y libxml++2.6-dev libxml2-utils cpanminus ` +# Install required packages from base repo +RUN dnf update -y ` + && dnf group install -y "Development Tools" ` + && dnf install -y glibc-langpack-en libcurl-devel man-db man-pages passwd sudo vim wget which tree ` + perl-App-cpanminus python38 python38-pip ` + epel-release ` + && dnf config-manager --set-enabled PowerTools ` + ` +# Install required packages from EPEL and SCL repos + && dnf install -y hdf5-devel lapack-devel ncl nco netcdf-devel netcdf-fortran netcdf-fortran-devel openssl-devel openmpi openmpi-devel ` + && dnf clean all ` + ` +# misc + && ln -s /usr/bin/python3 /usr/bin/python ` && cpanm bigint && cpanm XML::LibXML -RUN ln -sf /usr/bin/python3 /usr/bin/python ` - && ln -sf /usr/bin/gcc-10 /usr/bin/gcc ` - && ln -sf /usr/bin/g++-10 /usr/bin/g++ ` - && ln -sf /usr/bin/gfortran-10 /usr/bin/gfortran - -ENV CC=mpicc FC=mpifort CXX=mpicxx +# Required envs for building libraries +ENV ESMF_DIR=/tmp/bld/esmf-ESMF_8_0_1 +ENV ESMF_INSTALL_PREFIX=/usr/local +ENV ESMF_INSTALL_MODDIR=include +ENV ESMF_INSTALL_LIBDIR=lib +ENV ESMF_INSTALL_BINDIR=bin +ENV PATH="/usr/lib64/openmpi/bin:${PATH}" -# Install ESMF -RUN cd /tmp ` +# Install CMake +RUN mkdir -vp /tmp/bld ` + && cd /tmp/bld ` + && wget -c https://github.com/Kitware/CMake/releases/download/v3.18.4/cmake-3.18.4.tar.gz ` + && tar zxf cmake-3.18.4.tar.gz && cd cmake-3.18.4 ` + && ./bootstrap && make && make install ` + ` +# PnetCDF + && cd /tmp/bld ` + && wget -c https://github.com/Parallel-NetCDF/PnetCDF/archive/checkpoint.1.12.1.tar.gz ` + && tar zxf checkpoint.1.12.1.tar.gz ` + && cd PnetCDF-checkpoint.1.12.1 ` + && autoreconf -i ` + && ./configure --prefix=/usr/local && make -j && make install ` + ` +# Build and install ESMF libraries + && cd /tmp/bld ` && wget -c https://github.com/esmf-org/esmf/archive/ESMF_8_0_1.tar.gz ` && tar zxf ESMF_8_0_1.tar.gz ` && cd esmf-ESMF_8_0_1 ` - && export ESMF_DIR=$(pwd) ` - && export ESMF_PREFIX=/usr ESMF_INSTALL_MODDIR=include ESMF_INSTALL_LIBDIR=lib ESMF_INSTALL_BINDIR=bin ` - && export ESMF_F90COMPILEOPTS_ENV="-fallow-argument-mismatch" ` - && make -j8 && make install ` - && cd / && rm -rvf ESMF_8_0_1.tar.gz esmf-ESMF_8_0_1 + && make -j && make install ` + ` +# Cleanup + && cd /tmp && rm -rf /tmp/bld # Add user account -RUN groupadd hpscterrsys ` - && useradd user -g hpscterrsys -m ` - && usermod -aG hpscterrsys user ` - && adduser user sudo ` - && printf "clm\nclm" | passwd user - -# Set default envs -RUN cd /home/user ` - && echo "export CC=$CC" >> .bash_profile ` - && echo "export FC=$FC" >> .bash_profile ` - && echo "export CXX=$CXX" >> .bash_profile ` - && echo "export USER=$(whoami)" >> .bash_profile ` - && echo "export CESMDATAROOT=/home/user/CESMDATAROOT" >> .bash_profile ` - && echo "export CCSMROOT=/home/user" >> .bash_profile ` - && echo "alias ll='ls -phAlv'" >> .bash_profile +WORKDIR /home -# .cime folder -RUN mkdir /home/user/.cime && cd /home/user/.cime ` - && wget https://raw.githubusercontent.com/HPSCTerrSys/containers/refs/heads/master/clm5/cime_config/config_compilers.xml ` - && wget https://raw.githubusercontent.com/HPSCTerrSys/containers/refs/heads/master/clm5/cime_config/config_machines.xml ` - && mkdir -p /home/user/CESMDATAROOT/inputdata ` - && chown -R user /home/user +RUN groupadd -g 1555 clm5docker ` + && useradd clmuser -g clm5docker` + && echo clm5 | passwd --stdin clmuser ` + && usermod -aG wheel clmuser ` + && rm /run/nologin ` + ` +# Set compiler and library paths for CLM5 + && echo "" >> /home/clmuser/.bash_profile ` + && echo "# Set compiler and library paths for CLM5" >> /home/clmuser/.bash_profile ` + && echo "export PATH=/usr/lib64/openmpi/bin:$PATH" >> /home/clmuser/.bash_profile >> /home/clmuser/.bash_profile ` + && echo "source /etc/profile.d/ncarg.sh" >> /home/clmuser/.bash_profile ` + ` +# Set CLM5 environment variables + && echo "" >> /home/clmuser/.bash_profile ` + && echo "# CLM5 environment variables" >> /home/clmuser/.bash_profile ` + && echo "" >> /home/clmuser/.bash_profile ` + && echo "export PROJECT=/p/project" >> /home/clmuser/.bash_profile ` + && echo "export SCRATCH=/p/scratch" >> /home/clmuser/.bash_profile ` + && echo "export BUDGET_ACCOUNTS=slts" >> /home/clmuser/.bash_profile ` + && echo "export CESMDATAROOT=/p/scratch/CESMDATAROOT" >> /home/clmuser/.bash_profile ` + && echo "export CSMDATA=\$CESMDATAROOT/inputdata" >> /home/clmuser/.bash_profile ` + ` +# Copy cime config files to home directory + && mv /tmp/.cime /home/clmuser/.cime -USER user -WORKDIR /home/user +USER clmuser +WORKDIR /home/clmuser CMD ["/bin/bash","-l"] diff --git a/clm5/README.md b/clm5/README.md index b7722da..6bbef00 100644 --- a/clm5/README.md +++ b/clm5/README.md @@ -3,15 +3,15 @@ 1. Build Docker image ```sh -IMG_VERSION="0.5" -podman build --tag hpscterrsys/clm5:latest --tag hpscterrsys/clm5:$IMG_VERSION . +$ IMG_VERSION="0.4" +$ docker build --tag hpscterrsys/clm5:latest --tag hpscterrsys/clm5:$IMG_VERSION . ``` 2. Commit image to DockerHub ```sh -podman login docker.io -podman push hpscterrsys/eclm:latest -podman push hpscterrsys/eclm:$IMG_VERSION -podman logout +$ docker login +$ docker push hpscterrsys/clm5:latest +$ docker push hpscterrsys/clm5:$IMG_VERSION +$ docker logout ``` diff --git a/clm5/cime_config/config_compilers.xml b/clm5/cime_config/config_compilers.xml index f76c9cb..ef02ec1 100644 --- a/clm5/cime_config/config_compilers.xml +++ b/clm5/cime_config/config_compilers.xml @@ -1,12 +1,12 @@ - + /usr /usr /usr - /usr + /usr/local - -I/usr/lib64/gfortran/modules -fallow-argument-mismatch + -I/usr/lib64/gfortran/modules -llapack -lblas diff --git a/clm5/cime_config/config_machines.xml b/clm5/cime_config/config_machines.xml index e654e2f..277dd88 100644 --- a/clm5/cime_config/config_machines.xml +++ b/clm5/cime_config/config_machines.xml @@ -1,9 +1,9 @@ - + CLM5 Docker container - .* + clm5-docker.* LINUX gnu openmpi @@ -12,11 +12,11 @@ $ENV{CESMDATAROOT}/ForcingData $ENV{CESMDATAROOT}/Archive $ENV{CESMDATAROOT}/BaselineTests - $ENV{CESMDATAROOT}/tools/cprnc/build/cprnc + $CCSMROOT/tools/cprnc/build/cprnc make 8 none - HPSCTerrSys + kvrigor 8 8