hanami.github.io
hanami.github.io copied to clipboard
Environment Variables guide
Right now we use dotenv in development and test environments, but not production. This issue has effected several people in the chat.
We should consider adding a guide for Environment variables. Specifically, explain how they're set in development and test, as well as offer some suggestions for how to set them in production (heroku config:set,.env.production combined with an entry in .gitignore, or even .bashrc).
We can talk about SERVE_STATIC_ASSETS and APPNAME_SESSIONS_SECRET there too.
Which section do you see that fitting best under in the Guide? Dotenv is easy enough but the SERVE_STATIC_ASSETS + heroku may be tricky for some.
@cllns Please do 👍 Be sure to make clear the security concerns of having a .env file in source control.
@jodosha why not add ^.env.production to the initially generated .gitignore?
I noticed HANAMI_ENV is nowhere mentioned in the guides.
I also had trouble finding documentation on HANAMI_ENV, took me some trial and error, especially when running database migrations for test environment.
I'd love to help documenting this, but similar to the comment by @vladdypwnz, I'm new to Hanami and not sure where a section on environment variables belongs in the Guides. If anyone could give some pointers, that would be great.
@schnittchen
why not add
^.env.productionto the initially generated.gitignore?
Because .env.production isn't generated by Hanami, and because for production env it MUST NOT be used. You should set env variables via your VPS/Cloud provider.
@cllns I think this guide should be under Guides -> Projects section.
It should include the details mentioned in the comment above ☝️ and how to use Dotenv.