Skip to content

Commit

Permalink
reduce size by bringing all spack commands into a single script that …
Browse files Browse the repository at this point in the history
…deletes everything but the view after successfully building
  • Loading branch information
white238 committed Aug 17, 2023
1 parent 73a71a2 commit 3139977
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 43 deletions.
22 changes: 18 additions & 4 deletions scripts/set-up-spack.sh → 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
1 change: 0 additions & 1 deletion scripts/ubuntu/apt-install-defaults-plus-args.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ packages=(
# fetchers
ca-certificates
curl
git
wget
# interactive tools
valgrind
Expand Down
16 changes: 7 additions & 9 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,12 @@ 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 /opt/scripts
RUN apt-get -qq update && apt-get -qq install -y --no-install-recommends git
# TODO: REMOVE THE BRANCH BEFORE MERGING
RUN GIT_SSL_NO_VERIFY=1 git clone -b task/white238/reduce_size https://github.com/rse-ops/docker-images.git && cp -R docker-images/scripts /opt/scripts && rm -rf docker-images

# Install base packages
WORKDIR /opt
COPY ./scripts /opt/scripts
# Install spack
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
18 changes: 9 additions & 9 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,14 @@ 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 /opt/scripts
RUN apt-get -qq update && apt-get -qq install -y --no-install-recommends git
# TODO: Fix the git commands before merging
RUN GIT_SSL_NO_VERIFY=1 git clone -b task/white238/reduce_size https://github.com/white238/docker-images.git && \
cp -R docker-images/scripts /opt/scripts && \
rm -rf docker-images

# Install base packages
WORKDIR /opt
COPY ./scripts /opt/scripts
# Install spack
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
17 changes: 8 additions & 9 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,12 @@ 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 /opt/scripts
RUN apt-get -qq update && apt-get -qq install -y --no-install-recommends git
# TODO: REMOVE THE BRANCH BEFORE MERGING
RUN GIT_SSL_NO_VERIFY=1 git clone -b task/white238/reduce_size https://github.com/rse-ops/docker-images.git && cp -R docker-images/scripts /opt/scripts && rm -rf docker-images

# Install base packages
WORKDIR /opt
COPY ./scripts /opt/scripts
# Install spack
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
17 changes: 6 additions & 11 deletions ubuntu/clang/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG ubuntu_version
FROM ghcr.io/rse-ops/ubuntu:$ubuntu_version
FROM white238:ubuntu22_base

# Install llvm with spack
ARG llvm_version
Expand All @@ -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 3139977

Please sign in to comment.