Closed hugglesfox closed 4 years ago
OMG I'm a fool. Just realized I spelled AARDWOLF
as AARDWOLD
then copy pasted it a bunch of times. :woman_facepalming:
Fixing now...
@haydenhughes check out https://docs.rs/config/0.10.1/config/struct.Environment.html
The Config crate already has helpers for dealing with environment variables
I've reimplemented the feature using config::Environment
. This does greatly clean up the code although doesn't allow us to have much flexibility when it comes to the naming of the environment variables as it will use what ever the name is in the config.
For an example to set the port the environment variable is currently AARDWOLF_WEB_LISTEN_PORT
which imo really should be simplified down to AARDWOLF_PORT
.
I'm not against reorganizing the config structure. If you want to rename things a bit to make it nicer to use environment variables I say go for it
I chopped .Listen
off of the end of Web.Listen
so now to change the port we have AARDWOLF_WEB_PORT
which seems reasonable to me. Shortening Database
to just DB
might be something to think about but it's not really that bad and could reduce readability in other areas of the code. I didn't want to change things up too much.
When is the .env
used? I'm guessing it's to set environment variables for diesel? Will the end user ever have to set this or is it just for tests?
Also, next thing to do is documentation. I'm guessing put it in INSTALL.md
? (could be a good opportunity to update it)
INSTALL.md is a good candidate. However, for specific tasks (PostGRE, NGINX, et. al) I've been putting into /doc/[TITLE.md]
That'll do for now when it comes to documentation. When we actually add docker support, we can put a specific docker install how to in doc/
Sorry for the last minute change, just spotted it whilst testing my docker image. Should be good to merge.
Due to the complexity of managing files in docker, app configuration is usually exclusively done by environment variables. This PR aims to add support for Aardwolf to be configured by the following environment variables in order to improve docker friendliness:
AARDWOLF_HOST
ARRDWOLF_PORT
AARDWOLF_DB_HOST
AARDWOLF_DB_PORT
AARDWOLF_DB_USER
AARDWOLF_DB_PASS
Todo before merging:
Edit: The actual names of the environment variables have changed from the proposed. See
INSTALL.md