Skip to content

spack containerize: permit to customize the base images#15028

Merged
scheibelp merged 13 commits intospack:developfrom
alalazo:container/minimal_approach
Nov 17, 2020
Merged

spack containerize: permit to customize the base images#15028
scheibelp merged 13 commits intospack:developfrom
alalazo:container/minimal_approach

Conversation

@alalazo
Copy link
Copy Markdown
Member

@alalazo alalazo commented Feb 17, 2020

closes #14802
closes #14879

This PR reworks a few attributes in the container subsection of spack.yaml to permit the injection of custom base images both in the build and final stage. In more detail, users can still specify the base operating system and Spack version they want to use:

spack:
  container:
    images:
      os: ubuntu:18.04
      spack: develop

in which case the generated recipe will use one of the Spack images built on Docker Hub for the build stage and the base OS image in the final stage or alternatively they can specify explicitly the two base images:

spack:
  container:
    images:
      build: spack/ubuntu-bionic:latest
      final: ubuntu:18.04

and it will be up to them to ensure their consistency. The ability to install OS packages in both the build and final stage has been retained. Handles to avoid an update of the available system packages have been added to the configuration to facilitate the generation of recipes permitting deterministic builds.

Following the discussion in #14917 this PR takes at the moment a minimalist approach and thus removed the possibility to install OS packages in the generated image (if any is needed it should be the custom base image that takes care of that). In case this seems unwanted it will be sufficient to drop commit ed71483 to make this PR compatible with #14917 and #14879.

@alalazo alalazo added feature A feature is missing in Spack containers labels Feb 17, 2020
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Feb 17, 2020

@samcmill
Copy link
Copy Markdown
Contributor

My 2 cents is to retain the ability to install OS packages in the image.

The rationale is to have something in-between the canned images (zero effort but zero control) and custom images (lots of control but potentially lots of effort).

Copy link
Copy Markdown
Contributor

@hartzell hartzell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this. Few inline comments.

@alalazo alalazo force-pushed the container/minimal_approach branch from ed71483 to 05fded7 Compare February 21, 2020 13:31
@alalazo alalazo self-assigned this Feb 25, 2020
@reidpr
Copy link
Copy Markdown
Contributor

reidpr commented Mar 5, 2020

Thanks for your hard work on this PR.

May I make a friendly request? Can everyone please use gender-neutral language when describing users? For example, instead of “a user can still specify ... Spack version he wants to use”, write “a user can still specify ... Spack version they want to use”.

Among lots of other good reasons, this would be in keeping with the Spack COC, e.g. the admonition to use “inclusive language”.

@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Mar 5, 2020

@reidpr Edit done. I'll have a look at the docs later and adjust it too if I find anything. Thanks.

@victorusu
Copy link
Copy Markdown
Contributor

This is great! please merge!

@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Mar 6, 2020

@hartzell Do you have further requests wrt to docs or anything else?

@scheibelp scheibelp self-assigned this Mar 10, 2020
@scheibelp scheibelp self-requested a review March 10, 2020 18:04
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Mar 11, 2020

@svenevs I thought that given the positive comment in Spack's slack on spack containerize you might be interested in this PR 🙂

@tgamblin tgamblin self-assigned this Mar 24, 2020
Copy link
Copy Markdown
Member

