Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

dockerTools: use epoch for layers and mtime #281443

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tomberek
Copy link
Contributor

The UX improvement of a recent time is primarily for the image itself and seldom used for layers and individual file.

Description of changes

The discussion in #47005 is about the date of an image, but there is far less usage of the time of a layer. This change makes all layers use epoch as mtime and for creation date, but still allows for overriding with "now" for the image itself. The intent is to allow greater re-use of image layers in a container storage subsystem.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • [x ] sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
  • Fits CONTRIBUTING.md.

Add a 馃憤 reaction to pull requests you find important.

Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

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

Seems like a good idea.
TODO:

  • document this behavior in the manual
  • add a release note in the breaking changes section
    • web servers and perhaps other services can be sensitive to mtime
      • e.g. when serving a store path, make sure your responses do not have a Last-Modified header
  • test in nixos/tests/docker-tools.nix
  • explain why the customization layer mtime is still impure, and/or fix that too (and => when it's configurable)

pkgs/build-support/docker/stream_layered_image.py Outdated Show resolved Hide resolved
The UX improvement of a recent time is primarily for the image itself
and seldom used for layers and individual file.
@@ -373,7 +373,7 @@ See [](#ex-dockerTools-buildLayeredImage-hello) to see how to do that.
# Building a layered Docker image

The following package builds a layered Docker image that runs the `hello` executable from the `hello` package.
The Docker image will have name `hello` and tag `latest`.
The Docker image will have name `hello` and tag `latest`. The created image can have a current timestamp when setting the `created` parameter to "now" - this will only affect the image, not the individual layers.
Copy link
Member

Choose a reason for hiding this comment

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

This is not the place to add this information. The buildLayeredImage section is a thin wrapper for the streamLayeredImage section, which is where you should add the extra sentence instead.

Adding this information either in the general area for streamLayeredImage (the content before the "Inputs" subheading) or in the documentation of the created attribute seems fine to me.

Also, when moving the text, please make sure you put one sentence per line to make it easier to review documentation. See https://github.com/NixOS/nixpkgs/blob/master/doc/README.md#documentation-conventions

@DanielSidhion
Copy link
Member

Note for whoever merges this (or for myself after it's merged): please close #255396 since it conflicts with these changes.

@@ -49,6 +49,8 @@ The pre-existing [services.ankisyncd](#opt-services.ankisyncd.enable) has been m

- `himalaya` was updated to v1.0.0-beta, which introduces breaking changes. Check out the [release note](https://github.com/soywod/himalaya/releases/tag/v1.0.0-beta) for details.

- `dockerTools.streamLayeredImage` created layers with mtimes using the "now" argument for the `created` parameter. It now uses UNIX time of "1" for the mtime of layers. It will still use "now" for the last customization layer and for setting the creation date of the image itself. This leads to greater re-use of layers between different images.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- `dockerTools.streamLayeredImage` created layers with mtimes using the "now" argument for the `created` parameter. It now uses UNIX time of "1" for the mtime of layers. It will still use "now" for the last customization layer and for setting the creation date of the image itself. This leads to greater re-use of layers between different images.
- `dockerTools.streamLayeredImage` previously created layers with mtimes using the "now" argument for the `created` parameter. It now uses UNIX time of "1" for the mtime of layers. It will still use "now" for the last customization layer and for setting the creation date of the image itself. This leads to greater re-use of layers between different images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants