-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support to configs via environment variables #45
Comments
From readme You can run and configure these values using these environment variables: PORT=8080 |
Yeah, but this don't work with docker. It should? |
As an example, this do not work:
|
I believe you have to expose the environment variable via the env flag |
You are absolutely right @bsedat. I forgot that. I tested this on ElasticBeastalk, which expose the envs for me and as you said, it didn't work. |
The docker image uses the release generated by It would be possible to translate ENV variables to these terms today but soon we will support multiple apps (#43) and this will become really complex to handle through ENV variables. I suggest managing the .conf file. I'm not sure what's the best way to mount a file through ElasticBeanstalk but I will give it a try this weekend and report back here. |
@edgurgel Hi! PS. Please tag docker image 0.4.3 as latest. |
My previous comment is still valid and the env variables won't handle the configuration as soon as we move to multiple apps. Then I would need to support both ways :/ I will tag the latest as 0.4.3! |
@edgurgel I see the problem, its impossible to pass hashes to env vars, but its easy to add one "if" to check if ENV vars are valid and ignore config. It will enable both env and config ways. And env is good way to use according to http://12factor.net/config Also, if you use shared application settings (for pusher gem), you only need to point it to env var and have no problems with sharing settings from yml (rails) to poxa. |
If I keep the env vars as config they will be limited to a single application as already discussed. I would like to keep the priority of configuration like this:
I'm not sure how to accomplish this with the current schema. |
But in this case ENV vars in docker image is unusable. |
Ok, but how we can fix docker image? It comes with config and totally ignores ENV vars. Is it possible to fix it? |
@edgurgel Could you please share Dockerfile? I can try to build custom poxa image with support on env vars |
Poxa doesn't have a Dockerfile as it uses Even if you build your own image it won't load as ENV vars are load only by mix config (https://github.com/edgurgel/poxa/blob/master/config/config.exs#L9) and mix is not available as part of a release. The heroku buildpack uses mix to run it by default and that's why it works with ENV vars there. You can always just build a docker image using mix to run it if you want to. You would run with something like this: https://github.com/edgurgel/poxa#deploying-on-heroku |
@edgurgel Thats really strange behaviour. So there are no easy way to use ENV vars in docker? |
There's but we would need to change current code to load them if there's no config available OR you would need to build a docker image using mix to run it (which is not the way exrm releases work) |
My argument is that it's not a good change as soon these ENV vars won't work for multiple apps soon. |
One thing you can do is build your own Dockerfile based on the original edip image like this.
This would result in a preconfigured Docker image that you can easily deploy from your private repository. |
@SLAMPER Problem is you need private docker repository |
You've got a point there. To use env variables in the docker container you only have to change a few lines in the code. But as soon as multi app support will be implemented this will be broken as edgurgel pointed out. |
@SLAMPER Actually, I think we need to write a script that generates poxa config from env variables if they are present. We simply run it before running docker container. |
@arrowcircle that's a good idea. I just wrote a super simple dirty script which does this. It also uses the $POXA_APP_COUNT env variable to check how many apps we have and also supports multiple apps as far as I could get how they work from the multi-app branch. For the Docker container we will then need a script that calls this script first, |
If we agree with this solution we can add this script to the poxa docker image as a helper script. |
@edgurgel I'm currently working on a small buildscript that can easily build the container with this script in the startup. Also this script only works in bash and the edip image only has ash so it will need some changes. I will get back when I've got something that is working |
Ok I fixed the script and it works with the container. I put the simple container on git: https://github.com/Slamper/easy_poxa If you want to add the scripts to the official image feel free to do so. I will then delete my repo :) |
@arrowcircle Happy New Year too. |
Hey guys1 Happy New Year! Maybe start with a simple script and as soon as the multiple apps branch lands we can move to the one that supports multiple apps? I'm keen to move this forward these next weeks. |
I simplified the script in my master branch to only support the single app version. |
We have good news! There's a new option on conform that understands env vars (at least for "default values") when you don't define a I will give it a try this weekend, also moving to distillery (no more exrm). |
To use the docker image, I have to create a config file and copy it to the container (like this). It would be easier (maybe better) to configure this settings by environment variables.
I'm deploying to AWS Elastic Beanstalk and If it were possible to configure by environment variables I will be able to get the app up and running just by configuring the env vars on AWS Console and creating a file like this:
Dockerrun.aws.json
I'm new to Elixir, so, I'm not familiar with Mix. From what I understand, the config.exs file is already getting some configs from env vars, but, this code is executed only on docker image generation command is executed (
MIX_ENV=prod mix edip --prefix edgurgel
) and not on the application initialization. So, it doesn't help who is trying to use the docker image. Right?The text was updated successfully, but these errors were encountered: