Skip to content

Commit

Permalink
move spack commands into a single script that also deletes spack to s…
Browse files Browse the repository at this point in the history
…ave space
  • Loading branch information
white238 committed Aug 18, 2023
1 parent 3eaf0d2 commit a3157f9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 38 deletions.
22 changes: 18 additions & 4 deletions scripts/build-with-spack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,38 @@ popd
# temporary path update for this script
export PATH=/opt/spack/bin:$PATH

# Install Clingo for Spack
python3 -m pip install --upgrade pip
python3 -m pip install clingo
# Bootstrap clingo
spack bootstrap now

# Find packages already installed on system, e.g. autoconf
# IMPORTANT: ensure that all binaries installed include their development files
# failure to do this will get them detected, and kill builds with
# spack
spack external find # NOTE no all
# Find some packages out of the default check set that work
spack external find python perl binutils git tar xz bzip2
spack external find python perl binutils git tar xz bzip2 hwloc ncurses
# configure spack
# build for the generic target
spack config add 'packages:all:target:[x86_64]'
# reuse as much as possible, make externals useful
spack config add 'concretizer:reuse:true'
# Generate spack environment for packages
spack env create --dir /opt/env --with-view /opt/view
# Activate created environment
spack env activate --without-view /opt/env
# Add binary mirror
spack mirror add develop https://binaries.spack.io/releases/develop
# Move install tree outside of spack directory so spack repo can be removed after
spack config add "config:install_tree:root:'/opt'"
# Concretize spec
spack spec --reuse $0
# Add spec to environment
spack add $0
spack buildcache keys --install --trust
spack install --fail-fast

# delete spack to save space
rm -rf /opt/spack

# ensure clangs and others that don't inject rpaths make working executables
cat >/etc/ld.so.conf.d/spack_view.conf <<EOF
Expand Down
12 changes: 4 additions & 8 deletions ubuntu/20.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ FROM ubuntu:20.04@sha256:33a5cc25d22c45900796a1aca487ad7a7cb09f09ea00b779e3b2026

LABEL maintainer="Chris White <[email protected]>,@vsoch"

ARG uptodate_github_commit_spack__spack__develop=e381e166ec27bb56c2d3bc856e7020224a005d1d
ENV spack_commit=${uptodate_github_commit_spack__spack__develop}
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=America/Los_Angeles

Expand All @@ -14,12 +12,10 @@ ENV PATH=/opt/view/bin:/opt/spack/bin:$PATH \
CMAKE_PREFIX_PATH=/opt/view \
ACLOCAL_PATH=/opt/view/share/aclocal

# Install repository scripts dir to containers /opt/scripts
WORKDIR /opt
COPY ./scripts /opt/scripts
# Install spack

# Install base packages
RUN ./scripts/ubuntu/apt-install-defaults-plus-args.sh && \
./scripts/install-cmake-binary.sh && \
./scripts/set-up-spack.sh
# Tell spack to use this one without arguments
# NOTE: this has to be here, setting it earlier will kill spack
ENV SPACK_ENV=/opt/env
./scripts/install-cmake-binary.sh
12 changes: 4 additions & 8 deletions ubuntu/22.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ FROM ubuntu:22.04@sha256:ec050c32e4a6085b423d36ecd025c0d3ff00c38ab93a3d71a460ff1

LABEL maintainer="@vsoch"

ARG uptodate_github_commit_spack__spack__develop=e381e166ec27bb56c2d3bc856e7020224a005d1d
ENV spack_commit=${uptodate_github_commit_spack__spack__develop}
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=America/Los_Angeles

Expand All @@ -14,12 +12,10 @@ ENV PATH=/opt/view/bin:/opt/spack/bin:$PATH \
CMAKE_PREFIX_PATH=/opt/view \
ACLOCAL_PATH=/opt/view/share/aclocal

# Install repository scripts dir to containers /opt/scripts
WORKDIR /opt
COPY ./scripts /opt/scripts
# Install spack

# Install base packages
RUN ./scripts/ubuntu/apt-install-defaults-plus-args.sh && \
./scripts/install-cmake-binary.sh && \
./scripts/set-up-spack.sh
# Tell spack to use this one without arguments
# NOTE: this has to be here, setting it earlier will kill spack
ENV SPACK_ENV=/opt/env
./scripts/install-cmake-binary.sh
13 changes: 5 additions & 8 deletions ubuntu/23.04/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# TODO: fix this, it is pointing at 22.04 not 23.04
FROM ubuntu:22.04@sha256:ec050c32e4a6085b423d36ecd025c0d3ff00c38ab93a3d71a460ff1c44fa6d77

LABEL maintainer="@vsoch"

ARG uptodate_github_commit_spack__spack__develop=e381e166ec27bb56c2d3bc856e7020224a005d1d
ENV spack_commit=${uptodate_github_commit_spack__spack__develop}
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=America/Los_Angeles

Expand All @@ -14,12 +13,10 @@ ENV PATH=/opt/view/bin:/opt/spack/bin:$PATH \
CMAKE_PREFIX_PATH=/opt/view \
ACLOCAL_PATH=/opt/view/share/aclocal

# Install repository scripts dir to containers /opt/scripts
WORKDIR /opt
COPY ./scripts /opt/scripts
# Install spack

# Install base packages
RUN ./scripts/ubuntu/apt-install-defaults-plus-args.sh && \
./scripts/install-cmake-binary.sh && \
./scripts/set-up-spack.sh
# Tell spack to use this one without arguments
# NOTE: this has to be here, setting it earlier will kill spack
ENV SPACK_ENV=/opt/env
./scripts/install-cmake-binary.sh
15 changes: 5 additions & 10 deletions ubuntu/clang/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,11 @@ ENV llvm_spec="llvm@${llvm_version}+llvm_dylib+link_llvm_dylib~split_dwarf~lldb~
CXX=/opt/view/bin/clang++ \
CPP=/opt/view/bin/clang-cpp

# build compiler and set defaults
RUN spack external find hwloc ncurses \
&& spack spec --reuse "${llvm_spec}" \
&& spack add "${llvm_spec}" \
&& spack mirror add develop https://binaries.spack.io/releases/develop \
&& spack buildcache keys --install --trust \
&& spack install --fail-fast \
&& spack compiler add \
&& spack config add "packages:all:compiler:[${COMPILER_NAME}@${COMPILER_VERSION}]" \
&& update-alternatives --install /usr/bin/cc cc ${CC} 50 \
# build compiler and set defaults then remove spack to keep image size small
ARG uptodate_github_commit_spack__spack__develop=b8590fbd057621c9b71c5b274b21e1802d52bc45
ENV spack_commit=${uptodate_github_commit_spack__spack__develop}
RUN ./scripts/build-with-spack.sh "${llvm_spec}"
RUN update-alternatives --install /usr/bin/cc cc ${CC} 50 \
&& update-alternatives --install /usr/bin/c++ c++ ${CXX} 50 \
&& update-alternatives --install /usr/bin/cpp cpp ${CPP} 50 \
&& update-alternatives --install /usr/bin/c89 c89 ${CC} 50 \
Expand Down

0 comments on commit a3157f9

Please sign in to comment.