Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ERB in env file? #501

Closed
benlieb opened this issue Apr 9, 2024 · 3 comments
Closed

Use ERB in env file? #501

benlieb opened this issue Apr 9, 2024 · 3 comments

Comments

@benlieb
Copy link

benlieb commented Apr 9, 2024

Is there any way to parse this first with ERB (using Rails)?

Similar to how yml files work:

  url: <%= ApplicationConfig.defaults("REDIS_URL") %>
  channel_prefix: threadable_api_production
@gcentauri
Copy link

i've been using yml files with config_for(:the_thing) to get the ENV files into rails

# config/the_thing.yml
shared:
  base_url: <%= ENV["BASE_URL"] %>
  admin_password: <%= ENV["ADMIN_PASSWORD"] %>

does this get you what you need? rather than trying to run ruby and interpolate in the .env file

@benlieb
Copy link
Author

benlieb commented Apr 30, 2024

@gcentauri I referenced yml files in my question…

@bkeepers
Copy link
Owner

@benlieb there is not erb+yaml support built into dotenv, but you could pretty easily load the file yourself:

Dotenv.update YAML.load(ERB.new(Dotenv::Rails.root.join('.env.yml').read).result)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants