ansible-builder
ansible-builder copied to clipboard
Allow Customization of `builder` stage
I'm using ansible-builder
0.4.0
, which is hardcoded to use quay.io/ansible/python-builder
as the base for the builder
stage.
This is very limiting for me for a couple of reasons:
- I need to pull dependencies through a private Artifactory instance which is using a private CA cert and I have no way of getting that CA certificate to the container image right now.
- I need to pull dependencies through a private Artifactory instance and I can't tell pip in the
builder
stage to do so. If I put--extra-index-url
or even--index-url
at the top of myrequirements.txt
, I get the following warning:/Users/brandonmcnama/.local/pipx/venvs/ansible/lib/python3.9/site-packages/requirements/parser.py:44: UserWarning: Private repos not supported. Skipping.
- The python-builder image has a particular version of Python installed, which means I'm forced to use that same version of Python in my base image.
I'd like to propose the following:
- Allow the user to specify a builder image to use in the execution environment manifest.
- Allow the user to specify "before" and "after" steps that are prepended and appended to the instructions for the
builder
stage specifically.
Allow the user to specify "before" and "after" steps that are prepended and appended to the instructions for the builder stage specifically.
Point taken, but, I would put this at much lower priority than supporting the builder
image itself, because you can solve the same problem with customizing your base builder
image.
In #160, we are changing the base image customization to a build arg. This is so that in a sequence of commands of ansible-builder build
and then later podman build
, the user can apply a custom setting to podman build
as needed. This approach makes it obvious how to support a custom builder
image, which is to make it a build argument in the syntax of the Containerfile/Dockerfile.
Point taken, but, I would put this at much lower priority than supporting the
builder
image itself, because you can solve the same problem with customizing your basebuilder
image.
This only solves doing things before, not after, and it makes those things less discoverable than having them declared in the execution env manifest. IMO it should be both, but I agree that customizing the steps around the builder is lower priority than allowing an arbitrary builder image to be used.
In #160, we are changing the base image customization to a build arg. This is so that in a sequence of commands of
ansible-builder build
and then laterpodman build
, the user can apply a custom setting topodman build
as needed. This approach makes it obvious how to support a custombuilder
image, which is to make it a build argument in the syntax of the Containerfile/Dockerfile.
Sounds good!
With https://github.com/ansible/ansible-builder/pull/167, we allow customizing the build arg PYTHON_BUILDER_IMAGE
. You can do this with --build-arg
CLI or in the definition file. This is not yet released.
We still have no means of adding custom steps anywhere in that stage of the Containerfile.
I will leave this open referring to that request.
We could technically do this now. Maybe it could be a new key under additional_build_steps
other than prepend / append?
Hi, I would like to change the python version. I've set this in my config:
build_arg_defaults:
PYTHON_BUILDER_IMAGE: python:3.10
And I have this error:
ansible_builder.exceptions.DefinitionError: Keys {'PYTHON_BUILDER_IMAGE'} are not allowed in 'build_arg_defaults'
@Sispheor Thanks for the request. We are currently working on this feature, you can track this under https://github.com/users/nitzmahone/projects/1 - "Dynamic base/builder images"
OK it has been renamed to EE_BUILDER_IMAGE
.
Changing the python version should be documented guys ! 🙂 Here I need to dig into the python builder/ansible builder and understand all the thing to make a new image.
@Sispheor Would you be interested in opening documentation PR with your findings, I will be more than happy to help you out. Thanks in advance.
It was costless to allow my lib to support python 3.8 🙂.
That being said you'll find some example in the issues made by the community.
It will require more effort as the official image of CentOS with python 3.10 doesn't exist yet. But it's feasible.
It would just have been nice to have it documented somewhere.
I believe the latest ansible-builder 3.0 release should provide all the mechanisms you need to do the things you want now. No builder image is required (or even accepted). All stages are based off of the specified base image, and we have prepend
and append
instruction points for each builder stage.
Closing this as completed. Please let us know if you encounter any bugs with the newest version!