ruby on rails - Clone a repository during deployment on Heroku -
i have rails project projectx, hosted on heroku. storing production configs , files, using different repository projectx-config. possible to:
- clone projectx-config,
- remove current config files, and
- symlink config files projectx-config files
note has done on heroku. aware heroku has options maintain configs using environment variables, not looking for.
thanks!
no not possible.
each dyno gets own ephemeral filesystem, fresh copy of deployed code. during dyno’s lifetime running processes can use filesystem temporary scratchpad, no files written visible processes in other dyno , files written discarded moment dyno stopped or restarted. example, occurs time dyno replaced due application deployment , approximately once day part of normal dyno management.
- https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem
or @ least not without rube goldberg machine setupe setup kind of automation (like post-commit hook) merge repo , repo b , push result heroku.
also believe app config should not present in environment variables, tedious maintain rather maintaining file.
heroku not agree here.
the traditional approach handling such config vars put them under source - in properties file of sort. error-prone process, , complicated open source apps have maintain separate (and private) branches app-specific configurations.
better solution use environment variables, , keep keys out of code. on traditional host or working locally can set environment vars in bashrc file. on heroku, use config vars. - https://devcenter.heroku.com/articles/config-vars
although might overestimating need store in env vars. need store secrets such api keys in env.
other non-secret configuration such settings various gems can , should setup in config/initializers
.
if still think using gui terrible use yaml files parse , use set env vars:
require 'yaml' yaml = yaml.load_file(file.join(__dir__, 'conf.yml')) def create_key(*components) components.join('_').upcase end env_vars = yaml["production"].each_with_object({}) |(key,value), memo| key_components = [key] if value.kind_of? hash value.each_pair |k,v| memo[create_key(*key_components.dup.push(k))] = v end else memo[create_key(*key_components)] = value end end.each |k,v| system("heroku config:set #{k}=#{v}") puts "setting #{k} = #{v}; #{ $? }" end
or store serialized form (json or yaml) in single env var - there total size limit of 32kb though.
Comments
Post a Comment