php icon indicating copy to clipboard operation
php copied to clipboard

Add build argument for debug image

Open enumag opened this issue 3 years ago • 9 comments

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.

enumag avatar Apr 04 '22 14:04 enumag

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

mvorisek avatar Apr 04 '22 16:04 mvorisek

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.

enumag avatar Apr 04 '22 18:04 enumag

@tianon What do you think about this?

enumag avatar May 05 '22 04:05 enumag

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 avatar May 05 '22 18:05 tianon

@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.

enumag avatar May 05 '22 18:05 enumag

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.

yosifkit avatar May 05 '22 18:05 yosifkit

It's easy to add a comment about that next to the ARG.

enumag avatar Jun 10 '22 04:06 enumag

@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:

  1. Clone docker-library/php
  2. Run a script to generate debug Dockerfiles, let's say sh ./apply-templates.sh --debug
  3. 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?

enumag avatar Jul 11 '22 13:07 enumag

ping @tianon @yosifkit

enumag avatar Sep 09 '22 07:09 enumag

We have been trying to debug a segmentation fault and this would help us alot!

taka-oyama avatar Jan 23 '23 07:01 taka-oyama

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

yosifkit avatar Jan 26 '23 23:01 yosifkit