Skip to content

Commit

Permalink
feat: install most dependencies in cacheable layer, before adding main
Browse files Browse the repository at this point in the history
  • Loading branch information
wdconinc committed Dec 29, 2023
1 parent 18374c4 commit be65f11
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 16 deletions.
14 changes: 9 additions & 5 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ variables:
DOCKER_IMAGE: docker.io/docker:24.0.7
SINGULARITY_IMAGE: quay.io/singularity/singularity:v3.11.5

## Application versions used for the main release
## Default versions are specified in packages.yaml but can be overridden
## note: nightly builds will always use the master/main branch
JUGGLER_VERSION: "v13.0.0"
EICRECON_VERSION: "v1.9.1"
JUGGLER_VERSION: ""
EICRECON_VERSION: ""

## Local registry
CI_PUSH: 1
Expand Down Expand Up @@ -337,8 +337,12 @@ jug_dev:
--build-arg S3_SECRET_KEY=${S3_SECRET_KEY}
--build-arg JUG_VERSION=${EXPORT_TAG}-${BUILD_TYPE}-$(git rev-parse HEAD)
${IF_BUILD_DEFAULT:+
--build-arg JUGGLER_VERSION=${JUGGLER_VERSION}
--build-arg EICRECON_VERSION=${EICRECON_VERSION}
${JUGGLER_VERSION:+--build-arg JUGGLER_VERSION=${JUGGLER_VERSION}}
${EICRECON_VERSION:+--build-arg EICRECON_VERSION=${EICRECON_VERSION}}
}
${IF_BUILD_NIGHTLY:+
--build-arg JUGGLER_VERSION=main
--build-arg EICRECON_VERSION=main
}
--build-arg ENV=${ENV}
--build-arg jobs=${JOBS}
Expand Down
47 changes: 38 additions & 9 deletions containers/jug/dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -123,28 +123,57 @@ EOF
## ========================================================================================
FROM spack as builder

## Setup our custom environment (secret mount for write-enabled mirror)
## 1. Setup our default environment (secret mount for write-enabled mirror)
COPY --from=spack-environment . /opt/spack-environment/
ARG ENV=dev
ARG JUGGLER_VERSION="main"
ADD https://api.github.com/repos/eic/juggler/commits/${JUGGLER_VERSION} /tmp/juggler.json
ARG EICRECON_VERSION="main"
ADD https://api.github.com/repos/eic/eicrecon/commits/${EICRECON_VERSION} /tmp/eicrecon.json
ENV SPACK_ENV=/opt/spack-environment/${ENV}
RUN --mount=type=cache,target=/ccache,id=${TARGETPLATFORM} \
--mount=type=cache,target=/var/cache/spack \
--mount=type=secret,id=mirrors,target=/opt/spack/etc/spack/mirrors.yaml \
<<EOF
set -e
export CCACHE_DIR=/ccache
source ${SPACK_ROOT}/share/spack/setup-env.sh
mkdir -p /var/cache/spack/blobs/sha256/
find /var/cache/spack/blobs/sha256/ -atime +7 -delete
JUGGLER_VERSION=$(jq -r .sha /tmp/juggler.json)
EICRECON_VERSION=$(jq -r .sha /tmp/eicrecon.json)
spack buildcache update-index eics3rw
spack env activate --dir ${SPACK_ENV}
spack add juggler@git.${JUGGLER_VERSION}
spack add eicrecon@git.${EICRECON_VERSION}
spack concretize --fresh --force --quiet
make --jobs ${jobs} --keep-going --directory /opt/spack-environment \
SPACK_ENV=${SPACK_ENV} \
BUILDCACHE_OCI_PROMPT="eicweb" \
BUILDCACHE_OCI_FINAL="ghcr" \
BUILDCACHE_S3_FINAL="eics3rw"
ccache --show-stats
ccache --zero-stats
EOF

