kamal
kamal copied to clipboard
feat: Add template argument to envify
Closes #351
- Adds
-t
argument toenvify
- injects
MRSK_DESTINATION
so a single template can be used to generate env files for multiple destinations - injects
MRSK_DESTINATION
when loadingdeploy.yml
files
TODO
- [ ] Docs
Instead of passing in the template what about instead using .env.destination.erb
or .env.template.erb
as the default template? Then setup could just be:
- Create .env.template.erb and utilize
ENV['KAMAL_DESTINATION']
- Run
kamal envify -d staging
- Update
.env.staging
- Run
kamal envify -d production
- Update
.env.production
I ended up working with the current functionality and utilizing ERB to create a template for this, figured I'd share.
.env.template.erb
# Generated by kamal envify on <%= DateTime.now %>, to regenerate run `kamal envify -d <%= destination %>`
DESTINATION=<%= destination %>
# TODO: Fetch credentials with the passed in destination, staging|production for instance.
.env.staging.erb
<%=
destination = "staging"
ERB.new(File.read(".env.template.erb"), trim_mode: "-").result(binding)
%>
.env.production.erb
<%=
destination = "production"
ERB.new(File.read(".env.template.erb"), trim_mode: "-").result(binding)
%>
When running kamal envify -d staging
it'll load .env.staging.erb, set destination to 'staging' and utilize the rest of the template. For each additional environment that you want to envify you then just need a two line file and to set the destination name.
Closing as we've removed kamal envify
in Kamal 2.