Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
	modified:   .github/workflows/docker-publish.yml
	modified:   cuda-11/Dockerfile
	modified:   cuda-11/spack.yaml
	modified:   ubuntu-clang/Dockerfile
	modified:   ubuntu-clang/spack.yaml
	modified:   ubuntu-gcc/Dockerfile
	modified:   ubuntu-gcc/spack.yaml
  • Loading branch information
s-sajid-ali committed Sep 11, 2023
1 parent fcdf07b commit 6690da6
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 116 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Cancel Previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
Expand Down
50 changes: 35 additions & 15 deletions cuda-11/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM nvidia/cuda:11.8.0-devel-ubuntu22.04 as bootstrap
FROM nvidia/cuda:11.2.1-devel as bootstrap

ENV SPACK_ROOT=/opt/spack \
CURRENTLY_BUILDING_DOCKER_IMAGE=1 \
Expand All @@ -24,16 +24,19 @@ RUN apt-get -yqq update \
iproute2 \
locales \
make \
mercurial \
subversion \
python3 \
python3-pip \
python3-setuptools \
unzip \
zstd \
&& locale-gen en_US.UTF-8 \
&& pip3 install boto3 \
&& rm -rf /var/lib/apt/lists/*

RUN mkdir $SPACK_ROOT && cd $SPACK_ROOT && \
git clone https://github.com/spack/spack.git . && git fetch origin develop:container_branch && git checkout container_branch && \
git init --quiet && git remote add origin https://github.com/spack/spack.git && git fetch --depth=1 origin develop && git checkout --detach FETCH_HEAD && \
mkdir -p $SPACK_ROOT/opt/spack

RUN ln -s $SPACK_ROOT/share/spack/docker/entrypoint.bash \
Expand All @@ -46,7 +49,7 @@ RUN ln -s $SPACK_ROOT/share/spack/docker/entrypoint.bash \
RUN mkdir -p /root/.spack \
&& cp $SPACK_ROOT/share/spack/docker/modules.yaml \
/root/.spack/modules.yaml \
&& rm -rf /root/*.* /run/nologin $SPACK_ROOT/.git
&& rm -rf /root/*.* /run/nologin

# [WORKAROUND]
# https://superuser.com/questions/1241548/
Expand All @@ -60,7 +63,9 @@ WORKDIR /root
SHELL ["docker-shell"]

# Creates the package cache
RUN spack bootstrap now && spack spec hdf5+mpi
RUN spack bootstrap now \
&& spack bootstrap status --optional \
&& spack spec hdf5+mpi

ENTRYPOINT ["/bin/bash", "/opt/spack/share/spack/docker/entrypoint.bash"]
CMD ["interactive-shell"]
Expand Down Expand Up @@ -89,9 +94,9 @@ RUN mkdir /opt/spack-environment \
&& echo ' lapack:' \
&& echo ' - openblas' \
&& echo ' specs:' \
&& echo ' - hdf5@1.12.2+hl+mpi~fortran' \
&& echo ' - hdf5+hl+mpi~fortran' \
&& echo ' - mpich~fortran device=ch4 netmod=ofi' \
&& echo ' - petsc@main~fortran+debug' \
&& echo ' - petsc@main~fortran+debug+cuda' \
&& echo ' - gsl' \
&& echo ' - python+pythoncmd' \
&& echo ' - py-pyparsing' \
Expand All @@ -102,7 +107,7 @@ RUN mkdir /opt/spack-environment \
&& echo ' - ninja' \
&& echo ' concretizer:' \
&& echo ' unify: true' \
&& echo ' view: /opt/view' \
&& echo ' view: /opt/views/view' \
&& echo ' config:' \
&& echo ' install_tree: /opt/software') > /opt/spack-environment/spack.yaml

Expand All @@ -116,29 +121,44 @@ RUN spack external find gettext
RUN cd /opt/spack-environment && spack env activate . && spack install --fail-fast && spack gc -y

# Strip all the binaries
RUN find -L /opt/view/* -type f -exec readlink -f '{}' \; | \
RUN find -L /opt/views/view/* -type f -exec readlink -f '{}' \; | \
xargs file -i | \
grep 'charset=binary' | \
grep 'x-executable\|x-archive\|x-sharedlib' | \
awk -F: '{print $1}' | xargs strip

# Modifications to the environment that are necessary to run
RUN cd /opt/spack-environment && \
spack env activate --sh -d . >> /etc/profile.d/z10_spack_environment.sh
spack env activate --sh -d . > activate.sh

# Override spack behavior to have nvcc in the final container image
FROM nvidia/cuda:11.8.0-devel-ubuntu22.04

# Bare OS image to run the installed executables
FROM nvidia/cuda:11.2.1-base

COPY --from=builder /opt/spack-environment /opt/spack-environment
COPY --from=builder /opt/software /opt/software
COPY --from=builder /opt/._view /opt/._view
COPY --from=builder /opt/view /opt/view
COPY --from=builder /etc/profile.d/z10_spack_environment.sh /etc/profile.d/z10_spack_environment.sh

# paths.view is a symlink, so copy the parent to avoid dereferencing and duplicating it
COPY --from=builder /opt/views /opt/views

RUN { \
echo '#!/bin/sh' \
&& echo '.' /opt/spack-environment/activate.sh \
&& echo 'exec "$@"'; \
} > /entrypoint.sh \
&& chmod a+x /entrypoint.sh \
&& ln -s /opt/views/view /opt/view

# Noninteractive install!
ENV DEBIAN_FRONTEND=noninteractive \
LANGUAGE=en_US.UTF-8 \
LANG=en_US.UTF-8 \
LC_ALL=en_US.UTF-8 \
TZ=Etc/UTC

RUN apt-get -yqq update && apt-get -yqq upgrade \
&& apt-get -yqq install build-essential bash git cmake wget gfortran tar \
&& rm -rf /var/lib/apt/lists/*
ENTRYPOINT ["/bin/bash", "--rcfile", "/etc/profile", "-l", "-c", "$*", "--" ]
ENTRYPOINT [ "/entrypoint.sh" ]
CMD [ "/bin/bash" ]

2 changes: 1 addition & 1 deletion cuda-11/spack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spack:
lapack:
- openblas
specs:
- hdf5@1.12.2+hl+mpi~fortran
- hdf5+hl+mpi~fortran
- mpich~fortran device=ch4 netmod=ofi
- petsc@main~fortran+debug+cuda
- gsl
Expand Down
123 changes: 66 additions & 57 deletions ubuntu-clang/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,56 +19,56 @@ RUN apt-get -yqq install clang-15 libc++-15-dev libc++abi-15-dev libomp-15-dev
# What we want to install and how we want to install it
# is specified in a manifest file (spack.yaml)
RUN mkdir /opt/spack-environment \
&& (echo "spack:" \
&& echo " compilers:" \
&& echo " - compiler:" \
&& echo " spec: [email protected]" \
&& echo " paths:" \
&& echo " cc: /usr/bin/clang-15" \
&& echo " cxx: /usr/bin/clang++-15" \
&& echo " f77:" \
&& echo " fc:" \
&& echo " flags:" \
&& echo " cxxflags: -stdlib=libc++" \
&& echo " operating_system: ubuntu22.04" \
&& echo " target: x86_64" \
&& echo " modules: []" \
&& echo " environment: {}" \
&& echo " extra_rpaths:" \
&& echo " - /lib/gcc/x86_64-linux-gnu/11/libgfortran.so" \
&& echo " packages:" \
&& echo " all:" \
&& echo " target:" \
&& echo " - x86_64_v2" \
&& echo " compiler:" \
&& echo " - clang" \
&& echo " providers:" \
&& echo " mpi:" \
&& echo " - mpich" \
&& echo " blas:" \
&& echo " - openblas" \
&& echo " lapack:" \
&& echo " - openblas" \
&& echo " specs:" \
&& echo " - mpich~fortran device=ch4 netmod=ofi" \
&& echo " - openblas@develop~fortran" \
&& echo " - petsc@main~fortran+debug" \
&& echo " - hdf5@1.12.2+hl+mpi~fortran" \
&& echo " - fftw+mpi+openmp" \
&& echo " - cmake" \
&& echo " - gsl" \
&& echo " - python+pythoncmd" \
&& echo " - py-pyparsing" \
&& echo " - py-numpy" \
&& echo " - py-mpi4py" \
&& echo " - py-h5py+mpi" \
&& echo " - py-pytest" \
&& echo " - ninja" \
&& echo " concretizer:" \
&& echo " unify: true" \
&& echo " view: /opt/view" \
&& echo " config:" \
&& echo " install_tree: /opt/software") > /opt/spack-environment/spack.yaml
&& (echo spack: \
&& echo ' compilers:' \
&& echo ' - compiler:' \
&& echo ' spec: [email protected]' \
&& echo ' paths:' \
&& echo ' cc: /usr/bin/clang-15' \
&& echo ' cxx: /usr/bin/clang++-15' \
&& echo ' f77: null' \
&& echo ' fc: null' \
&& echo ' flags:' \
&& echo ' cxxflags: -stdlib=libc++' \
&& echo ' operating_system: ubuntu22.04' \
&& echo ' modules: []' \
&& echo ' environment: {}' \
&& echo ' extra_rpaths: []' \
&& echo ' packages:' \
&& echo ' all:' \
&& echo ' target:' \
&& echo ' - x86_64_v2' \
&& echo ' compiler:' \
&& echo ' - clang' \
&& echo ' providers:' \
&& echo ' # Cannot use intel-oneapi-mpi with clang' \
&& echo ' # for some reason, so use mpich for now.' \
&& echo ' mpi:' \
&& echo ' - mpich' \
&& echo ' blas:' \
&& echo ' - openblas' \
&& echo ' lapack:' \
&& echo ' - openblas' \
&& echo ' specs:' \
&& echo ' - mpich~fortran device=ch4 netmod=ofi' \
&& echo ' - openblas@develop~fortran' \
&& echo ' - petsc@main~fortran+debug' \
&& echo ' - hdf5+hl+mpi~fortran' \
&& echo ' - fftw+mpi+openmp' \
&& echo ' - cmake' \
&& echo ' - gsl' \
&& echo ' - python+pythoncmd' \
&& echo ' - py-pyparsing' \
&& echo ' - py-numpy' \
&& echo ' - py-mpi4py' \
&& echo ' - py-h5py+mpi' \
&& echo ' - py-pytest' \
&& echo ' - ninja' \
&& echo ' concretizer:' \
&& echo ' unify: true' \
&& echo ' view: /opt/views/view' \
&& echo ' config:' \
&& echo ' install_tree: /opt/software') > /opt/spack-environment/spack.yaml

# Find externals
RUN spack external find tar
Expand All @@ -80,24 +80,33 @@ RUN spack external find gettext
RUN cd /opt/spack-environment && spack env activate . && spack install --fail-fast && spack gc -y

# Strip all the binaries
RUN find -L /opt/view/* -type f -exec readlink -f '{}' \; | \
RUN find -L /opt/views/view/* -type f -exec readlink -f '{}' \; | \
xargs file -i | \
grep 'charset=binary' | \
grep 'x-executable\|x-archive\|x-sharedlib' | \
awk -F: '{print $1}' | xargs strip -s
awk -F: '{print $1}' | xargs strip

# Modifications to the environment that are necessary to run
RUN cd /opt/spack-environment && \
spack env activate --sh -d . >> /etc/profile.d/z10_spack_environment.sh
spack env activate --sh -d . > activate.sh


# Bare OS image to run the installed executables
FROM ubuntu:22.04

COPY --from=builder /opt/spack-environment /opt/spack-environment
COPY --from=builder /opt/software /opt/software
COPY --from=builder /opt/._view /opt/._view
COPY --from=builder /opt/view /opt/view
COPY --from=builder /etc/profile.d/z10_spack_environment.sh /etc/profile.d/z10_spack_environment.sh

# paths.view is a symlink, so copy the parent to avoid dereferencing and duplicating it
COPY --from=builder /opt/views /opt/views

RUN { \
echo '#!/bin/sh' \
&& echo '.' /opt/spack-environment/activate.sh \
&& echo 'exec "$@"'; \
} > /entrypoint.sh \
&& chmod a+x /entrypoint.sh \
&& ln -s /opt/views/view /opt/view

# Noninteractive install!
ENV DEBIAN_FRONTEND=noninteractive \
Expand All @@ -116,6 +125,6 @@ RUN apt-get -yqq install clang-15 libc++-15-dev libc++abi-15-dev libomp-15-dev
RUN apt-get -yqq update && apt-get -yqq upgrade \
&& apt-get -yqq install build-essential bash git tar wget \
&& rm -rf /var/lib/apt/lists/*
ENTRYPOINT ["/bin/bash", "--rcfile", "/etc/profile", "-l", "-c", "$*", "--" ]
ENTRYPOINT [ "/entrypoint.sh" ]
CMD [ "/bin/bash" ]

6 changes: 2 additions & 4 deletions ubuntu-clang/spack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ spack:
flags:
cxxflags: -stdlib=libc++
operating_system: ubuntu22.04
target: x86_64
modules: []
environment: {}
extra_rpaths:
- /lib/gcc/x86_64-linux-gnu/11/libgfortran.so
extra_rpaths: []
packages:
all:
target:
Expand All @@ -38,7 +36,7 @@ spack:
- mpich~fortran device=ch4 netmod=ofi
- openblas@develop~fortran
- petsc@main~fortran+debug
- hdf5@1.12.2+hl+mpi~fortran
- hdf5+hl+mpi~fortran
- fftw+mpi+openmp
- cmake
- gsl
Expand Down
Loading

0 comments on commit 6690da6

Please sign in to comment.