Skip to content

Commit

Permalink
Removed testing env and lockfiles from repo, optimized Dockerfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeGat committed Aug 1, 2023
1 parent e2f6b2f commit aa68b80
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 2,133 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
keys
__pycache__
.pytest_cache
.vscode
containers/spack_environment
.vscode
17 changes: 11 additions & 6 deletions containers/Dockerfile.base-spack
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@ FROM rockylinux:8.7
SHELL ["/bin/bash", "-c"]

ENV SPACK_ROOT=/opt/spack
ENV SPACK_PACKAGES_ROOT=/opt/spack_packages
ENV SPACK_PACKAGES_REPO_ROOT=/opt/spack_packages
ENV GNUPGHOME=$SPACK_ROOT/opt/spack/gpg

ARG SPACK_PACKAGES_VERSION

RUN dnf -y group install "Development Tools"
RUN dnf -y group install "Development Tools" \
&& dnf clean all \
&& rm -rf /var/cache/yum

# csh currently required for some build scripts e.g. MOM5
RUN dnf -y install \
csh \
gcc-gfortran \
git \
jq \
python3 \
python3-pip \
# csh currently required for some build scripts e.g. MOM5
csh
&& dnf clean all \
&& rm -rf /var/cache/yum

# Install spack
RUN git clone -c feature.manyFiles=true https://github.com/spack/spack.git $SPACK_ROOT --branch v0.20.1 --single-branch --depth=1
Expand All @@ -40,13 +45,13 @@ SHELL ["docker-shell"]
RUN spack bootstrap now

# Set up ACCESS Spack package repo
RUN git clone -b ${SPACK_PACKAGES_VERSION} https://github.com/ACCESS-NRI/spack_packages.git ${SPACK_PACKAGES_ROOT}
RUN git clone --depth 1 -b ${SPACK_PACKAGES_VERSION} https://github.com/ACCESS-NRI/spack_packages.git ${SPACK_PACKAGES_ROOT}
COPY repos.yaml $SPACK_ROOT/etc/spack/repos.yaml

# TODO
# Think about setting up spack S3 build cache for CI here
# Set up ACCESS Spack buildcache
RUN pip3 install boto3
RUN pip3 install --no-cache-dir boto3
RUN spack gpg init

# Add buildcache mirror
Expand Down
27 changes: 12 additions & 15 deletions containers/Dockerfile.build
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
ARG BASE_IMAGE
FROM ${BASE_IMAGE}

ARG PACKAGE
# Need to specify compiler package name for install and module name for build separately
# e.g. for the latest intel this would be:
# COMPILER_NAME=intel
# COMPILER_PACKAGE=intel-oneapi-compilers
ARG COMPILER_NAME
ARG COMPILER_PACKAGE
ARG COMPILER_VERSION
# eg. mom5, access-om2...
ARG MODEL_NAMES

ENV SPACK_ENVIRONMENT_DIRECTORY_ROOT=/opt/spack_environment

# Use Spack shell environment for subsequent RUN steps
SHELL ["docker-shell"]

COPY ./spack_environment/envs ${SPACK_ENVIRONMENT_DIRECTORY_ROOT}

RUN ./setup-spack-envs ${MODEL_NAMES}

# Install required compiler
RUN spack -d install ${COMPILER_PACKAGE}@${COMPILER_VERSION}
# RUN spack -d install ${COMPILER_PACKAGE}@${COMPILER_VERSION}

# Load required compiler and generate site-wide compilers.yaml
RUN spack load ${COMPILER_PACKAGE}@${COMPILER_VERSION} && \
spack compiler find --scope site
# RUN spack load ${COMPILER_PACKAGE}@${COMPILER_VERSION} && \
# spack compiler find --scope site (try with scope env:$package)

# Build and install package dependencies
RUN spack -d install --only dependencies ${PACKAGE}%${COMPILER_NAME}@${COMPILER_VERSION}
# RUN spack -d install --only dependencies ${PACKAGE}%${COMPILER_NAME}@${COMPILER_VERSION}

# Push any uncached binaries to buildcache
# `spack find --json | jq .[].name`
# This returns all currently installed spec names
RUN dnf -y install jq
RUN spack -d buildcache create -a -m s3_buildcache `spack find --json | jq --raw-output .[].name`
9 changes: 4 additions & 5 deletions containers/setup-spack-envs.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
for package in "$1"; do
spack env create $package
spack env create $package $package.spack.yaml
spack env activate $package
spack -d install --add ${COMPILER_PACKAGE}@${COMPILER_VERSION}
spack load ${COMPILER_PACKAGE}@${COMPILER_VERSION}
spack compiler find --scope site
spack -d install --only dependencies ${PACKAGE}%${COMPILER_NAME}@${COMPILER_VERSION}
spack -d install --only dependencies --fail-fast
spack gc -y
spack env deactivate
done
40 changes: 0 additions & 40 deletions containers/spack_environment/envs/mom5.spack.yaml

This file was deleted.

Loading

0 comments on commit aa68b80

Please sign in to comment.