diff --git a/configs/sites/tier1/container/Dockerfile.gcc b/configs/sites/tier1/container/Dockerfile.gcc new file mode 100644 index 000000000..917527d7c --- /dev/null +++ b/configs/sites/tier1/container/Dockerfile.gcc @@ -0,0 +1,138 @@ +# Spack-Stack Container Build for tier1/container GCC site +# See the README.md for building instructions. + +## ---------- build base container used by builder and runtime ---------- +FROM ubuntu:24.04 AS ubuntu_base + +ARG BUILD_JOBS=4 +ARG SPACK_STACK_TEMPLATE=unified-dev + +SHELL ["/bin/bash", "-c"] + + +ENV DEBIAN_FRONTEND=noninteractive \ + TZ=Etc/UTC \ + LANGUAGE=en_US.UTF-8 \ + LANG=en_US.UTF-8 \ + LC_ALL=en_US.UTF-8 \ + COMPILER=gcc + +# Install core packages. +RUN set -euo pipefail; \ + apt-get -yqq update && \ + apt-get -yqq upgrade && \ + apt-get -yqq install --no-install-recommends \ + # Core build tools. + build-essential \ + gcc-13 \ + gcc++-13 \ + gfortran-13 \ + cpp-13 \ + make \ + llvm-14 \ + autoconf \ + # External dependencies. + libcurl4-openssl-dev \ + libmysqlclient-dev \ + libqt5svg5-dev \ + qt5-qmake \ + qt5dxcb-plugin \ + qtbase5-dev \ + zstd \ + # Shell tools, source retrieval and networking. + sed \ + file \ + less \ + bzip2 \ + unzip \ + ca-certificates \ + curl \ + git \ + git-lfs \ + gpg \ + environment-modules \ + tcl \ + tcl-dev \ + vim \ + wget \ + nano \ + locales && \ + locale-gen en_US.UTF-8 && \ + # Update alternatives for compilers and tools + update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 100 && \ + update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100 && \ + update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-13 100 && \ + update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-14 100 && \ + rm -rf /var/lib/apt/lists/* + + +## ---------- build spack-stack environment ---------- +FROM ubuntu_base AS builder + +ENV SPACK_STACK_DIR=/opt/spack-stack \ + SPACK_ROOT=/opt/spack-stack/spack + + +# Copy spack-stack from build context. Note the build context must be the +# root of the spack-stack repository (see the README.md for details). +COPY . ${SPACK_STACK_DIR} + +# Create spack-stack environment +WORKDIR /opt/spack-stack +RUN mkdir -p /tmp/spack-stack && \ + source setup.sh && \ + spack stack create env \ + --site container \ + --template ${SPACK_STACK_TEMPLATE} \ + --name container \ + --prefix /opt/spack-software/ \ + --compiler $COMPILER && \ + cd ${SPACK_STACK_DIR}/envs/container && \ + spack env activate . && \ + spack concretize 2>&1 | tee log.concretize && \ + spack install --fail-fast -j ${BUILD_JOBS} 2>&1 | tee log.install && \ + spack module tcl refresh -y && \ + spack stack setup-meta-modules && \ + # Save output of spack find. + spack find 2>&1 | tee /opt/spack-software/spack_find.out && \ + spack clean --all + +## ---------- Create runtime container ---------- +FROM ubuntu_base AS runtime + +COPY --from=builder /opt/spack-software/ /opt/spack-software/ + +ENV CC=gcc \ + CXX=g++ \ + FC=gfortran + +# Container-wide rc script with compiler defaults, MPI policy, module paths. +RUN echo "ulimit -s unlimited" > /etc/spack_container_rc.sh \ + && echo "ulimit -v unlimited" >> /etc/spack_container_rc.sh \ + && echo "export CC=gcc" >> /etc/spack_container_rc.sh \ + && echo "export CXX=g++" >> /etc/spack_container_rc.sh \ + && echo "export FC=gfortran" >> /etc/spack_container_rc.sh \ + && echo "# OpenMPI settings for running as root and oversubscription." >> /etc/spack_container_rc.sh \ + && echo "export OMPI_ALLOW_RUN_AS_ROOT=1" >> /etc/spack_container_rc.sh \ + && echo "export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1" >> /etc/spack_container_rc.sh \ + && echo "export PRTE_MCA_rmaps_default_mapping_policy=:oversubscribe" >> /etc/spack_container_rc.sh \ + && echo "# TCL module path for the spack-stack environment." >> /etc/spack_container_rc.sh \ + && echo "source /etc/profile.d/modules.sh" >> /etc/spack_container_rc.sh \ + && echo "module use /opt/spack-software/modules/Core" >> /etc/spack_container_rc.sh \ + && echo "source /etc/spack_container_rc.sh" >> /etc/bash.bashrc \ + && printf "[credential]\n helper = cache --timeout=7200\n" >> /root/.gitconfig \ + && mkdir /root/.pmix \ + && echo "rmaps_default_mapping_policy=:oversubscribe" >> /root/.pmix/mca-params.conf + +# Nonroot user for MPI +RUN useradd -U -k /etc/skel -s /bin/bash -d /home/nonroot -m nonroot --uid 43891 \ + && echo "ulimit -s unlimited" >> /home/nonroot/.bashrc \ + && echo "ulimit -v unlimited" >> /home/nonroot/.bashrc \ + && printf "[credential]\n helper = cache --timeout=7200\n" >> /home/nonroot/.gitconfig \ + && mkdir /home/nonroot/.pmix \ + && chown -R nonroot:nonroot /home/nonroot/.gitconfig /home/nonroot/.pmix + +# Ensure the container rc is run by non-login shells too. +ENV BASH_ENV=/etc/spack_container_rc.sh + +CMD ["/bin/bash"] diff --git a/configs/sites/tier1/container/Dockerfile.oneapi b/configs/sites/tier1/container/Dockerfile.oneapi new file mode 100644 index 000000000..c22058808 --- /dev/null +++ b/configs/sites/tier1/container/Dockerfile.oneapi @@ -0,0 +1,151 @@ +# Spack-Stack Container Build for tier1/container Intel oneapi site +# See the README.md for building instructions. + +## ---------- build base container used by builder and runtime ---------- +FROM ubuntu:24.04 AS ubuntu_base + +ARG BUILD_JOBS=4 +ARG SPACK_STACK_TEMPLATE=unified-dev + +SHELL ["/bin/bash", "-c"] + + +ENV DEBIAN_FRONTEND=noninteractive \ + TZ=Etc/UTC \ + LANGUAGE=en_US.UTF-8 \ + LANG=en_US.UTF-8 \ + LC_ALL=en_US.UTF-8 \ + COMPILER=intel + +# Install core packages. +RUN set -euo pipefail; \ + apt-get -yqq update && \ + apt-get -yqq upgrade && \ + apt-get -yqq install --no-install-recommends \ + # Core build tools. + build-essential \ + gcc-13 \ + gcc++-13 \ + gfortran-13 \ + cpp-13 \ + make \ + llvm-14 \ + autoconf \ + # External dependencies. + libcurl4-openssl-dev \ + libmysqlclient-dev \ + libqt5svg5-dev \ + qt5-qmake \ + qt5dxcb-plugin \ + qtbase5-dev \ + zstd \ + # Shell tools, source retrieval and networking. + sed \ + file \ + less \ + bzip2 \ + unzip \ + ca-certificates \ + curl \ + git \ + git-lfs \ + gpg \ + environment-modules \ + tcl \ + tcl-dev \ + vim \ + wget \ + nano \ + locales && \ + locale-gen en_US.UTF-8 && \ + # Update alternatives for compilers and tools + update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 100 && \ + update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 100 && \ + update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-13 100 && \ + update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-14 100 && \ + # Install the intel + apt install -y apt-utils gpg && \ + wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \ + | gpg --dearmor \ + | tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null && \ + echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" \ + | tee /etc/apt/sources.list.d/oneAPI.list && \ + apt update && \ + apt install -y \ + intel-oneapi-compiler-dpcpp-cpp-2025.3 \ + intel-oneapi-compiler-fortran-2025.3 \ + intel-oneapi-mpi-devel-2021.17 \ + intel-oneapi-tbb-devel-2022.3 \ + intel-oneapi-mkl-devel-2025.3 && \ + /opt/intel/oneapi/modulefiles-setup.sh --output-dir=/opt/intel/oneapi/modulefiles && \ + echo "source /etc/profile.d/modules.sh && module use /opt/intel/oneapi/modulefiles" > /etc/profile.d/z01_oneapi_modules.sh && \ + rm -rf /var/lib/apt/lists/* + + +## ---------- build spack-stack environment ---------- +FROM ubuntu_base AS builder + +ENV SPACK_STACK_DIR=/opt/spack-stack \ + SPACK_ROOT=/opt/spack-stack/spack + + +# Copy spack-stack from build context. Note the build context must be the +# root of the spack-stack repository (see the README.md for details). +COPY . ${SPACK_STACK_DIR} + +# Create spack-stack environment +WORKDIR /opt/spack-stack +RUN mkdir -p /tmp/spack-stack && \ + source setup.sh && \ + spack stack create env \ + --site container \ + --template ${SPACK_STACK_TEMPLATE} \ + --name container \ + --prefix /opt/spack-software/ \ + --compiler oneapi && \ + cd ${SPACK_STACK_DIR}/envs/container && \ + spack env activate . && \ + spack concretize 2>&1 | tee log.concretize && \ + spack install --fail-fast -j ${BUILD_JOBS} 2>&1 | tee log.install && \ + spack module tcl refresh -y && \ + spack stack setup-meta-modules && \ + # Save output of spack find. + spack find 2>&1 | tee /opt/spack-software/spack_find.out && \ + spack clean --all + +## ---------- Create runtime container ---------- +FROM ubuntu_base AS runtime + +COPY --from=builder /opt/spack-software/ /opt/spack-software/ + +ENV CC=icx \ + CXX=icpx \ + FC=ifx + +# Container-wide rc script with compiler defaults, MPI policy, module paths. +RUN echo "ulimit -s unlimited" > /etc/spack_container_rc.sh \ + && echo "ulimit -v unlimited" >> /etc/spack_container_rc.sh \ + && echo "export CC=icx" >> /etc/spack_container_rc.sh \ + && echo "export CXX=icpx" >> /etc/spack_container_rc.sh \ + && echo "export FC=ifx" >> /etc/spack_container_rc.sh \ + && echo "# TCL module path for the spack-stack environment." >> /etc/spack_container_rc.sh \ + && echo "export MODULEPATH=/opt/spack-software/modules/Core" >> /etc/spack_container_rc.sh \ + && echo "source /etc/profile.d/modules.sh" >> /etc/spack_container_rc.sh \ + && echo "module use /opt/intel/oneapi/modulefiles" >> /etc/spack_container_rc.sh \ + && echo "module use /opt/spack-software/modules/Core" >> /etc/spack_container_rc.sh \ + && echo "source /etc/spack_container_rc.sh" >> /etc/bash.bashrc \ + && printf "[credential]\n helper = cache --timeout=7200\n" >> /root/.gitconfig \ + && mkdir /root/.pmix + +# Nonroot user for MPI +RUN useradd -U -k /etc/skel -s /bin/bash -d /home/nonroot -m nonroot --uid 43891 \ + && echo "ulimit -s unlimited" >> /home/nonroot/.bashrc \ + && echo "ulimit -v unlimited" >> /home/nonroot/.bashrc \ + && printf "[credential]\n helper = cache --timeout=7200\n" >> /home/nonroot/.gitconfig \ + && mkdir /home/nonroot/.pmix \ + && chown -R nonroot:nonroot /home/nonroot/.gitconfig /home/nonroot/.pmix + +# Ensure the container rc is run by non-login shells too. +ENV BASH_ENV=/etc/spack_container_rc.sh + +CMD ["/bin/bash"] diff --git a/configs/sites/tier1/container/README.md b/configs/sites/tier1/container/README.md new file mode 100644 index 000000000..c388bd8fa --- /dev/null +++ b/configs/sites/tier1/container/README.md @@ -0,0 +1,37 @@ +# Container Site + +This site config is used to build the official Spack-stack containers. This new tier-1 container site superceedes the legacy spack-based container builds and orients the container builder around common configs and a common site definition. The motivation for this site is to have our shared containers more closely match sites with loadable modules and developer tools-pre installed. + + +# Building + +This container is not a typical site config and is installed slightly differently to accomodate the use of a dockerfile. Please follow the instructions here to build it. + +## Prerequisites +- Docker +- At least 100 GB of disk space for the build +- Sufficient RAM (8GB+ recommended) + +## Quick Build + +The build context is the spack-stack repository root. The Dockerfile +copies the entire local checkout (including the submodules) into +the image, so any local changes to configs, templates, or spack-ext +are automatically reflected in the container. + +```bash +docker build \ + -t spack-stack-gcc:local \ + -f "$(git rev-parse --show-toplevel)/configs/sites/tier1/container/Dockerfile.gcc" \ + --build-arg SPACK_STACK_TEMPLATE=unified-dev \ + --build-arg BUILD_JOBS=10 \ + "$(git rev-parse --show-toplevel)" 2>&1 | tee ${HOME}/log.docker_gcc + + +docker build \ + -t spack-stack-oneapi:local \ + -f "$(git rev-parse --show-toplevel)/configs/sites/tier1/container/Dockerfile.oneapi" \ + --build-arg SPACK_STACK_TEMPLATE=unified-dev \ + --build-arg BUILD_JOBS=10 \ + "$(git rev-parse --show-toplevel)" 2>&1 | tee ${HOME}/log.docker_oneapi +``` diff --git a/configs/sites/tier1/container/config.yaml b/configs/sites/tier1/container/config.yaml new file mode 100644 index 000000000..52ecf712a --- /dev/null +++ b/configs/sites/tier1/container/config.yaml @@ -0,0 +1,9 @@ +config: + build_jobs: 10 + + # Container-specific paths for build and staging areas. + # Use /tmp for transient build data (not preserved in final image). + build_stage: /tmp/spack-stack/cache/build_stage + test_stage: /tmp/spack-stack/cache/test_stage + source_cache: /tmp/spack-stack/cache/source_cache + misc_cache: /tmp/spack-stack/cache/misc_cache diff --git a/configs/sites/tier1/container/modules.yaml b/configs/sites/tier1/container/modules.yaml new file mode 100644 index 000000000..b134d3669 --- /dev/null +++ b/configs/sites/tier1/container/modules.yaml @@ -0,0 +1,7 @@ +modules: + default: + enable:: + - tcl + tcl: + include: + - python diff --git a/configs/sites/tier1/container/packages.yaml b/configs/sites/tier1/container/packages.yaml new file mode 100644 index 000000000..af5a307f5 --- /dev/null +++ b/configs/sites/tier1/container/packages.yaml @@ -0,0 +1,58 @@ +packages: + all: + target: [core2] + met: + variants: +python +grib2 +graphics +lidar2nc +modis + # System packages installed during the container build. + grep: + externals: + - spec: grep@3.11 + prefix: /usr + findutils: + externals: + - spec: findutils@4.9.0 + prefix: /usr + coreutils: + externals: + - spec: coreutils@9.4 + prefix: /usr + autoconf: + externals: + - spec: autoconf@2.71 + prefix: /usr + diffutils: + buildable: false + externals: + - spec: diffutils@3.10 + prefix: /usr + git: + buildable: false + externals: + - spec: git@2.43.0~tcltk + prefix: /usr + git-lfs: + buildable: false + externals: + - spec: git-lfs@3.4.1 + prefix: /usr + llvm: + buildable: false + externals: + - spec: llvm@14.0.6 + prefix: /usr + qt: + buildable: false + externals: + - spec: qt@5.15.3 + prefix: /usr + version: [5.15.3] + wget: + buildable: false + externals: + - spec: wget@1.21.4 + prefix: /usr + perl: + buildable: false + externals: + - spec: perl@5.38.2 + prefix: /usr \ No newline at end of file diff --git a/configs/sites/tier1/container/packages_gcc.yaml b/configs/sites/tier1/container/packages_gcc.yaml new file mode 100644 index 000000000..d17749d31 --- /dev/null +++ b/configs/sites/tier1/container/packages_gcc.yaml @@ -0,0 +1,18 @@ +packages: + all: + prefer: + - '%gcc' + providers: + mpi: [openmpi@5.0.8] + mpi: + require: [openmpi@5.0.8] + gcc: + externals: + - spec: gcc@13.3.0 languages:='c,c++,fortran' + prefix: /usr + extra_attributes: + compilers: + c: /usr/bin/gcc + cxx: /usr/bin/g++ + fortran: /usr/bin/gfortran + buildable: false diff --git a/configs/sites/tier1/container/packages_oneapi.yaml b/configs/sites/tier1/container/packages_oneapi.yaml new file mode 100644 index 000000000..44c1482c9 --- /dev/null +++ b/configs/sites/tier1/container/packages_oneapi.yaml @@ -0,0 +1,65 @@ +packages: + all: + prefer: + - '%oneapi' + providers: + mpi: [intel-oneapi-mpi@2021.17] + mpi: + require: [intel-oneapi-mpi@2021.17] + # Compilers and meta packages. + intel-oneapi-compilers: + buildable: false + externals: + - spec: intel-oneapi-compilers@2025.3.0 + prefix: /opt/intel/oneapi + modules: + - umf/1.0.2 + - tbb/2022.3 + - compiler-rt/2025.3.0 + - compiler/2025.3.0 + extra_attributes: + compilers: + c: /opt/intel/oneapi/compiler/2025.3/bin/icx + cxx: /opt/intel/oneapi/compiler/2025.3/bin/icpx + fortran: /opt/intel/oneapi/compiler/2025.3/bin/ifx + gcc: + externals: + - spec: gcc@13.3.0 languages:='c,c++,fortran' + prefix: /usr + extra_attributes: + compilers: + c: /usr/bin/gcc + cxx: /usr/bin/g++ + fortran: /usr/bin/gfortran + buildable: false + intel-oneapi-mkl: + buildable: false + externals: + - spec: intel-oneapi-mkl@2025.3 + prefix: /opt/intel/oneapi + modules: + - mkl/2025.3 + intel-oneapi-mpi: + buildable: false + externals: + - spec: intel-oneapi-mpi@2021.17 + modules: + - mpi/2021.17 + prefix: /opt/intel/oneapi + intel-oneapi-tbb: + buildable: false + externals: + - spec: intel-oneapi-tbb@2022.3 + prefix: /opt/intel/oneapi + modules: + - tbb/2022.3 + mpich: + buildable: false + openmpi: + buildable: false + mkl: + require: + - intel-oneapi-mkl + py-numpy: + require: + - '^intel-oneapi-mkl'