From 6d46d5e5f9ac4e5dc9f1425597ac72f2c585aadc Mon Sep 17 00:00:00 2001 From: Naser Mahfouz Date: Sat, 28 Sep 2024 15:15:28 -0400 Subject: [PATCH] standalone-ghci --- .github/workflows/standalone-ghci.yaml | 80 +++++++++++++++++ standalone-ghci/Dockerfile | 116 +++++++++++++++++++++++++ standalone-ghci/readme | 7 ++ 3 files changed, 203 insertions(+) create mode 100644 .github/workflows/standalone-ghci.yaml create mode 100644 standalone-ghci/Dockerfile create mode 100644 standalone-ghci/readme diff --git a/.github/workflows/standalone-ghci.yaml b/.github/workflows/standalone-ghci.yaml new file mode 100644 index 0000000..7b9f66a --- /dev/null +++ b/.github/workflows/standalone-ghci.yaml @@ -0,0 +1,80 @@ +name: ghci + +on: + pull_request: + branches: [ main ] + paths: + - 'standalone-ghci/**' + - '.github/workflows/standalone-ghci.yaml' + push: + branches: [ main ] + paths: + - 'standalone-ghci/**' + - '.github/workflows/standalone-ghci.yaml' + tags: + - 'standalone-ghci-*' + +env: + GCC_VERSION: "11.4.0" + MPICH_VERSION: "4.2.1" + SZIP_VERSION: "2.1.1" + HDF5_VERSION: "1.12.3" + NETCDFC_VERSION: "4.9.2" + NETCDFCXX_VERSION: "4.2" + NETCDFFORTRAN_VERSION: "4.6.1" + PNETCDF_VERSION: "1.12.1" + +jobs: + ocis: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + id-token: write + + steps: + - + name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + show-progress: false + persist-credentials: false + - + name: GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/${{ github.repository }}-standalone-ghci + - + name: QEMU + uses: docker/setup-qemu-action@v3 + - + name: Buildx + uses: docker/setup-buildx-action@v3 + - + name: Push + uses: docker/build-push-action@v6 + with: + context: standalone-ghci/ + file: standalone-ghci/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + GCC_VERSION=${{ env.GCC_VERSION }} + MPICH_VERSION=${{ env.MPICH_VERSION }} + SZIP_VERSION=${{ env.SZIP_VERSION }} + HDF5_VERSION=${{ env.HDF5_VERSION }} + NETCDFC_VERSION=${{ env.NETCDFC_VERSION }} + NETCDFCXX_VERSION=${{ env.NETCDFCXX_VERSION }} + NETCDFFORTRAN_VERSION=${{ env.NETCDFFORTRAN_VERSION }} + PNETCDF_VERSION=${{ env.PNETCDF_VERSION }} diff --git a/standalone-ghci/Dockerfile b/standalone-ghci/Dockerfile new file mode 100644 index 0000000..7b3be3c --- /dev/null +++ b/standalone-ghci/Dockerfile @@ -0,0 +1,116 @@ +FROM ghcr.io/e3sm-project/containers-inputdata-files-standalone:main + +ARG GCC_VERSION=11.4.0 +ARG MPICH_VERSION=4.2.1 +ARG SZIP_VERSION=2.1.1 +ARG HDF5_VERSION=1.12.3 +ARG NETCDFC_VERSION=4.9.2 +ARG NETCDFCXX_VERSION=4.2 +ARG NETCDFFORTRAN_VERSION=4.6.1 +ARG PNETCDF_VERSION=1.12.1 + +ENV GCC_VERSION=${GCC_VERSION} +ENV MPICH_VERSION=${MPICH_VERSION} +ENV SZIP_VERSION=${SZIP_VERSION} +ENV HDF5_VERSION=${HDF5_VERSION} +ENV NETCDFC_VERSION=${NETCDFC_VERSION} +ENV NETCDFCXX_VERSION=${NETCDFCXX_VERSION} +ENV NETCDFFORTRAN_VERSION=${NETCDFFORTRAN_VERSION} +ENV PNETCDF_VERSION=${PNETCDF_VERSION} + +RUN apt-get update +RUN apt-get -y upgrade +RUN apt-get -y remove cmake +RUN apt-get -y install software-properties-common +RUN add-apt-repository universe +RUN apt-get update && apt-get -y install \ + locales csh m4 libcurl4-openssl-dev \ + libz-dev gcc g++ gfortran liblapack-dev make git \ + git wget subversion libxml2-dev libxml2-utils libxml-libxml-perl \ + libswitch-perl build-essential checkinstall zlib1g-dev libssl-dev \ + python3-distutils python-is-python3 python3-pip python3-full + +RUN python -m pip install netcdf4 pyyaml psutil pylint nanobind + +RUN python -m pip cache purge +RUN apt-get -y autoremove + +# TODO: move to env file (spack.yaml)? +RUN mkdir -p /opt/spack-environment \ +&& (echo "spack:" \ +&& echo " " \ +&& echo " definitions:" \ +&& echo " - compilers: [gcc@${GCC_VERSION}]" \ +&& echo " - mpis: [mpich@${MPICH_VERSION}]" \ +&& echo " - mpipkgs:" \ +&& echo " - hdf5@${HDF5_VERSION}" \ +&& echo " - netcdf-c@${NETCDFC_VERSION}" \ +&& echo " - netcdf-cxx@${NETCDFCXX_VERSION}" \ +&& echo " - netcdf-fortran@${NETCDFFORTRAN_VERSION}" \ +&& echo " - parallel-netcdf@${PNETCDF_VERSION}" \ +&& echo " - othpkgs:" \ +&& echo " - cmake" \ +&& echo " - cprnc" \ +&& echo " - yaml-cpp" \ +&& echo " - fmt" \ +&& echo " - spdlog" \ +&& echo " " \ +&& echo " specs:" \ +&& echo " - szip" \ +&& echo " - matrix:" \ +&& echo " - [\$mpis]" \ +&& echo " - [\$%compilers]" \ +&& echo " - matrix:" \ +&& echo " - [\$othpkgs]" \ +&& echo " - [\$%compilers]" \ +&& echo " - matrix:" \ +&& echo " - [\$mpipkgs]" \ +&& echo " - [\$^mpis]" \ +&& echo " - [\$%compilers]" \ +&& echo " " \ +&& echo " concretizer:" \ +&& echo " unify: true" \ +&& echo " " \ +&& echo " config:" \ +&& echo " install_tree: /opt/software" \ +&& echo " " \ +&& echo " view: /usr/local/packages" \ +&& echo "") > /opt/spack-environment/spack.yaml + +# TODO: do these intervene with each other? +# https://cache.spack.io/tag/v0.22.2/ +RUN spack mirror add v0.22.2 https://binaries.spack.io/v0.22.2 +RUN spack buildcache keys --install --trust +# https://cache.spack.io/tag/v0.22.1/?stack=e4s +RUN spack mirror add v0.22.2-e4s https://binaries.spack.io/v0.22.2/e4s +RUN spack buildcache keys --install --trust +# https://cache.spack.io/tag/v0.22.2/?stack=root# +RUN spack mirror add v0.22.2-root https://binaries.spack.io/v0.22.2/root +RUN spack buildcache keys --install --trust + +# TODO: add e4s inventory when they support ubuntu 22.04+ +# # https://oaciss.uoregon.edu/e4s/inventory.html +# RUN spack mirror add E4S-24.0 https://cache.e4s.io/24.0 +# RUN spack buildcache keys -it +# RUN spack mirror add E4S https://cache.e4s.io +# RUN spack buildcache keys -it + +RUN cd /opt/spack-environment && spack env activate . && spack install --fail-fast && spack gc -y + +RUN cd /opt/spack-environment && \ + spack env activate --sh -d . >> /etc/profile.d/z10_spack_environment.sh + +ENV USER=ghciocitester + +RUN git config --global user.email "${USER}@${USER}.${USER}" +RUN git config --global user.name "${USER}" + +ARG DEBIAN_FRONTEND=noninteractive +ENV TZ=America/Los_Angeles + +ENV LANGUAGE=en_US:en \ + LANG=en_US.UTF-8 + +# TODO: maybe add a test here or in the workflow? + +ENTRYPOINT ["/bin/bash", "--rcfile", "/etc/profile", "-l"] diff --git a/standalone-ghci/readme b/standalone-ghci/readme new file mode 100644 index 0000000..32a1121 --- /dev/null +++ b/standalone-ghci/readme @@ -0,0 +1,7 @@ +The standalone-ghci container is mainly for testing eamxx standalone on github actions + +Design notes +- the container is based on ghcr.io/e3sm-project/containers-inputdata-files-standalone:main +- the container relies on binary cache to accelerate builds +- the container is based on gcc 11, native to ubuntu 22.04 (jammy) +- the container has mpich 3.4.3, to ensure compatibility with craympich