Alfred Alfred - 1 year ago 363
Java Question

Dropwizard config override

I am developing a RESTful service with Dropwizard. Now I need deploy it to different environment(test, staging, prod) & data centers(cn, us, etc). As such, it needs different config for different environment/data-center.

Curious how is this usually handled? I could potentially have one config for each env/dc, but in that case, they will have a lot of duplication of common config.

I was expecting that I have a base config, say base.yaml, containing the common configs; And then each environment&DC will have one config, which extend/override the base yaml with their custom config. Is this possible within Dropwizard?

Thank you!

Answer Source

I don't think DropWizard has that feature, but you can always write a small script that composes a few YAML files and starts DropWizard with the result. You can use a simple template engine like Mustache for it.


# ...
    - type: http
      port: {{PORT}}


PORT: "8080"

And then use:

mustache config-parms-us.yml config-template.yml > config.yml
java ... server config.yml