containerfile
The containerfile module is a tool for adding custom Containerfile instructions for custom image builds. This is useful when you wish to use some feature directly available in a Containerfile, but not in a bash module, such as using a RUN instruction with custom mounts.
Since standard compiler-based BlueBuild image builds generate a Containerfile from your recipe, there is no need to manage it yourself. However, we know that we also have technical users that would like to have the ability to customize their Containerfile. This is where the containerfile module comes into play.
snippets:
Section titled “snippets:”The snippets property is the easiest to use when you just need to insert a few custom lines to the Containerfile. Each entry under the snippets property will be directly inserted into your final Containerfile for your build.
modules: - type: containerfile snippets: - RUN --mount=type=tmpfs,target=/tmp /some/script.shThis makes it really easy to add individual, custom instructions.
containerfiles:
Section titled “containerfiles:”The containerfiles property allows you to tell the compiler which directory contains a Containerfile in ./containerfiles/.
Below is an example of how a containerfile module would be used with the containerfiles property:
modules: - type: containerfile containerfiles: - example - subroutineIn the example above, the compiler would look for these files:
./containerfiles/example/Containerfile./containerfiles/subroutine/Containerfile
You could then store files related to say the subroutine Containerfile in ./containerfiles/subroutine/ to keep it organized and portable for other recipes to use.
Order of operations
Section titled “Order of operations”The order of operations is important in a Containerfile. There’s a very simple set of rules for the order in this module:
- For each defined
containerfilemodule:- First all
containerfiles:are added to the mainContainerfilein the order they are defined - Then all
snippetsare added to the mainContainerfilein the order they are defined
- First all
If you wanted to have some snippets run before any containerfiles have, you will want to put them in their own module definition before the entry for containerfiles. For example:
modules: - type: containerfile snippets: - RUN --mount=type=tmpfs,target=/tmp /some/script.sh - type: containerfile containerfiles: - example - subroutineIn the example above, the COPY from the snippets will always come before the containerfiles “example” and “subroutine”.
Example configuration
Section titled “Example configuration”type: containerfilesnippets: - RUN --mount=type=tmpfs,target=/tmp /some/script.shcontainerfiles: - example - subroutineConfiguration options
Section titled “Configuration options”snippets: (optional array)
Section titled “snippets: (optional array)”Lines to directly insert into the generated Containerfile.
containerfiles: (optional array)
Section titled “containerfiles: (optional array)”Names of directories in ./containerfiles/ containing each a Containerfile to insert into the generated Containerfile.