diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml index db63463..531c316 100644 --- a/.github/workflows/containers.yml +++ b/.github/workflows/containers.yml @@ -31,12 +31,15 @@ jobs: # A matrix of Dockerfile paths, associated tags, and which architectures # they support. matrix: - dockerfile: [[e4s-ubuntu-18.04, e4s-ubuntu-18.04.dockerfile, 'linux/amd64,linux/ppc64le,linux/arm64'], - [e4s-ubuntu-20.04, e4s-ubuntu-20.04.dockerfile, 'linux/amd64,linux/ppc64le,linux/arm64'], - [linux-ubuntu22.04-x86_64_v2, linux-ubuntu22.04-x86_64_v2/Dockerfile, 'linux/amd64'], - [e4s-amazonlinux-2, e4s-amazonlinux-2.dockerfile, 'linux/amd64,linux/arm64'], - [e4s-centos-7, e4s-centos-7.dockerfile, 'linux/amd64'], - [e4s-fedora-36, e4s-fedora-36.dockerfile, 'linux/amd64,linux/ppc64le,linux/arm64']] + dockerfile: [ + [e4s-ubuntu-18.04, e4s-ubuntu-18.04.dockerfile, 'linux/amd64,linux/ppc64le,linux/arm64'], + [e4s-ubuntu-20.04, e4s-ubuntu-20.04.dockerfile, 'linux/amd64,linux/ppc64le,linux/arm64'], + [linux-ubuntu22.04, linux-ubuntu22.04/Dockerfile, 'linux/amd64/v2,linux/arm64'], + [linux-amzn2023, linux-amzn2023/Dockerfile, 'linux/amd64/v2,linux/arm64'], + [e4s-amazonlinux-2, e4s-amazonlinux-2.dockerfile, 'linux/amd64,linux/arm64'], + [e4s-centos-7, e4s-centos-7.dockerfile, 'linux/amd64'], + [e4s-fedora-36, e4s-fedora-36.dockerfile, 'linux/amd64,linux/ppc64le,linux/arm64'] + ] name: Build ${{ matrix.dockerfile[0] }} steps: - name: Checkout diff --git a/Dockerfiles/linux-amzn2023/Dockerfile b/Dockerfiles/linux-amzn2023/Dockerfile new file mode 100644 index 0000000..726558a --- /dev/null +++ b/Dockerfiles/linux-amzn2023/Dockerfile @@ -0,0 +1,63 @@ +FROM amazonlinux:2023 as build + +WORKDIR /root + +ENV LANG=C.UTF-8 \ + LC_ALL=C.UTF-8 \ + PATH=/root/tools/bin:/root/spack/bin:/usr/bin:/bin + +RUN yum install -y \ + bzip2 \ + clang \ + git \ + lld \ + make \ + patch \ + python \ + tar \ + unzip \ + xz + +RUN mkdir spack && \ + cd spack && \ + curl -Lfs https://github.com/spack/spack/archive/refs/heads/develop.tar.gz | tar -xzf - --strip-components=1 -C . && \ + curl -Lfs https://github.com/spack/spack/pull/34926.patch | patch -p1 && \ + curl -Lfs https://github.com/spack/spack/pull/35020.patch | patch -p1 && \ + curl -Lfs https://github.com/spack/spack/pull/35078.patch | patch -p1 && \ + curl -Lfs https://github.com/spack/spack/pull/35174.patch | patch -p1 && \ + true + +ADD spack.yaml build.mk /root/ + +ADD Dockerfiles/linux-amzn2023/compilers.yaml /root/spack/etc/spack + +# Assume system make is too old +RUN spack env create --with-view /root/tools tools && \ + spack -e tools add gmake@4.4 && \ + spack -e tools concretize && \ + spack -e tools install + +RUN --mount=type=cache,target=/buildcache \ + --mount=type=cache,target=/root/.spack/cache \ + spack mirror add cache /buildcache && \ + make -f build.mk -j$(nproc) BUILDCACHE=/buildcache + +# Remove Spack metadata / Python cache to save some bytes +RUN find -L /opt/spack -type d \( -name '__pycache__' -or -name '.spack' \) -exec rm -rf {} + && \ + find -L /opt/spack -type f -name '*.a' -exec rm -rf {} + + +# Stage 2, create a small(er) docker image +FROM amazonlinux:2023 + +ENV NVIDIA_VISIBLE_DEVICES=all \ + NVIDIA_DRIVER_CAPABILITIES=compute,utility \ + LANG=C.UTF-8 \ + LC_ALL=C.UTF-8 \ + PATH=/opt/spack/view/bin:/root/spack/bin:$PATH + +COPY --from=build /opt/spack /opt/spack + +# We stick to system compilers & linkers +RUN yum install -y gcc g++ gfortran binutils && \ + yum clean all && \ + rm -rf /var/cache/yum/* diff --git a/Dockerfiles/linux-amzn2023/compilers.yaml b/Dockerfiles/linux-amzn2023/compilers.yaml new file mode 100644 index 0000000..920316f --- /dev/null +++ b/Dockerfiles/linux-amzn2023/compilers.yaml @@ -0,0 +1,16 @@ +compilers: +- compiler: + spec: clang@15.0.6 + paths: + cc: /usr/bin/clang + cxx: /usr/bin/clang++ + f77: null + fc: null + flags: + cxxflags: '-O3 -g0' + cflags: '-O3 -g0' + ldflags: '-fuse-ld=lld -Wl,-O3' + operating_system: amzn2023 + modules: [] + environment: {} + extra_rpaths: [] \ No newline at end of file diff --git a/Dockerfiles/linux-ubuntu22.04-x86_64_v2/packages.yaml b/Dockerfiles/linux-ubuntu22.04-x86_64_v2/packages.yaml deleted file mode 100644 index 68db84b..0000000 --- a/Dockerfiles/linux-ubuntu22.04-x86_64_v2/packages.yaml +++ /dev/null @@ -1,3 +0,0 @@ -packages: - all: - require: target=x86_64_v2 diff --git a/Dockerfiles/linux-ubuntu22.04-x86_64_v2/Dockerfile b/Dockerfiles/linux-ubuntu22.04/Dockerfile similarity index 76% rename from Dockerfiles/linux-ubuntu22.04-x86_64_v2/Dockerfile rename to Dockerfiles/linux-ubuntu22.04/Dockerfile index 9cf7141..d9cdae1 100644 --- a/Dockerfiles/linux-ubuntu22.04-x86_64_v2/Dockerfile +++ b/Dockerfiles/linux-ubuntu22.04/Dockerfile @@ -28,10 +28,13 @@ RUN mkdir spack && \ curl -Lfs https://github.com/spack/spack/archive/refs/heads/develop.tar.gz | tar -xzf - --strip-components=1 -C . && \ curl -Lfs https://github.com/spack/spack/pull/34926.patch | patch -p1 && \ curl -Lfs https://github.com/spack/spack/pull/35020.patch | patch -p1 && \ + curl -Lfs https://github.com/spack/spack/pull/35078.patch | patch -p1 && \ + curl -Lfs https://github.com/spack/spack/pull/35174.patch | patch -p1 && \ true -ADD spack.yaml /root/ -ADD Dockerfiles/linux-ubuntu22.04-x86_64_v2/compilers.yaml Dockerfiles/linux-ubuntu22.04-x86_64_v2/packages.yaml /root/spack/etc/spack/ +ADD spack.yaml build.mk /root/ + +ADD Dockerfiles/linux-ubuntu22.04/compilers.yaml /root/spack/etc/spack/ # Assume system make is too old RUN spack env create --with-view /root/tools tools && \ @@ -39,12 +42,10 @@ RUN spack env create --with-view /root/tools tools && \ spack -e tools concretize && \ spack -e tools install - -RUN --mount=type=cache,target=/root/.spack/cache \ - spack -e . concretize -f && \ - spack -e . install && \ - spack -e . gc --yes-to-all && \ - spack -e . env view --link run enable /opt/spack/view +RUN --mount=type=cache,target=/buildcache \ + --mount=type=cache,target=/root/.spack/cache \ + spack mirror add cache /buildcache && \ + make -f build.mk -j$(nproc) BUILDCACHE=/buildcache # Remove Spack metadata, python cache and static libraries to save some bytes RUN find -L /opt/spack -type d \( -name '__pycache__' -or -name '.spack' \) -exec rm -rf {} + && \ @@ -54,7 +55,8 @@ RUN find -L /opt/spack -type d \( -name '__pycache__' -or -name '.spack' \) -exe FROM ubuntu:22.04 ENV DEBIAN_FRONTEND=noninteractive \ - LC_ALL=C \ + LANG=C.UTF-8 \ + LC_ALL=C.UTF-8 \ PATH=/opt/spack/view/bin:/root/spack/bin:$PATH COPY --from=build /opt/spack /opt/spack diff --git a/Dockerfiles/linux-ubuntu22.04-x86_64_v2/compilers.yaml b/Dockerfiles/linux-ubuntu22.04/compilers.yaml similarity index 80% rename from Dockerfiles/linux-ubuntu22.04-x86_64_v2/compilers.yaml rename to Dockerfiles/linux-ubuntu22.04/compilers.yaml index 2b3e40d..c696e86 100644 --- a/Dockerfiles/linux-ubuntu22.04-x86_64_v2/compilers.yaml +++ b/Dockerfiles/linux-ubuntu22.04/compilers.yaml @@ -11,7 +11,4 @@ compilers: cflags: '-O3 -g0 -ffunction-sections' ldflags: '-fuse-ld=lld -Wl,-O3' operating_system: ubuntu22.04 - target: x86_64 - modules: [] - environment: {} - extra_rpaths: [] \ No newline at end of file + modules: [] \ No newline at end of file diff --git a/build.mk b/build.mk new file mode 100644 index 0000000..54fff70 --- /dev/null +++ b/build.mk @@ -0,0 +1,27 @@ +SPACK ?= spack +SPACK_INSTALL_FLAGS += --no-check-signature +BUILDCACHE = $(CURDIR)/buildcache +MAKEFLAGS += -Orecurse + +export SPACK_COLOR = always +export SPACK_BACKTRACE = yes + +.PHONY: all + +all: push + $(SPACK) -e . gc --yes-to-all + $(SPACK) -e . env view --link run enable /opt/spack/view + +include env.mk + +spack.lock: spack.yaml + $(SPACK) -e . concretize -f + +env.mk: spack.lock + $(SPACK) -e . env depfile -o $@ --make-prefix spack + +spack/push/%: spack/install/% + $(SPACK) -e . buildcache create --unsigned --allow-root --only=package $(BUILDCACHE) /$(HASH) # push $(SPEC) + +push: $(addprefix spack/push/,$(spack/SPACK_PACKAGE_IDS)) + $(SPACK) -e . buildcache update-index $(BUILDCACHE) \ No newline at end of file diff --git a/spack.yaml b/spack.yaml index 0d993c2..1312159 100644 --- a/spack.yaml +++ b/spack.yaml @@ -1,6 +1,7 @@ spack: view: false specs: + - 'awscli' - 'clingo-bootstrap@spack +optimized' - 'curl' - 'file' @@ -13,7 +14,7 @@ spack: - 'patch' - 'patchelf' - 'py-boto3' - - 'python@3.11 %clang +optimizations' + - 'python@3.11 %clang +optimizations +zlib_ng' - 'tar' - 'unzip' - 'vim' @@ -23,4 +24,14 @@ spack: install_tree: root: /opt/spack/store concretizer: - unify: true \ No newline at end of file + unify: true + packages: + all: + variants: ~nls + require: + - one_of: + - target=x86_64_v2 + - target=aarch64 + - target=ppc64le + zlib: + variants: ~shared