diff --git a/files/Dockerfile.spack b/files/Dockerfile.spack index ab5eca2..5755f6b 100644 --- a/files/Dockerfile.spack +++ b/files/Dockerfile.spack @@ -6,21 +6,13 @@ COPY %APPDIR% /%APPDIR% COPY software-catalog /software-catalog COPY .spack /.spack COPY packages /packages +COPY build_spack.sh /.spack/build_spack.sh WORKDIR /packages RUN echo "Installing apt-get packages" && %APTGET_INSTALL% -RUN [ ! /%APPDIR%/spack.yaml ] && echo "No spack environment to install" || echo "Installing spack packages" && spack -C /.spack find && cat /%APPDIR%/spack.yaml \ - && spack -C /.spack compiler find && spack -C /.spack external find && spack -C /.spack -e /%APPDIR% install --fail-fast --no-checksum --keep-stage -j2 \ - && [ -f /%APPDIR%/post_inst.sh ] && sh /%APPDIR%/post_inst.sh || echo "Nothing else to do"; spack gc -y - # && spack -C /.spack mirror add binary_mirror_dev https://binaries.spack.io/develop \ - # && spack -C /.spack buildcache keys --install --trust \ - - -RUN spack -C /.spack env activate /%APPDIR% --sh >> /etc/profile.d/z10_spack_environment.sh && \ - echo "export PYTHONPATH=/opt/view/local/lib/python3.10/site-packages/:\$PYTHONPATH" >> /etc/profile.d/z10_spack_environment.sh && \ - echo "export PATH=/usr/local/bin/:\$PATH" >> /etc/profile.d/z10_spack_environment.sh +RUN sh /.spack/build_spack.sh /%APPDIR% 3.10 SHELL ["/bin/bash", "--login", "-c"] diff --git a/image_builder/build.py b/image_builder/build.py index b168dc0..09ccd35 100644 --- a/image_builder/build.py +++ b/image_builder/build.py @@ -63,6 +63,8 @@ def __init__(self, repositories_cfg, builder_cfg, registry_cfg): builder_cfg["builder_home"], "files", "run_build.sh") self.get_workflow_script = os.path.join( builder_cfg["builder_home"], "files", "get_workflow.sh") + self.spack_build_script = os.path.join( + builder_cfg["builder_home"], "files", "build_spack.sh") self.singularity_sudo = builder_cfg['singularity_sudo'] def _update_dockerfile(self, tmp_folder, step_id, machine, debs, pips): @@ -128,11 +130,8 @@ def _update_configuration(self, workflow_folder_path, machine): environment['spack']['config'] = { 'shared_linking': {'type': 'runpath'}} environment['spack']['view'] = "/opt/view" - else: - raise Exception( - "Incorrect spack environment. Not containing the spack tag.") - with open(os.path.join(workflow_folder_path, "spack.yaml"), 'w') as file: - yaml.dump(environment, file, default_flow_style=False) + with open(os.path.join(workflow_folder_path, "spack.yaml"), 'w') as file: + yaml.dump(environment, file, default_flow_style=False) return debs, pips def _generate_build_environment(self, logger, tmp_folder, workflow, machine, path): @@ -142,6 +141,7 @@ def _generate_build_environment(self, logger, tmp_folder, workflow, machine, pat debs, pips = self._update_configuration(workflow_folder_path, machine) software_repo_path = os.path.join( tmp_folder, os.path.basename(self.software_repository)) + shutil.copy2(self.spack_build_script, tmp_folder) shutil.copytree(self.software_repository, software_repo_path) spack_cfg_path = os.path.join(tmp_folder, ".spack") shutil.copytree(self.spack_cfg, spack_cfg_path)