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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFE: formalize Containerfile workflow for custom stage outputs #5529

Open
owtaylor opened this issue May 15, 2024 · 0 comments
Open

RFE: formalize Containerfile workflow for custom stage outputs #5529

owtaylor opened this issue May 15, 2024 · 0 comments
Labels
jira Issues which will be sync'd to a card at https://issues.redhat.com/projects/RUN

Comments

@owtaylor
Copy link

See also: containers/podman#12605

In some cases, we want a Containerfile to take control of generating layer contents and metadata in very specific ways. Examples:

  • bootc images - the tooling wants to divide up layers to improve the efficiency of the update process
  • Flatpaks - the tooling wants to add labels with generated metadata like the base64-encoded icon

This is somewhat possible currently, you can do this by mounting the context directory (or a subdirectory) read-write, writing a container image there, then making the next stage inherit that with a containers-transports url - FROM oci-archive:out.ociarchive.

But there are some downsides:

  • The FROM oci-archive:out.ociarchive is not context-relative, it's just a filesystem path interpreted relative to the working directory of buildah. This is inconsistent: in all other cases (COPY, run --mount, etc.) referenced filesystem paths are context-relative and are restricted to being a subdirectory of the context dir, and also creates a problem that the Containefile no longer is independent of the context dir specified on the buildah build line - a Containerfile might only work with a context-dir of ., for example.
  • Because buildah doesn't really understand what is going on, it considers the stage outputing the oci archive to be unused. It's necessary to either use --skip-unused-stages=false or make a dummy reference to the stage (see the bootc Containerfile above for an example.)
  • Having to use the context dir as scratch space isn't ideal - it might be desirable to to have the context dir read-only, or it might be on a filesystem with limited space.

Ideally, it would be possible to do something like:

FROM --container=from=export,type=oci-archive,src=/tmp/out.ociarchive

Though just fixing the path issue would already be an improvement.

Possible Questions

Couldn't this just be scripted using individual buildah commands? Why is a Containerfile necessary?

One place where we want to use this is as part of the Konflux build service. In this case, it's very desirable to separate out the specification of what we build (via a Containerfile) from the mechanics of how we build it (with different resource limits, on multiple architectures, etc.) Having to customize the build task mixes the two up creating an explosion of different possible tasks. It's also quite desirable to be able to just give a developer a Containerfile and say "this is how you build a Flatpak", compared to a (possibly complex) shell script.

What about compatibility with other Containerfile consumers

All I can say here is that while FROM oci-archive:<path> isn't a syntax extension to the Containerfile spec, it's still a Buildah specific extension.

@nalind nalind added the jira Issues which will be sync'd to a card at https://issues.redhat.com/projects/RUN label May 15, 2024
owtaylor added a commit to owtaylor/build-definitions that referenced this issue May 15, 2024
In certain cases, having a context set could change the meaning of a
Containerfile. See:

containers/buildah#5529

For details of a situation affecting Flatpaks and bootc images. This
applies to both to any context from the CONTEXT parameter, and the
implicit context from SOURCE_CODE_DIR. To avoid any possible problems,
just change to the context directory and use a context argument of .
owtaylor added a commit to owtaylor/build-definitions that referenced this issue May 16, 2024
Expose the --skip-unused-stages argument to Buildah as a parameter.
This is needed to handle certain Containerfiles where stages have
hidden side-effects like writing things to the context directory.

See containers/buildah#5529 for
details.
owtaylor added a commit to owtaylor/build-definitions that referenced this issue May 16, 2024
Expose the --skip-unused-stages argument to Buildah as a parameter.
This is needed to handle certain Containerfiles where stages have
hidden side-effects like writing things to the context directory.

See containers/buildah#5529 for
details.
owtaylor added a commit to owtaylor/build-definitions that referenced this issue May 16, 2024
Expose the --skip-unused-stages argument to Buildah as a parameter.
This is needed to handle certain Containerfiles where stages have
hidden side-effects like writing things to the context directory.

See containers/buildah#5529 for
details.
owtaylor added a commit to owtaylor/build-definitions that referenced this issue May 16, 2024
Expose the --skip-unused-stages argument to Buildah as a parameter.
This is needed to handle certain Containerfiles where stages have
hidden side-effects like writing things to the context directory.

See containers/buildah#5529 for
details.
github-merge-queue bot pushed a commit to konflux-ci/build-definitions that referenced this issue May 16, 2024
In certain cases, having a context set could change the meaning of a
Containerfile. See:

containers/buildah#5529

For details of a situation affecting Flatpaks and bootc images. This
applies to both to any context from the CONTEXT parameter, and the
implicit context from SOURCE_CODE_DIR. To avoid any possible problems,
just change to the context directory and use a context argument of .
owtaylor added a commit to owtaylor/build-definitions that referenced this issue May 21, 2024
Expose the --skip-unused-stages argument to Buildah as a parameter.
This is needed to handle certain Containerfiles where stages have
hidden side-effects like writing things to the context directory.

See containers/buildah#5529 for
details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira Issues which will be sync'd to a card at https://issues.redhat.com/projects/RUN
Projects
None yet
Development

No branches or pull requests

2 participants