Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Run `docker pull <repository>:<tag>` 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
Expand Down
115 changes: 55 additions & 60 deletions eclm/Dockerfile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,67 +1,62 @@
# 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 compiler toolchain and libraries
RUN <<EOF
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y sudo nano git wget tree cmake python3.12 pip nco
apt-get install -y gfortran g++ openmpi-bin libopenmpi-dev liblapack-dev libblas-dev
apt-get install -y libxml++2.6-dev libhdf5-openmpi-dev libhdf5-openmpi-hl-fortran-100t64 hdf5-helpers
EOF

# Build prep
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

RUN <<EOF
# Install netCDF
mkdir -p $TMP && 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
EOF

RUN <<EOF
# Install netCDF Fortran
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
EOF

RUN <<EOF
# 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 `
&& autoreconf -i `
&& ./configure --prefix=/usr/local && make -j && make install `
&& cd / && rm -rf /tmp/bld
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=${INSTALL_PREFIX}
make install
cd / && rm -rvf $TMP
EOF

# Add user account
RUN groupadd -g 1555 clm5docker `
&& useradd clmuser -g clm5docker`
&& echo clm5 | passwd --stdin clmuser `
&& usermod -aG wheel clmuser `
&& rm /run/nologin `
`
# 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
USER root
WORKDIR /root
CMD ["/bin/bash","-l"]
32 changes: 32 additions & 0 deletions eclm/Dockerfile_dev
Original file line number Diff line number Diff line change
@@ -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 <<EOF
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y vim gdb
EOF

# Dev environment presets
USER root
WORKDIR /root
RUN <<EOF
echo "export CC=mpicc FC=mpif90 CXX=mpicxx" >> .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"]
84 changes: 75 additions & 9 deletions eclm/README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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.1"
docker 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 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: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
docker login
docker push hpscterrsys/eclm:latest
docker push hpscterrsys/eclm:$IMG_VERSION
docker logout
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).