docker-nginx icon indicating copy to clipboard operation
docker-nginx copied to clipboard

[Feature Request] Custom envsubst for templating with default values

Open Friz-zy opened this issue 2 years ago • 5 comments

The problem: by default nginx in docker uses GNU envsubst that can't proceed variables with default values like ${var:-DEFAULT}. We can use a8m envsubst or stephenc envsub instead, the first one has already had a prebuilded binary for x86_64 arch and it can be easily builded with docker and golang in a separate build stage.

Friz-zy avatar Oct 28 '21 16:10 Friz-zy

What is an actual use case for that? If you're providing a template, you surely control what's inside of a template and can just not use whatever is not supported by envsubst?

thresheek avatar Oct 28 '21 16:10 thresheek

You can create a universal template with defaults and reduce amount of variables to passing into container. Something like resolver ${RESOLVER_URL:-127.0.0.11} valid=${RESOLVER_TTL:-30s} ipv6=off; in resolver.conf.template. Without this behaviour you have to keep all this defaults values in docker-compose\helm\other things that you use for configuring and templating your setups.

Friz-zy avatar Oct 28 '21 17:10 Friz-zy

OK. But that means extra work for redoing templates in different environments that might have different defaults...

Anyway, that proposal would also mean we will have to build non-GNU envsubst for all supported platforms manually. I'm leaving it open, but it's definitely not on top of a things to implement.

thresheek avatar Oct 29 '21 08:10 thresheek

I'm also interested in this capability. It can simplify image configuration a lot

presidentio avatar Mar 29 '23 08:03 presidentio

I would love to have this feature as well! The idea is to have templates where most of the variables are optional, so you can run the application with little configuration, but still can be highly configurable if needed.

ernestojpg avatar Jun 02 '23 17:06 ernestojpg