## 2. Setup our environment with custom versions (on top of cached layer)
## Note: these default versions are just the very first commit.
ARG JUGGLER_VERSION="df87bf1f8643afa8e80bece9d36d6dc26dfe8132"
ARG EICRECON_VERSION="28108da4a1e8919a05dfdb5f11e114800a2cbe96"
ADD https://api.github.com/repos/eic/juggler/commits/${JUGGLER_VERSION} /tmp/juggler.json
ADD https://api.github.com/repos/eic/eicrecon/commits/${EICRECON_VERSION} /tmp/eicrecon.json
RUN --mount=type=cache,target=/ccache,id=${TARGETPLATFORM} \
--mount=type=cache,target=/var/cache/spack \
--mount=type=secret,id=mirrors,target=/opt/spack/etc/spack/mirrors.yaml \
<<EOF
source ${SPACK_ROOT}/share/spack/setup-env.sh
export CCACHE_DIR=/ccache
spack buildcache update-index eics3rw
spack env activate --dir ${SPACK_ENV}
if [ "${JUGGLER_VERSION}" != "df87bf1f8643afa8e80bece9d36d6dc26dfe8132" ] ; then
export JUGGLER_VERSION=$(jq -r .sha /tmp/juggler.json)
spack config add "packages:juggler::require:['@git.${JUGGLER_VERSION}=main']"
spack deconcretize -y juggler
fi
if [ "${EICRECON_VERSION}" != "28108da4a1e8919a05dfdb5f11e114800a2cbe96" ] ; then
export EICRECON_VERSION=$(jq -r .sha /tmp/eicrecon.json)
spack config add "packages:eicrecon::require:['@git.${EICRECON_VERSION}=main']"
spack deconcretize -y eicrecon
fi
cat ${SPACK_ENV}/spack.yaml
cat ${SPACK_ENV}/../packages.yaml
spack concretize --fresh --force --quiet
make --jobs ${jobs} --keep-going --directory /opt/spack-environment \
SPACK_ENV=${SPACK_ENV} \
Expand Down
2 changes: 1 addition & 1 deletion eic-spack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ EICSPACK_ORGREPO="eic/eic-spack"

## EIC spack commit hash or github version, e.g. v0.19.7
## note: nightly builds could use a branch e.g. releases/v0.19
EICSPACK_VERSION="5d8ba97ea6b021a50aa11e924a55a4726c689d65"
EICSPACK_VERSION="bc6a4382636dd8c8bcd8c665163840815d48a25e"

## Space-separated list of eic-spack cherry-picks
read -r -d '' EICSPACK_CHERRYPICKS <<- \
Expand Down
2 changes: 2 additions & 0 deletions spack-environment/dev/spack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ spack:
- edm4eic
- edm4hep
- eic-smear
- eicrecon
- eigen
- emacs
- fastjet
Expand All @@ -40,6 +41,7 @@ spack:
- iwyu
- jana2
- k4actstracking
- juggler
- k4fwcore
- lcov
- lhapdf
Expand Down
4 changes: 4 additions & 0 deletions spack-environment/packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ packages:
eic-smear:
require:
- '@1.1.12'
eicrecon:
require:
- '@1.9.1'
eigen:
require:
- '@3.4.0'
Expand Down Expand Up @@ -160,6 +163,7 @@ packages:
- -ipo +podio +root +zmq
juggler:
require:
- '@13.0.0'
- cxxstd=20
k4actstracking:
require:
Expand Down
4 changes: 3 additions & 1 deletion spack-environment/prod/spack.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
spack:
include:
include:
- ../concretizer.yaml
- ../packages.yaml
config:
Expand All @@ -9,6 +9,7 @@ spack:
- cmake
- dd4hep -ddeve
- edm4eic
- eicrecon
- fastjet
- fjcontrib
- gaudi
Expand All @@ -17,6 +18,7 @@ spack:
- intel-tbb
- irt
- jana2
- juggler
- npsim -geocad
- py-boto3
- py-jinja2
Expand Down

0 comments on commit be65f11

Please sign in to comment.