Skip to content

Commit fac7cbd

Browse files
authored
Add tutorial Docker image (#21)
1 parent d476c20 commit fac7cbd

File tree

7 files changed

+102
-18
lines changed

7 files changed

+102
-18
lines changed

.github/workflows/containers.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
dockerfile: [[e4s-ubuntu-18.04, e4s-ubuntu-18.04.dockerfile, 'linux/amd64,linux/ppc64le,linux/arm64'],
3535
[e4s-ubuntu-20.04, e4s-ubuntu-20.04.dockerfile, 'linux/amd64,linux/ppc64le,linux/arm64'],
3636
[linux-ubuntu22.04-x86_64_v2, linux-ubuntu22.04-x86_64_v2/Dockerfile, 'linux/amd64'],
37+
[tutorial-ubuntu-22.04, tutorial-ubuntu-22.04/Dockerfile, 'linux/amd64/v2'],
3738
[e4s-amazonlinux-2, e4s-amazonlinux-2.dockerfile, 'linux/amd64,linux/arm64'],
3839
[e4s-centos-7, e4s-centos-7.dockerfile, 'linux/amd64'],
3940
[e4s-fedora-36, e4s-fedora-36.dockerfile, 'linux/amd64,linux/ppc64le,linux/arm64']]

Dockerfiles/e4s-amazonlinux-2.dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ RUN python3 -m pip install --upgrade pip setuptools wheel \
4848

4949
COPY gpg.yaml /spack.yaml
5050
RUN git clone https://github.com/spack/spack /spack \
51+
&& (cd /spack && curl -Lfs https://github.com/spack/spack/pull/37405.patch | patch -p1) \
5152
&& export SPACK_ROOT=/spack \
5253
&& . /spack/share/spack/setup-env.sh \
53-
&& time spack -e . concretize -f | tee concretize.log \
54-
&& spack -e . install \
54+
&& spack -e . concretize \
55+
&& spack -e . install --make \
5556
&& spack -e . gc -y \
5657
&& spack clean -a \
57-
&& mv concretize.log spack.yaml /bootstrap/runner/. \
5858
&& rm -rf /spack /spack.yaml /spack.lock /.spack-env /root/.spack
5959

6060
ENV PATH=/bootstrap/runner/view/bin:$PATH \

Dockerfiles/linux-ubuntu22.04-x86_64_v2/Dockerfile

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,19 @@ RUN mkdir spack && \
2727
cd spack && \
2828
curl -Lfs https://github.com/spack/spack/archive/refs/heads/develop.tar.gz | tar -xzf - --strip-components=1 -C . && \
2929
curl -Lfs https://github.com/spack/spack/pull/34926.patch | patch -p1 && \
30-
curl -Lfs https://github.com/spack/spack/pull/35020.patch | patch -p1 && \
30+
curl -Lfs https://github.com/spack/spack/pull/35078.patch | patch -p1 && \
31+
curl -Lfs https://github.com/spack/spack/pull/35174.patch | patch -p1 && \
32+
curl -Lfs https://github.com/spack/spack/pull/37405.patch | patch -p1 && \
3133
true
3234

33-
ADD spack.yaml /root/
34-
ADD Dockerfiles/linux-ubuntu22.04-x86_64_v2/compilers.yaml Dockerfiles/linux-ubuntu22.04-x86_64_v2/packages.yaml /root/spack/etc/spack/
35-
36-
# Assume system make is too old
37-
RUN spack env create --with-view /root/tools tools && \
38-
spack -e tools add [email protected] && \
39-
spack -e tools concretize && \
40-
spack -e tools install
35+
COPY spack.yaml /root/
36+
COPY Dockerfiles/linux-ubuntu22.04-x86_64_v2/compilers.yaml Dockerfiles/linux-ubuntu22.04-x86_64_v2/packages.yaml /root/spack/etc/spack/
4137

4238

4339
RUN --mount=type=cache,target=/root/.spack/cache \
4440
spack -e . concretize -f && \
45-
spack -e . install && \
46-
spack -e . gc --yes-to-all && \
47-
spack -e . env view --link run enable /opt/spack/view
41+
spack -e . install --make && \
42+
spack -e . gc --yes-to-all
4843

4944
# Remove Spack metadata, python cache and static libraries to save some bytes
5045
RUN find -L /opt/spack -type d \( -name '__pycache__' -or -name '.spack' \) -exec rm -rf {} + && \
@@ -54,12 +49,15 @@ RUN find -L /opt/spack -type d \( -name '__pycache__' -or -name '.spack' \) -exe
5449
FROM ubuntu:22.04
5550

5651
ENV DEBIAN_FRONTEND=noninteractive \
57-
LC_ALL=C \
52+
LANG=C.UTF-8 \
53+
LC_ALL=C.UTF-8 \
5854
PATH=/opt/spack/view/bin:/root/spack/bin:$PATH
5955

6056
COPY --from=build /opt/spack /opt/spack
6157

6258
# We stick to system compilers & linkers
6359
RUN apt-get -yqq update && \
64-
apt-get -yqq install --no-install-recommends gcc gfortran g++ libc-dev && \
60+
apt-get -yqq install --no-install-recommends \
61+
gcc gfortran g++ \
62+
libc-dev && \
6563
rm -rf /var/lib/apt/lists/*
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
FROM ubuntu:22.04 as build
2+
3+
WORKDIR /root
4+
5+
ENV DEBIAN_FRONTEND=noninteractive \
6+
LC_ALL=C \
7+
PATH=/root/tools/bin:/root/spack/bin:$PATH
8+
9+
RUN apt-get -yqq update && \
10+
apt-get -yqq install \
11+
build-essential \
12+
ca-certificates \
13+
clang \
14+
curl \
15+
file \
16+
git \
17+
gnupg2 \
18+
iproute2 \
19+
lld \
20+
llvm \
21+
make \
22+
patch \
23+
python3 \
24+
unzip
25+
26+
RUN mkdir spack && \
27+
cd spack && \
28+
curl -Lfs https://github.com/spack/spack/archive/refs/heads/develop.tar.gz | tar -xzf - --strip-components=1 -C . && \
29+
curl -Lfs https://github.com/spack/spack/pull/34926.patch | patch -p1 && \
30+
curl -Lfs https://github.com/spack/spack/pull/35078.patch | patch -p1 && \
31+
curl -Lfs https://github.com/spack/spack/pull/35174.patch | patch -p1 && \
32+
curl -Lfs https://github.com/spack/spack/pull/37405.patch | patch -p1 && \
33+
true
34+
35+
COPY spack.yaml /root/
36+
COPY Dockerfiles/tutorial-ubuntu-22.04/compilers.yaml Dockerfiles/tutorial-ubuntu-22.04/packages.yaml /root/spack/etc/spack/
37+
38+
RUN --mount=type=cache,target=/root/.spack/cache \
39+
spack -e . concretize -f && \
40+
spack -e . install --make && \
41+
spack -e . gc --yes-to-all
42+
43+
# Remove Spack metadata, python cache and static libraries to save some bytes
44+
RUN find -L /opt/spack -type d \( -name '__pycache__' -or -name '.spack' \) -exec rm -rf {} + && \
45+
find -L /opt/spack -type f -name '*.a' -exec rm -rf {} +
46+
47+
# Stage 2, create a small(er) docker image
48+
FROM ubuntu:22.04
49+
50+
ENV DEBIAN_FRONTEND=noninteractive \
51+
LANG=C.UTF-8 \
52+
LC_ALL=C.UTF-8 \
53+
PATH=/opt/spack/view/bin:/root/spack/bin:$PATH
54+
55+
COPY --from=build /opt/spack /opt/spack
56+
57+
# We stick to system compilers & linkers
58+
RUN apt-get -yqq update && \
59+
apt-get -yqq install --no-install-recommends \
60+
gcc gfortran g++ \
61+
gcc-10 gfortran-10 g++-10 \
62+
gcc-12 gfortran-12 g++-12 \
63+
clang \
64+
libc-dev && \
65+
rm -rf /var/lib/apt/lists/*
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
compilers:
2+
- compiler:
3+
4+
paths:
5+
cc: /usr/bin/clang
6+
cxx: /usr/bin/clang++
7+
f77: null
8+
fc: null
9+
flags:
10+
cxxflags: '-O3 -g0 -ffunction-sections'
11+
cflags: '-O3 -g0 -ffunction-sections'
12+
ldflags: '-fuse-ld=lld -Wl,-O3'
13+
operating_system: ubuntu22.04
14+
modules: []
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
packages:
2+
all:
3+
require: target=x86_64_v2

spack.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
spack:
2-
view: false
2+
view:
3+
default:
4+
root: /opt/spack/view
5+
link: run
36
specs:
47
- 'clingo-bootstrap@spack +optimized'
58
- 'curl'

0 commit comments

Comments
 (0)