Skip to content

Commit a09416f

Browse files
committed
Dockerfile: Update to spack v1, additional fixes
Remove refs to spack-packages Bootstrap spack earlier to clone spack-managed spack-packages Add build-time buildcache
1 parent 6292f3f commit a09416f

File tree

2 files changed

+46
-21
lines changed

2 files changed

+46
-21
lines changed

containers/Dockerfile

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,8 @@ RUN zypper ref \
131131
FROM base-os-$OS AS base-spack
132132

133133
ARG SPACK_GIT_URL=https://github.com/ACCESS-NRI/spack.git
134-
ARG SPACK_VERSION=v0.22
134+
ARG SPACK_VERSION=v1.0
135135
ARG SPACK_REPO_VERSION=releases/${SPACK_VERSION}
136-
ARG SPACK_PACKAGES_REPO_VERSION=main
137136
ARG SPACK_CONFIG_REPO_VERSION=main
138137
ARG SPACK_TARGET=x86_64
139138
ARG SPACK_CONFIG_DIR=/opt/spack-config/${SPACK_VERSION}/ci
@@ -147,9 +146,8 @@ ENV ENV_COMPILERS_SPACK_MANIFEST=/opt/compilers.spack.yaml
147146
ENV ENV_PACKAGES_SPACK_MANIFEST=/opt/packages.spack.yaml
148147

149148
# Export the repo versions for comparison in the runner target
150-
ENV SPACK_PACKAGES_REPO_VERSION=${SPACK_PACKAGES_REPO_VERSION}
151-
ENV SPACK_CONFIG_REPO_VERSION=${SPACK_CONFIG_REPO_VERSION}
152-
ENV SPACK_REPO_VERSION=${SPACK_REPO_VERSION}
149+
ENV INITIAL_SPACK_CONFIG_REPO_VERSION=${SPACK_CONFIG_REPO_VERSION}
150+
ENV INITIAL_SPACK_REPO_VERSION=${SPACK_REPO_VERSION}
153151

154152
# Export the spack config directory for the runner target
155153
ENV SPACK_CONFIG_DIR=${SPACK_CONFIG_DIR}
@@ -160,7 +158,6 @@ ENV SPACK_CONFIG_DIR=${SPACK_CONFIG_DIR}
160158
ENV SPACK_USER_CACHE_PATH=${SPACK_ROOT}/..
161159

162160
LABEL au.org.access-nri.image.spack-repo-version=${SPACK_REPO_VERSION}
163-
LABEL au.org.access-nri.image.spack-packages-repo-version=${SPACK_PACKAGES_REPO_VERSION}
164161
LABEL au.org.access-nri.image.spack-config-repo-version=${SPACK_CONFIG_REPO_VERSION}
165162

166163
SHELL ["/bin/bash", "-c"]
@@ -169,14 +166,10 @@ SHELL ["/bin/bash", "-c"]
169166
RUN <<EOF
170167
git clone -c feature.manyFiles=true ${SPACK_GIT_URL} ${SPACK_ROOT} --branch ${SPACK_REPO_VERSION}
171168

172-
# Install ACCESS-NRI's spack-packages repo
173-
git clone https://github.com/ACCESS-NRI/spack-packages.git /opt/spack-packages --branch ${SPACK_PACKAGES_REPO_VERSION}
174-
175-
# Install ACCESS-NRI's spack-config repo
169+
# Install ACCESS-NRIs spack-config repo
176170
git clone https://github.com/ACCESS-NRI/spack-config.git /opt/spack-config --branch ${SPACK_CONFIG_REPO_VERSION}
177171

