Skip to content

Commit 4522350

Browse files
Stephen Sachsalalazo
andauthored
aws-pcluster: install gcc in the image and upload the build cache as an artifact (#30)
Install GCC in the same location where spack pipelines will build. This enables the prefix location to relocate the compiler paths in the apps correctly. Also, postinstall.sh will install gcc from hash, so there is no risk that gcc will build from source in the pipeline. `config.yaml` should stay constant, but is part of another repo `spack/spack`. We will keep a copy around and issue a warning when running cloud_pipelines if the file has changed. Co-authored-by: Massimiliano Culpo <[email protected]>
1 parent 0afe160 commit 4522350

File tree

4 files changed

+69
-13
lines changed

4 files changed

+69
-13
lines changed

.github/workflows/containers.yml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
[e4s-amazonlinux-2, e4s-amazonlinux-2.dockerfile, 'linux/amd64,linux/arm64'],
4141
[e4s-centos-7, e4s-centos-7.dockerfile, 'linux/amd64'],
4242
[e4s-fedora-36, e4s-fedora-36.dockerfile, 'linux/amd64,linux/ppc64le,linux/arm64'],
43-
[pcluster-amazonlinux-2, pcluster-amazonlinux-2.dockerfile, 'linux/amd64,linux/arm64']]
43+
[pcluster-amazonlinux-2, pcluster-amazonlinux-2/Dockerfile, 'linux/amd64,linux/arm64']]
4444
name: Build ${{ matrix.dockerfile[0] }}
4545
steps:
4646
- name: Checkout
@@ -79,3 +79,42 @@ jobs:
7979
ghcr.io/spack/${{ matrix.dockerfile[0] }}:latest
8080
${{ steps.meta.outputs.tags }}
8181
cache-to: type=inline
82+
83+
upload-gcc-buildcache:
84+
timeout-minutes: 60
85+
runs-on: self-hosted
86+
permissions:
87+
packages: write
88+
needs: [ deploy-images ]
89+
env:
90+
CONTAINER_NAME: 'ghcr.io/spack/pcluster-amazonlinux-2'
91+
steps:
92+
- name: Get Container Tag
93+
id: meta
94+
uses: docker/metadata-action@v4
95+
with:
96+
images: ${{ env.CONTAINER_NAME }}
97+
- uses: actions/checkout@v3
98+
- env:
99+
CONTAINER_TAG: ${{ steps.meta.outputs.tags }}
100+
run: |
101+
id=$(docker create --platform linux/amd64 ${CONTAINER_TAG})
102+
mkdir bootstrap-gcc-cache-x86_64
103+
docker cp $id:/bootstrap-gcc-cache bootstrap-gcc-cache-x86_64
104+
docker rm -v $id
105+
106+
id=$(docker create --platform linux/arm64 ${CONTAINER_TAG})
107+
mkdir bootstrap-gcc-cache-aarch64
108+
docker cp $id:/bootstrap-gcc-cache bootstrap-gcc-cache-aarch64
109+
docker rm -v $id
110+
111+
- uses: actions/upload-artifact@v3
112+
with:
113+
name: bootstrap-gcc-cache-x86_64
114+
path: |
115+
bootstrap-gcc-cache-x86_64
116+
- uses: actions/upload-artifact@v3
117+
with:
118+
name: bootstrap-gcc-cache-aarch64
119+
path: |
120+
bootstrap-gcc-cache-aarch64

Dockerfiles/pcluster-amazonlinux-2.dockerfile renamed to Dockerfiles/pcluster-amazonlinux-2/Dockerfile

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,25 @@ RUN curl -sOL https://efa-installer.amazonaws.com/aws-efa-installer-${EFA_INSTAL
109109
&& cd .. \
110110
&& rm -rf aws-efa-installer-${EFA_INSTALLER_VERSION}.tar.gz aws-efa-installer
111111

112-
# Bootstrap spack compiler installation
113-
RUN mkdir -p /bootstrap && \
114-
cd /bootstrap && \
115-
git clone https://github.com/spack/spack spack \
116-
&& export SPACK_ROOT=/bootstrap/spack \
117-
&& . spack/share/spack/setup-env.sh \
118-
&& curl -sOL https://raw.githubusercontent.com/spack/spack-configs/main/AWS/parallelcluster/postinstall.sh \
119-
&& /bin/bash postinstall.sh -fg -nointel \
120-
&& spack clean -a \
121-
&& cd /bootstrap/spack \
122-
&& find . -type f -maxdepth 1 -delete \
123-
&& rm -rf bin lib share var /root/.spack
112+
# Bootstrap spack compiler installation into the eventual installation tree
113+
# Defined in spack/share/spack/gitlab/cloud_pipelines/configs/config.yaml
114+
ARG SPACK_ROOT="/bootstrap-compilers/spack"
115+
# commit after https://github.com/spack/spack/pull/34821
116+
ARG SPACK_COMMIT=f27d012
117+
ARG TARGETARCH
118+
COPY Dockerfiles/pcluster-amazonlinux-2/${TARGETARCH}/packages.yaml /root/.spack/packages.yaml
119+
RUN mkdir -p $(dirname "${SPACK_ROOT}") \
120+
&& git clone https://github.com/spack/spack "${SPACK_ROOT}" \
121+
&& pushd "${SPACK_ROOT}" && git checkout ${SPACK_COMMIT} && popd \
122+
&& cp "${SPACK_ROOT}/share/spack/gitlab/cloud_pipelines/configs/config.yaml" "${SPACK_ROOT}/etc/spack/config.yaml" \
123+
&& cp "${SPACK_ROOT}/share/spack/gitlab/cloud_pipelines/configs/config.yaml" "/bootstrap/cloud_pipelines-config.yaml" \
124+
&& . "${SPACK_ROOT}/share/spack/setup-env.sh" \
125+
&& spack compiler add \
126+
&& spack external find \
127+
&& spack tags build-tools | xargs -I {} spack config rm packages:{} \
128+
&& spack install gcc \
129+
&& spack buildcache create -a -u /bootstrap-gcc-cache $(spack find --format '/{hash}') \
130+
&& rm -rf $(dirname "${SPACK_ROOT}") /root/.spack
124131

125132
ENV PATH=/bootstrap/runner/view/bin:$PATH \
126133
NVIDIA_VISIBLE_DEVICES=all \
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
--- # GCC setup for all AMD64 based targets
2+
packages:
3+
gcc:
4+
compiler: [gcc]
5+
require: "gcc@12 +binutils ^[email protected] target=x86_64_v3"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
--- # GCC setup for all ARM64 based targets
2+
packages:
3+
gcc:
4+
compiler: [gcc]
5+
require: "gcc@12 +binutils ^[email protected] target=aarch64"

0 commit comments

Comments
 (0)