lemmy icon indicating copy to clipboard operation
lemmy copied to clipboard

Add back support for Env vars

Open Nutomic opened this issue 4 years ago • 1 comments

Was broken by #1433. We should be able to support env vars again with the same behaviour as before, by following the example in https://github.com/softprops/envy/issues/55#issuecomment-787482221.

Edit: The solution is not going to work, because of another Envy issue: https://github.com/softprops/envy/issues/26

$ LEMMY_CAPTCHA__ENABLED=false LEMMY_CAPTCHA__DIFFICULTY=easy cargo run
Finished dev [unoptimized] target(s) in 0.15s
Running `target/debug/lemmy_server`
thread 'main' panicked at 'invalid type: string "false", expected a boolean'

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Nutomic avatar Mar 01 '21 17:03 Nutomic

I tried another crate, envconfig to implement this, but its missing many required features. All other related libraries I found are really small and unmaintained. So it looks like we would have to reimplement this functionality from scratch, which we dont have time for. This means configuration with env vars will not be supported in the next version, and probably not for a long time (except for a few specific vars which we can handle manually).

Nutomic avatar Mar 10 '21 13:03 Nutomic

I'm creating a Helm chart for Lemmy Kubernetes deployments, and envs would be useful for setting default chart values. Would you consider reopening this issue?

gabe565 avatar Jun 13 '23 05:06 gabe565

I think it'd be too much work. Is there any reason you can't use a lemmy.hjson file?

dessalines avatar Jun 13 '23 14:06 dessalines

Got it! Essentially, I would like to generate some of the config values, but using hjson might make it a bit more challenging. I can still generate the file, though, since regular JSON is valid hjson, it will just introduce some additional complexity and make things less dynamic.

For instance, if the user configures my Helm chart to deploy Pictrs, I could automatically generate an API key and store it as a Secret. Then, both pictrs and lemmy could use that secret to set the env. When using a config file, I'll need to generate and set the value explicitly in JSON. It makes the configuration less dynamic, but it's not a major issue.

I'll see if there's an elegant way for me to generate the hjson file. Thank you! 🙂

gabe565 avatar Jun 14 '23 00:06 gabe565