diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6999aa94..daa6d9a2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -423,8 +423,6 @@ jug_xl:default: --build-arg BASE_IMAGE=${BASE_IMAGE} --build-arg INTERNAL_TAG=${INTERNAL_TAG}-default --build-arg JUG_VERSION=${EXPORT_TAG}-$(git rev-parse HEAD) - --build-arg jobs=${JOBS} - --build-context detectors=. --provenance false containers/jug 2>&1 | tee build.log @@ -503,8 +501,6 @@ jug_xl:nightly: --build-arg INTERNAL_TAG=${INTERNAL_TAG}-nightly --build-arg JUG_VERSION=${EXPORT_TAG}-nightly-$(git rev-parse HEAD)-$(date +%Y-%m-%d_%H-%M-%S) --build-arg NIGHTLY=1 - --build-arg jobs=${JOBS} - --build-context detectors=. --provenance false containers/jug 2>&1 | tee build.log diff --git a/containers/jug/dev.Dockerfile b/containers/jug/dev.Dockerfile index b66e7b45..5ec5f4b9 100644 --- a/containers/jug/dev.Dockerfile +++ b/containers/jug/dev.Dockerfile @@ -212,16 +212,16 @@ ccache --show-stats ccache --zero-stats EOF -## Create views at /usr/local and /opt/detectors +## Create views at /usr/local and /opt/detector RUN <> ${SPACK_ENV}/spack.yaml spack -e ${SPACK_ENV} env view regenerate /usr/local -spack -e ${SPACK_ENV} env view regenerate /opt/detectors -if [[ -n $NIGHTLY && -f /opt/detectors/epic ]] ; then - ln -s /opt/detectors/epic-main/setup.sh /opt/detectors/setup.sh +spack -e ${SPACK_ENV} env view regenerate /opt/detector +if [[ -n $NIGHTLY && -f /opt/detector/epic ]] ; then + ln -s /opt/detector/epic-main/setup.sh /opt/detector/setup.sh fi EOF @@ -314,7 +314,7 @@ COPY --from=staging /opt/spack /opt/spack COPY --from=staging /opt/spack-environment /opt/spack-environment COPY --from=staging /opt/software /opt/software COPY --from=staging /usr/._local /usr/._local -COPY --from=staging /opt/._detectors /opt/._detectors +COPY --from=staging /opt/._detector /opt/._detector COPY --from=staging /etc/profile.d /etc/profile.d COPY --from=staging /etc/jug_info /etc/jug_info COPY --from=staging /etc/eic-env.sh /etc/eic-env.sh @@ -328,13 +328,13 @@ SHELL ["docker-shell"] ## ensure /usr/local is the view, not a symlink RUN < Nightly requested, will default configurations to nightly') - else: - print(' --> Regular run, nightly snapshot will NOT be installed') - - print(' --> Loading detector configuration') - default_found = False - default_detector = '' - default_version = '' - with open(args.config) as f: - data=yaml.load(f, Loader=yaml.FullLoader) - detectors=data['detectors'] - for det in detectors: - if not args.nightly and 'nightly' in detectors[det]: - del detectors[det]['nightly'] - for branch in detectors[det]: - cfg = detectors[det][branch] - default_str = '' - if not default_found: - if args.nightly and branch == 'nightly': - default_str = ' (default)' - default_detector = det - default_version = 'nightly' - default_found = True - elif not args.nightly and 'default' in cfg and cfg['default']: - default_str = ' (default)' - default_detector = det - default_version = cfg['version'] - default_found = True - print(' - {}: {}{}'.format(det, branch, default_str)) - print(' --> Building and installing detector libraries') - process_list = [] - for det in detectors: - if not args.nightly and 'nightly' in detectors[det]: - del detectors[det]['nightly'] - for branch in detectors[det]: - cfg = detectors[det][branch] - version = cfg['version'] if branch != 'nightly' else 'nightly' - prefix = '{}/{}-{}'.format(args.prefix, det, version) - data_dir = '{}/share/{}'.format(prefix, det) - ## build and install - print(' - {}-{}'.format(det, cfg['version'])) - ## cleanup - cmd = [f'rm -rf /tmp/build-{version} /tmp/det-{version}'] - print(' '.join(cmd)) - subprocess.check_call(' '.join(cmd), shell=True) - ## clone - cmd = [ - 'git clone --depth 1 -b {branch} {repo_grp}/{detector}.git /tmp/det-{version}'.format( - branch=cfg['version'], - repo_grp=DETECTOR_REPO_GROUP, - detector=det, - version=version) - ] - print(' '.join(cmd)) - subprocess.check_call(' '.join(cmd), shell=True) - ## patches - if cfg.get('patches'): - for patch in cfg['patches']: - cmd = [f'curl -L {patch} | patch -p1 -d/tmp/det-{version}'] - print(' '.join(cmd)) - subprocess.check_call(' '.join(cmd), shell=True) - ## build - cxxflags = '' - if 'CXXFLAGS' in os.environ: - cxxflags = os.environ['CXXFLAGS'] - if cfg.get('cxxflags'): - cxxflags = cfg['cxxflags'] - cmd = [ - f'cmake -B /tmp/build-{version} -S /tmp/det-{version} -DCMAKE_CXX_STANDARD=17', - f'-DCMAKE_CXX_FLAGS="-Wno-psabi {cxxflags}"', - f'-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache', - f'-DCMAKE_INSTALL_PREFIX={prefix}' - ] - print(' '.join(cmd)) - subprocess.check_call(' '.join(cmd), shell=True) - ## install - cmd = [ - f'cmake --build /tmp/build-{version} -j$(($(($(nproc)/4))+1)) -- install' - ] - print(' '.join(cmd)) - subprocess.check_output(' '.join(cmd), shell=True) - ## write version info to jug_info if available - if os.path.exists('/etc/jug_info'): - cmd = [f'cd /tmp/det-{version}', - '&&', - 'echo " - {detector}/{branch}: {version}-$(git rev-parse HEAD)"'.format( - detector=det, - branch=branch, - version=cfg['version']), - '>> /etc/jug_info', - '&&', - 'cd -'] - print(' '.join(cmd)) - subprocess.check_call(' '.join(cmd), shell=True) - ## cleanup - cmd = f'rm -rf /tmp/det-{version} /tmp/build-{version}' - print(cmd) - subprocess.check_call(cmd, shell=True) - # be resilient against failures - if os.path.exists(prefix): - ## create a shortcut for the prefix if desired - if branch != version: - cmd = 'rm -rf {shortcut} && ln -sf {prefix} {shortcut}'.format( - prefix=prefix, - shortcut='{}/{}-{}'.format(args.prefix, det, branch)) - print(cmd) - subprocess.check_call(cmd, shell=True) - ## write an environment file for this detector - with open('{prefix}/setup.sh'.format(prefix=prefix), 'w') as f: - print(DETECTOR_ENV.format( - prefix=prefix, - detector=det, - data_prefix=data_dir, - version=cfg['version'], - branch=branch), - file=f) - - ## run once inside global prefix to initialize artifacts in /opt/detectors - # os.environ['DETECTOR_PATH'] = args.prefix - # cmd = f'cd {args.prefix} && source {prefix}/setup.sh && ddsim --compactFile {prefix}/share/{det}/{det}.xml --printLevel DEBUG -G -N1' - # print(cmd) - # process_list.append(subprocess.Popen(cmd, shell=True, executable='/bin/bash', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) - - ## run once inside specific prefix to initialize artifacts in $DETECTOR_PATH - os.environ['DETECTOR_PATH'] = args.prefix - cmd = f'cd {prefix}/share/{det} && source {prefix}/setup.sh && ddsim --compactFile {prefix}/share/{det}/{det}.xml --printLevel DEBUG -G -N1' - print(cmd) - process_list.append(subprocess.Popen(cmd, shell=True, executable='/bin/bash', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)) - - while len(process_list) > 0: - now = datetime.now() - current_time = now.strftime("%H:%M:%S") - print("{} processes running... ({})".format(len(process_list), current_time)) - (out, err) = process_list[-1].communicate() - if process_list[-1].wait() != 0: - print(process_list[-1].args) - if out is not None: - print("stdout:") - print(out.decode()) - if err is not None: - print("stderr:") - print(err.decode()) - sys.exit(1) - process_list.pop() - - if not default_found and not args.nightly: - # Skip symlinking if no defaults present and its not a nightly build - pass - else: - print(' --> Symlinking default detector for backward compatibility') - full_prefix='{}/{}-{}'.format(args.prefix, default_detector, default_version) - cmd = ['ln -sf {full_prefix}/share {short_prefix}', - '&&', - 'ln -sf {full_prefix}/lib {short_prefix}', - '&&', - 'ln -sf {full_prefix}/setup.sh {short_prefix}'] - print(' '.join(cmd)) - subprocess.check_call(' '.join(cmd).format(full_prefix=full_prefix, short_prefix=args.prefix), shell=True) - - print('All done!') diff --git a/containers/jug/xl.Dockerfile b/containers/jug/xl.Dockerfile index b445e636..178bcde8 100644 --- a/containers/jug/xl.Dockerfile +++ b/containers/jug/xl.Dockerfile @@ -10,32 +10,8 @@ ARG INTERNAL_TAG="testing" FROM ${DOCKER_REGISTRY}${BASE_IMAGE}:${INTERNAL_TAG} ARG TARGETPLATFORM -ARG EICWEB="https://eicweb.phy.anl.gov/api/v4/projects" -ARG jobs=1 - ## version will automatically bust cache for nightly, as it includes ## the date ARG JUG_VERSION=1 RUN echo " - jug_xl: ${JUG_VERSION}" >> /etc/jug_info - -## also install detector/ip geometries into opt -ARG NIGHTLY='' -## cache bust when updated repositories -# - just master on eicweb (FIXME too narrow) -ADD ${EICWEB}/473/repository/tree?ref=master /tmp/473.json -ADD ${EICWEB}/452/repository/tree?ref=master /tmp/452.json -# - all branches for ip6 and epic on github -ADD https://api.github.com/repos/eic/ip6 /tmp/ip6.json -ADD https://api.github.com/repos/eic/epic /tmp/epic.json -COPY setup_detectors.py /tmp -COPY --from=detectors detectors.yaml /tmp -RUN --mount=type=cache,target=/ccache/,sharing=locked,id=${TARGETPLATFORM} <