@scheibelp scheibelp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few minor requests but overall I think that "build"/"final" and "os"/"spack" are duplicate ways to specify the same thing, which I think is confusing. I added more detail (and what I'd like to see change) in the comment prefixed with "main concern".

Copy link
Copy Markdown
Contributor

@hartzell hartzell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not in a position to test this right now, but it looks good. Thanks!

@alalazo alalazo force-pushed the container/minimal_approach branch from 63333ba to 86b08ba Compare April 14, 2020 12:12
@alalazo alalazo force-pushed the container/minimal_approach branch from 86b08ba to 40c0337 Compare May 4, 2020 14:33
@alalazo alalazo force-pushed the container/minimal_approach branch from 5a452de to 5e91dd9 Compare May 12, 2020 09:35
@alalazo alalazo force-pushed the container/minimal_approach branch from 5e91dd9 to d8f1713 Compare June 18, 2020 12:36
@alalazo alalazo force-pushed the container/minimal_approach branch from d8f1713 to d6acdd2 Compare June 26, 2020 13:07
@hartzell
Copy link
Copy Markdown
Contributor

hartzell commented Jul 9, 2020

This might be off tangent, but since I mentioned it in my experiment above....

I "want" to use CentOS and/but I need to use newer compilers. My solution to that is to include [email protected] in the build image, but I discovered that I also need to include it in the final image. If I remove it, various libraries end up missing. E.g. bcl2fastq2 depends on boost which ends up needing the libgomp in the gcc install tree. (Oddly enough, libgomp is included in the example, but even if I use the yum version I end up missing other things).

So, in spite of vary carefully doing a multistage build, I end up with a fairly large image (gcc is about 1.2GB). I could thin it by carefully trimming most of the gcc install tree (leaving just lib and lib64 might work), but that seems fragile.

Is there something else I could/should be doing (don't say CentOS8...), or is this a fact of life?

@hartzell
Copy link
Copy Markdown
Contributor

Hi All. Any movement on this?

@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Oct 15, 2020

@hartzell I'm keeping this PR rebased semi-frequently. Will try to have it merged for the next major release.

@hartzell
Copy link
Copy Markdown
Contributor

Great. I'm currently running spack containerize and piping the output through sed, so I'll look forward to this landing.

FWIW, my custom builder pre-builds gcc while my custom final needs to include our internal root CA certs.

Is there a timeframe for the next major release?

@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Oct 15, 2020

Is there a timeframe for the next major release?

Before SC next month 🙂

@hartzell
Copy link
Copy Markdown
Contributor

Woo hoo! Thanks!

@alalazo alalazo force-pushed the container/minimal_approach branch from 63711bb to 70f5151 Compare October 19, 2020 09:10
@alalazo alalazo mentioned this pull request Oct 30, 2020
2 tasks
The ``base`` attribute has been renamed to ``images``
while the ``base:image`` attribute has been renamed
``images:os``.

This commit is in preparation of a generalization
to permit the use of custom base images in both the
build and final stage.
The ``images`` attribute has now another mode of
operation where users can specify both a ``build``
and a ``final`` custom base image.
Since now the base images can be customized it's redundant
to also have a configure option to install os packages.
Also fixed indentation as Paul suggested in another review.
@alalazo alalazo force-pushed the container/minimal_approach branch from 70f5151 to b0a3dd3 Compare November 16, 2020 13:42
The documentation has been updated according to reviews.
Examples have been extended and the "Setting Base Images"
section has been divided into two subsections - one for
each selection method.
Copy link
Copy Markdown
Member

@scheibelp scheibelp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main request is to address whitespace handling in the template files (see https://github.com/spack/spack/pull/15028/files#r399576494). The rest of the comments are very minor (generally typos).

@scheibelp scheibelp merged commit 5f636fc into spack:develop Nov 17, 2020
@alalazo alalazo deleted the container/minimal_approach branch November 17, 2020 19:25
lorak41 pushed a commit to lorak41/spack that referenced this pull request Feb 19, 2021
* releases/v0.16: (6003 commits)
  update CHANGELOG.md for v0.16.0
  bump version number to 0.16.0
  clingo: add `master` branch version (spack#19958)
  cmd: add `spack mark` command (spack#16662)
  spack test (spack#15702)
  Added -level_zero -rocm -opencl flags and sha256 for TAU v2.30. (spack#19962)
  Improve warning message for deprecated attributes in "packages.yaml"
  Documentation: spack load/environments prefix inspections (spack#19961)
  spack load/environments: allow customization of prefix inspections (spack#18260)
  spack containerize: allow users to customize the base image (spack#15028)
  concretizer: modified weights for providers and matching for externals
  concretizer: maximize the number of default values used for a single variant
  concretizer: don't require a provider for virtual deps if spec is external
  concretizer: spec_clauses() shouldn't emit node_compiler_hard for rule bodies.
  concretizer: don't generate rules for empty version lists
  concretizer: add a rule to avoid cycles in the graph of dependencies
  External packages have a consistent hash across different concretizers
  Don't fail if MV variants have a tuple as default value
  Fixup for target preferences
  Added unit tests to for regressions on open concretizer bugs
  ...

# Conflicts:
#	.gitignore
#	lib/spack/spack/binary_distribution.py
#	lib/spack/spack/cmd/setup.py
#	lib/spack/spack/modules/common.py
#	var/spack/repos/builtin/packages/med/package.py
#	var/spack/repos/builtin/packages/mofem-cephas/package.py
#	var/spack/repos/builtin/packages/mofem-fracture-module/package.py
#	var/spack/repos/builtin/packages/mofem-users-modules/package.py
#	var/spack/repos/builtin/packages/mpich/package.py
#	var/spack/repos/builtin/packages/petsc/package.py
#	var/spack/repos/builtin/packages/python/package.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

containers feature A feature is missing in Spack

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Additional containerize spec file customization

10 participants