php
php copied to clipboard
Add build argument for debug image
I understand that #879 likely won't be solved any time soon but I'd like to at least add a support for an ARG so that I can easily checkout this repository and build a debug image myself like this:
docker build --pull --no-cache 8.1/bullseye/cli --build-arg DEBUG=1
What do you think?
EDIT: Partially reverted. It is now meant to be used together with #1280. This way the condition added in 1280 makes more sense because it can be true without any modifications to the Dockerfile.
thanks for providing an alternative to https://github.com/docker-library/php/pull/1280
all other templating args are defined in https://github.com/docker-library/php/blob/master/versions.json#L7 and regenerating the DockerFiles is easy, thus I think it should be better to allow variants suffixed by -debug as a debug switch
but this is up too the maintainers to decide, currently, I patched our debug build with https://github.com/docker-library/php/pull/1280 which works well and the condition is 1:1 with the one added in https://github.com/docker-library/php/pull/1278 , so I like my PR slightly more to keep the condition consistency
In my opinion they should be used together... your PR to prevent stripping and mine to let ppl avoid manually editing the Dockerfiles. It also means that the condition in your PR can be true without any modifications to the Dockerfile.
Extra variants in versions.json are likely not possible because that would essentially be #879.
@tianon What do you think about this?
I'm definitely not a fan of ARG - it ends up polluting the history of every layer following it in the image metadata. :disappointed:
@tianon I see. And what if we put the ARG all the way down before the first layer that will actually use it? It's in fact nearly the last layer so most of them will be untouched.
While that definitely would be a problem, I'd rather not complicate the Dockerfile with parts that make it uncertain how it was built. While build-args are not used in official images and it is unlikely we would ever add them, many new users may not know that. The Dockerfile then becomes uncertain as to what the published images on Docker Hub may contain.
It's easy to add a comment about that next to the ARG.
@tianon @yosifkit Okay, if ARG isn't the way to go then how about just having a support in the template to generate debug Dockerfiles? My goal is to have a somewhat easy way to build the debug image I need. Something like:
- Clone
docker-library/php - Run a script to generate debug Dockerfiles, let's say
sh ./apply-templates.sh --debug - Run
docker build ...to generate the debug image I need.
I simply want to avoid having to do custom modifications to this repo's sources every time I want a new image. Would something like that be acceptable?
ping @tianon @yosifkit
We have been trying to debug a segmentation fault and this would help us alot!
having a support in the template to generate debug Dockerfiles?
I was finally able to come back to this; here is what I've come up with that fits with the current scripts: https://github.com/docker-library/php/pull/1364