Docker enviroment variables in releases ?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Docker enviroment variables in releases ?

lmdthel
Hi list!

Any good solutions for using Docker enviroment variables in an Erlang release running i Docker ?

Like it would be really cool to override default sys.config settings when starting the container with -e SOME_SYS_CONFIG_SETTING=1234

Thomas

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Docker enviroment variables in releases ?

Dmitry Kolesnikov-2
Hello,

I’ve built a simple wrapper over application:env and os:get_env for this type of purpose.
https://github.com/fogfish/feta/blob/master/src/opts.erl

In sys.config you define
```
{myapp, [
   {port, {env, "CONFIG_MYAPP_PORT", "8080”}}
...
```

In erlang code:
```
Port = opts:val(port, myapp)
```
Then this function would check value of CONFIG_MYAPP_PORT variable and return it. The default value is return if env is not defined.

If any one finds this feature useful for other projects, I can think of evolving this feature further on.

Best Regards,
Dmitry

> On 2 Mar 2019, at 10.49, Thomas Elsgaard <[hidden email]> wrote:
>
> Hi list!
>
> Any good solutions for using Docker enviroment variables in an Erlang release running i Docker ?
>
> Like it would be really cool to override default sys.config settings when starting the container with -e SOME_SYS_CONFIG_SETTING=1234
>
> Thomas
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Docker enviroment variables in releases ?

Roger Lipscombe-2
In reply to this post by lmdthel
If you're using relx (and if you're using rebar3 or erlang.mk, you
probably are), it already supports simple environment substitution.
Use ${VAR} in "sys.config.src".

On Sat, 2 Mar 2019 at 08:49, Thomas Elsgaard <[hidden email]> wrote:

>
> Hi list!
>
> Any good solutions for using Docker enviroment variables in an Erlang release running i Docker ?
>
> Like it would be really cool to override default sys.config settings when starting the container with -e SOME_SYS_CONFIG_SETTING=1234
>
> Thomas
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Docker enviroment variables in releases ?

lmdthel
Thanks to Dmitry and Roger, very useful ... I will look into it..

Thomas

On Sat, 2 Mar 2019 at 16:02 Roger Lipscombe <[hidden email]> wrote:
If you're using relx (and if you're using rebar3 or erlang.mk, you
probably are), it already supports simple environment substitution.
Use ${VAR} in "sys.config.src".

On Sat, 2 Mar 2019 at 08:49, Thomas Elsgaard <[hidden email]> wrote:
>
> Hi list!
>
> Any good solutions for using Docker enviroment variables in an Erlang release running i Docker ?
>
> Like it would be really cool to override default sys.config settings when starting the container with -e SOME_SYS_CONFIG_SETTING=1234
>
> Thomas
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions