containerize: pin the Spack version used in a container (#21910)
This PR permits to specify the `url` and `ref` of the Spack instance used in a container recipe simply by expanding the YAML schema as outlined in #20442: ```yaml container: images: os: amazonlinux:2 spack: ref: develop resolve_sha: true ``` The `resolve_sha` option, if true, verifies the `ref` by cloning the Spack repository in a temporary directory and transforming any tag or branch name to a commit sha. When this new ability is leveraged an additional "bootstrap" stage is added, which builds an image with Spack setup and ready to install software. The Spack repository to be used can be customized with the `url` keyword under `spack`. Modifications: - [x] Permit to pin the version of Spack, either by branch or tag or sha - [x] Added a few new OSes (centos:8, amazonlinux:2, ubuntu:20.04, alpine:3, cuda:11.2.1) - [x] Permit to print the bootstrap image as a standalone - [x] Add documentation on the new part of the schema - [x] Add unit tests for different use cases
This commit is contained in:

committed by
GitHub

parent
ff65e6352f
commit
6063600a7b
@@ -1,3 +1,8 @@
|
||||
{% if render_phase.bootstrap %}
|
||||
{{ bootstrap.recipe }}
|
||||
|
||||
{% endif %}
|
||||
{% if render_phase.build %}
|
||||
# Build stage with Spack pre-installed and ready to be used
|
||||
FROM {{ build.image }} as builder
|
||||
|
||||
@@ -35,7 +40,8 @@ RUN cd {{ paths.environment }} && \
|
||||
{% if extra_instructions.build %}
|
||||
{{ extra_instructions.build }}
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{% if render_phase.final %}
|
||||
# Bare OS image to run the installed executables
|
||||
FROM {{ run.image }}
|
||||
|
||||
@@ -49,12 +55,12 @@ RUN {% if os_package_update %}{{ os_packages_final.update }} \
|
||||
&& {% endif %}{{ os_packages_final.install }} {{ os_packages_final.list | join | replace('\n', ' ') }} \
|
||||
&& {{ os_packages_final.clean }}
|
||||
{% endif %}
|
||||
|
||||
{% if extra_instructions.final %}
|
||||
|
||||
{{ extra_instructions.final }}
|
||||
{% endif %}
|
||||
{% for label, value in labels.items() %}
|
||||
LABEL "{{ label }}"="{{ value }}"
|
||||
{% endfor %}
|
||||
|
||||
ENTRYPOINT ["/bin/bash", "--rcfile", "/etc/profile", "-l"]
|
||||
{% endif %}
|
||||
|
7
share/spack/templates/container/alpine_3.dockerfile
Normal file
7
share/spack/templates/container/alpine_3.dockerfile
Normal file
@@ -0,0 +1,7 @@
|
||||
{% extends "container/bootstrap-base.dockerfile" %}
|
||||
{% block install_os_packages %}
|
||||
RUN apk update \
|
||||
&& apk add --no-cache curl findutils gcc g++ gfortran git gnupg \
|
||||
make patch python3 py3-pip tcl unzip bash \
|
||||
&& pip3 install boto3
|
||||
{% endblock %}
|
24
share/spack/templates/container/amazonlinux_2.dockerfile
Normal file
24
share/spack/templates/container/amazonlinux_2.dockerfile
Normal file
@@ -0,0 +1,24 @@
|
||||
{% extends "container/bootstrap-base.dockerfile" %}
|
||||
{% block install_os_packages %}
|
||||
RUN yum update -y \
|
||||
&& yum groupinstall -y "Development Tools" \
|
||||
&& yum install -y \
|
||||
curl \
|
||||
findutils \
|
||||
gcc-c++ \
|
||||
gcc \
|
||||
gcc-gfortran \
|
||||
git \
|
||||
gnupg2 \
|
||||
hostname \
|
||||
iproute \
|
||||
make \
|
||||
patch \
|
||||
python \
|
||||
python-pip \
|
||||
python-setuptools \
|
||||
unzip \
|
||||
&& pip install boto3 \
|
||||
&& rm -rf /var/cache/yum \
|
||||
&& yum clean all
|
||||
{% endblock %}
|
45
share/spack/templates/container/bootstrap-base.dockerfile
Normal file
45
share/spack/templates/container/bootstrap-base.dockerfile
Normal file
@@ -0,0 +1,45 @@
|
||||
FROM {{ bootstrap.image }} as bootstrap
|
||||
|
||||
{% block env_vars %}
|
||||
ENV SPACK_ROOT=/opt/spack \
|
||||
CURRENTLY_BUILDING_DOCKER_IMAGE=1 \
|
||||
container=docker
|
||||
{% endblock %}
|
||||
|
||||
{% block install_os_packages %}
|
||||
{% endblock %}
|
||||
|
||||
RUN mkdir $SPACK_ROOT && cd $SPACK_ROOT && \
|
||||
{{ bootstrap.spack_checkout }} && \
|
||||
mkdir -p $SPACK_ROOT/opt/spack
|
||||
|
||||
RUN ln -s $SPACK_ROOT/share/spack/docker/entrypoint.bash \
|
||||
/usr/local/bin/docker-shell \
|
||||
&& ln -s $SPACK_ROOT/share/spack/docker/entrypoint.bash \
|
||||
/usr/local/bin/interactive-shell \
|
||||
&& ln -s $SPACK_ROOT/share/spack/docker/entrypoint.bash \
|
||||
/usr/local/bin/spack-env
|
||||
|
||||
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
|
||||
|
||||
# [WORKAROUND]
|
||||
# https://superuser.com/questions/1241548/
|
||||
# xubuntu-16-04-ttyname-failed-inappropriate-ioctl-for-device#1253889
|
||||
RUN [ -f ~/.profile ] \
|
||||
&& sed -i 's/mesg n/( tty -s \\&\\& mesg n || true )/g' ~/.profile \
|
||||
|| true
|
||||
|
||||
{% block post_checkout %}
|
||||
{% endblock %}
|
||||
|
||||
WORKDIR /root
|
||||
SHELL ["docker-shell"]
|
||||
|
||||
# Creates the package cache
|
||||
RUN spack spec hdf5+mpi
|
||||
|
||||
ENTRYPOINT ["/bin/bash", "/opt/spack/share/spack/docker/entrypoint.bash"]
|
||||
CMD ["interactive-shell"]
|
26
share/spack/templates/container/centos_7.dockerfile
Normal file
26
share/spack/templates/container/centos_7.dockerfile
Normal file
@@ -0,0 +1,26 @@
|
||||
{% extends "container/bootstrap-base.dockerfile" %}
|
||||
{% block install_os_packages %}
|
||||
RUN yum update -y \
|
||||
&& yum install -y epel-release \
|
||||
&& yum update -y \
|
||||
&& yum --enablerepo epel groupinstall -y "Development Tools" \
|
||||
&& yum --enablerepo epel install -y \
|
||||
curl \
|
||||
findutils \
|
||||
gcc-c++ \
|
||||
gcc \
|
||||
gcc-gfortran \
|
||||
git \
|
||||
gnupg2 \
|
||||
hostname \
|
||||
iproute \
|
||||
make \
|
||||
patch \
|
||||
python \
|
||||
python-pip \
|
||||
python-setuptools \
|
||||
unzip \
|
||||
&& pip install boto3 \
|
||||
&& rm -rf /var/cache/yum \
|
||||
&& yum clean all
|
||||
{% endblock %}
|
29
share/spack/templates/container/centos_8.dockerfile
Normal file
29
share/spack/templates/container/centos_8.dockerfile
Normal file
@@ -0,0 +1,29 @@
|
||||
{% extends "container/bootstrap-base.dockerfile" %}
|
||||
{% block install_os_packages %}
|
||||
RUN yum update -y \
|
||||
# See https://fedoraproject.org/wiki/EPEL#Quickstart for powertools
|
||||
&& yum install -y dnf-plugins-core \
|
||||
&& dnf config-manager --set-enabled powertools \
|
||||
&& yum install -y epel-release \
|
||||
&& yum update -y \
|
||||
&& yum --enablerepo epel groupinstall -y "Development Tools" \
|
||||
&& yum --enablerepo epel install -y \
|
||||
curl \
|
||||
findutils \
|
||||
gcc-c++ \
|
||||
gcc \
|
||||
gcc-gfortran \
|
||||
git \
|
||||
gnupg2 \
|
||||
hostname \
|
||||
iproute \
|
||||
make \
|
||||
patch \
|
||||
python38 \
|
||||
python38-pip \
|
||||
python38-setuptools \
|
||||
unzip \
|
||||
&& pip3 install boto3 \
|
||||
&& rm -rf /var/cache/yum \
|
||||
&& yum clean all
|
||||
{% endblock %}
|
1
share/spack/templates/container/cuda_11_2_1.dockerfile
Symbolic link
1
share/spack/templates/container/cuda_11_2_1.dockerfile
Symbolic link
@@ -0,0 +1 @@
|
||||
ubuntu_2004.dockerfile
|
32
share/spack/templates/container/ubuntu_1604.dockerfile
Normal file
32
share/spack/templates/container/ubuntu_1604.dockerfile
Normal file
@@ -0,0 +1,32 @@
|
||||
{% extends "container/bootstrap-base.dockerfile" %}
|
||||
{% block env_vars %}
|
||||
{{ super() }}
|
||||
ENV DEBIAN_FRONTEND=noninteractive \
|
||||
LANGUAGE=en_US.UTF-8 \
|
||||
LANG=en_US.UTF-8 \
|
||||
LC_ALL=en_US.UTF-8
|
||||
{% endblock %}
|
||||
{% block install_os_packages %}
|
||||
RUN apt-get -yqq update \
|
||||
&& apt-get -yqq install --no-install-recommends \
|
||||
build-essential \
|
||||
ca-certificates \
|
||||
curl \
|
||||
file \
|
||||
g++ \
|
||||
gcc \
|
||||
gfortran \
|
||||
git \
|
||||
gnupg2 \
|
||||
iproute2 \
|
||||
locales \
|
||||
lua-posix \
|
||||
make \
|
||||
python3 \
|
||||
python3-pip \
|
||||
python3-setuptools \
|
||||
unzip \
|
||||
&& locale-gen en_US.UTF-8 \
|
||||
&& pip3 install boto3 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
{% endblock %}
|
6
share/spack/templates/container/ubuntu_1804.dockerfile
Normal file
6
share/spack/templates/container/ubuntu_1804.dockerfile
Normal file
@@ -0,0 +1,6 @@
|
||||
{% extends "container/ubuntu_1604.dockerfile" %}
|
||||
{% block post_checkout %}
|
||||
# [WORKAROUND]
|
||||
# https://bugs.launchpad.net/ubuntu/+source/lua-posix/+bug/1752082
|
||||
RUN ln -s posix_c.so /usr/lib/x86_64-linux-gnu/lua/5.2/posix.so
|
||||
{% endblock %}
|
1
share/spack/templates/container/ubuntu_2004.dockerfile
Symbolic link
1
share/spack/templates/container/ubuntu_2004.dockerfile
Symbolic link
@@ -0,0 +1 @@
|
||||
ubuntu_1604.dockerfile
|
Reference in New Issue
Block a user