178-
# Exit with ENOENT 2 "No such file or directory", if the directory does not
179-
# exist
172+
# Exit with ENOENT 2 "No such file or directory", if the directory does not exist
180173
if [ -d "${SPACK_CONFIG_DIR}" ]; then ln -s -r -v ${SPACK_CONFIG_DIR}/* ${SPACK_ROOT}/etc/spack/; else echo "${SPACK_CONFIG_DIR} does not exist!"; exit 2; fi
181174
EOF
182175

@@ -196,9 +189,19 @@ RUN ln -s ${SPACK_ROOT}/share/spack/docker/entrypoint.bash \
196189
SHELL ["docker-shell"]
197190

198191
# https://spack.readthedocs.io/en/latest/bootstrapping.html
199-
# Spack is configured to bootstrap its dependencies lazily by default;
192+
# Spack is configured to bootstrap its dependencies and repositories lazily by default;
200193
# i.e. the first time they are needed and can’t be found.
201194

195+
# Bootstrap spack and clone relevant spack-packages repos
196+
197+
# Currently, the version of spack-config informs the initial versions of the spack-packages repos to use.
198+
# If we wanted to do it manually, add this post-bootstrap
199+
# builtin_spack_packages_sha=$(git -C $(spack location --repo builtin) rev-parse "${BUILTIN_SPACK_PACKAGES_REPO_VERSION}}^{}")
200+
# access_spack_packages_sha=$(git -C $(spack location --repo access.nri) rev-parse "${ACCESS_SPACK_PACKAGES_REPO_VERSION}}^{}")
201+
# spack repo update builtin --commit $builtin_spack_packages_sha
202+
# spack repo update access.nri --commit $access_spack_packages_sha
203+
RUN spack bootstrap now
204+
202205
################################################################################
203206
# Install compilers and other common packages
204207
FROM base-spack AS upstream
@@ -207,7 +210,18 @@ LABEL org.opencontainers.image.source=https://github.com/ACCESS-NRI/build-ci
207210

208211
# Install compilers and low-level, common packages
209212
COPY ${SOURCE_COMPILERS_SPACK_MANIFEST} ${ENV_COMPILERS_SPACK_MANIFEST}
210-
RUN <<EOF
213+
RUN --mount=type=secret,id=oci-username,env=OCI_USERNAME \
214+
--mount=type=secret,id=oci-password,env=OCI_PASSWORD \
215+
--mount=type=secret,id=oci-url,env=OCI_URL \
216+
<<EOF
217+
spack mirror add \
218+
--scope=system \
219+
--autopush \
220+
--unsigned \
221+
--oci-username-variable OCI_USERNAME \
222+
--oci-password-variable OCI_PASSWORD \
223+
docker_build_buildcache $OCI_URL
224+
211225
echo "Installing compilers"
212226
spack env activate compilers --create --envfile ${ENV_COMPILERS_SPACK_MANIFEST}
213227
spack spec
@@ -220,16 +234,32 @@ yq '.spack.specs[]' "${ENV_COMPILERS_SPACK_MANIFEST}" | while read compiler; do
220234
done
221235

222236
spack clean --downloads --stage
237+
238+
spack mirror remove --scope=system docker_build_buildcache
223239
EOF
224240

225241
COPY ${SOURCE_PACKAGES_SPACK_MANIFEST} ${ENV_PACKAGES_SPACK_MANIFEST}
226-
RUN <<EOF
242+
RUN --mount=type=secret,id=oci-username,env=OCI_USERNAME \
243+
--mount=type=secret,id=oci-password,env=OCI_PASSWORD \
244+
--mount=type=secret,id=oci-url,env=OCI_URL \
245+
<<EOF
246+
247+
spack mirror add \
248+
--scope=system \
249+
--autopush \
250+
--unsigned \
251+
--oci-username-variable OCI_USERNAME \
252+
--oci-password-variable OCI_PASSWORD \
253+
docker_build_buildcache $OCI_URL
254+
227255
echo "Installing common packages"
228256
spack env activate packages --create --envfile ${ENV_PACKAGES_SPACK_MANIFEST}
229257
spack install --deprecated --fail-fast || exit
230258
spack env deactivate
231259

232260
spack clean --downloads --stage
261+
262+
spack mirror remove --scope=system docker_build_buildcache
233263
EOF
234264

235265
################################################################################
@@ -240,8 +270,5 @@ LABEL org.opencontainers.image.source=https://github.com/ACCESS-NRI/build-ci
240270
# Set up ACCESS Spack buildcache
241271
RUN spack mirror add --scope=system --autopush --unsigned runner_set_buildcache /opt/runner_set_buildcache
242272

243-
# Bootstrap Spack now to avoid doing it on first runner use, every time
244-
RUN spack bootstrap now
245-
246273
ENTRYPOINT ["/bin/bash", "/opt/spack/share/spack/docker/entrypoint.bash"]
247274
CMD ["interactive-shell"]

containers/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ This folder contains the `Dockerfile` and `compose.*.yaml` files needed to build
88

99
Furthermore, those images download upstream compilers and common packages informed by the `upstream/[dev|prod]/[packages|compilers].spack.yaml` spack manifests.
1010

11-
Finally, there is a `spack-config` folder that contains a customised [spack-enable.bash](https://github.com/ACCESS-NRI/spack-config/blob/main/spack-enable.bash) used to load `spack`, as well as upstream compilers.
12-
1311
## How to build `spack` for testing
1412

1513
You can use spack in a similar way to `build-ci`, with it's own upstream `spack` used for compilers and common packages. This is also suitable for developers to test. Run the following Docker Compose commands:
@@ -26,4 +24,4 @@ When finished, you can run the following to shut down the services:
2624
docker compose -f containers/compose.dev.yaml down --volumes
2725
```
2826

29-
Users can modify `SPACK_PACKAGES_REPO_VERSION`/`SPACK_CONFIG_REPO_VERSION`, among other things, from within the docker compose file before running `docker compose build`.
27+
Users can modify the `SPACK_CONFIG_REPO_VERSION`, among other things, from within the docker compose file before running `docker compose build`.

0 commit comments

Comments
 (0)