rubygems / gemstash

A RubyGems.org cache and private gem server
MIT License
752 stars 120 forks source link

Support config file in /etc #369

Closed kyrofa closed 11 months ago

kyrofa commented 11 months ago

We run gemstash in a read-only Docker container. A persistent volume is mounted to a particular directory, and that's the base path for Gemstash. We ship the gemstash config in /etc/gemstash/config.yml, because it's a system-wide config and that's generally where those live. It's a bit annoying to constantly have to include --config-file when adding new authorizations and whatnot, though. How would folks feel about checking /etc/gemstash/config.yml in addition to the ~/.gemstash/config.yml that is checked today? Or, barring that, having gemstash support an environment variable to point to its config file?

olleolleolle commented 11 months ago

Or, an environment variable doing what --config-file is doing? (Hehe, I just saw your earlier title for this Issue.)

The Configuration class mentions a file in $HOME that you could perhaps overwrite in your Docker container?

  DEFAULT_FILE = File.expand_path("~/.gemstash/config.yml").freeze
olleolleolle commented 11 months ago

But, all workarounds aside, I welcome a more flexible way of choosing one's configuration in Gemstash!

(Made me think of: Bundler's BUNDLE prefixes connected to config options, and XDG prefixes in https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html.)

kyrofa commented 11 months ago

Or, an environment variable doing what --config-file is doing? (Hehe, I just saw your earlier title for this Issue.)

Yeah this went through a few quick iterations in place before I was happy with it :stuck_out_tongue: .

Ultimately, we want to be able to have our config file in /etc. We don't even have a /home/gemstash directory, for example. Workarounds are definitely possible (we can create one and probably get away with a symlink from ~/.gemstash/config.yml), but I wanted to float both options for having real support for this, and see what you thought:

  1. Change the "default" logic from simply checking ~/.gemstash/config.yml to having a few fallback paths: ~/.gemstash/config.yml if it exists, and if it doesn't, check /etc/gemstash/config.yml (or a similar system-wide place, I'm open to alternatives there)
  2. Support an environment variable for --config-file (e.g. GEMSTASH_CONFIG) that we can set to /etc/gemstash/config.yml in our container

Again, workarounds are possible, and this is only an annoyance in the first place. So please feel free to say this isn't something you're interested in and I will harbor no hard feelings. But if we can support (1) or (2), it'll be even easier to run a dockerized Gemstash.

In case it's unclear, I'm happy to do the legwork of adding whichever option you prefer, I just wanted to log the issue and have this conversation before striking out in a direction. Do you favor (1) or (2)? Or prefer not to do this?

olleolleolle commented 11 months ago

I think 2 is closest to what we have now, in terms of configuration options, so that would give us some flexibility without inventing much.

kyrofa commented 11 months ago

Okay, I'll make a PR.