chainguard-images / images

Public Chainguard Images
https://chainguard.dev/chainguard-images
Apache License 2.0
546 stars 147 forks source link

Generic Environment Substitution Solution #435

Open amouat opened 1 year ago

amouat commented 1 year ago

Which image/versions are related to this issue/feature request?

All images that have configuration options, especially those that use a configuration file.

Issue/Feature description

Many container images from other providers support env var substitution - that is you can docker something like docker run -e MYPORT=5000 myimage to configure options on the image that would normal require editing and volume mounting a config file.

This is fairly simple to do with a shell script and envsbst (https://man7.org/linux/man-pages/man1/envsubst.1.html). But it's a little more difficult in a minimal container without pulling in a shell (which I really don't want to do). My suggestion is to create a small reusable binary that runs as an entrypoint and doees this for us. We could extend: https://github.com/wolfi-dev/container-entrypoint

dlorenc commented 1 year ago

+1 on doing this as a small rust/go binary!

amouat commented 1 year ago

The only thing that gives me pause is it's not very transparent; if it was a bash script it's a lot easier to see what's going on.

imjasonh commented 1 year ago

The only thing that gives me pause is it's not very transparent; if it was a bash script it's a lot easier to see what's going on.

I think a little static Go binary would be great, and not require a shell anymore.

Having to reimplement parts of some bash commands (like command) seems like it might be annoying, but ultimately being able to have the benefits of an entrypoint.sh without a shell seems valuable.

leksmano commented 1 year ago

would it be possible to support functionality similar to the templates described here: https://github.com/docker-library/docs/tree/master/nginx#using-environment-variables-in-nginx-configuration-new-in-119 ?

vicious-dahlia commented 1 year ago

Please add this feature, it's necessary for many practical uses of nginx.

black-snow commented 7 months ago

I currently use https://gitlab.com/black-snow/env-dump in some places. I could extend it if you tell me what you need.

ericsmalling commented 5 months ago

Just heard from another customer that relies on this feature for nginx

ctr49 commented 5 months ago

How about using renvsubst instead of envsubst - this should be more aligned with the minimal container image approach.

kevinneufeld commented 4 months ago

We also rely on this feature, which is the primary reason we cannot use the chainguard image as is.

smythp commented 2 months ago

Thought I'd ask about the status of this feature since I'm updating the nginx README.