Rails: Moving `master.key` to production server

匿名 (未验证) 提交于 2019-12-03 01:45:01

问题:

I am trying to deploy an updated version of a rails app to a droplet on DigitalOcean using mina

When I run mina deploy I get the error Missing encryption key to decrypt file with. Ask your team for your master key and write it to /home/my_rails_project/app/tmp/build-153920174210305/config/master.key or put it in the ENV['RAILS_MASTER_KEY'].

I was expecting this error as I haven't yet worked out how to add the details to the server.

A number of articles suggest there are two means of doing this:

Option 1: Place the config/master.key file in the server. You’ll normally want to symlink this file to a shared folder in the server filesystem. Again, do not version your config/master.key file.

Option 2: create a RAILS_MASTER_KEY ENV variable. Rails will detect it and use it as your master key, e.g. in heroku: heroku config:set RAILS_MASTER_KEY= < your-master-key-here >.

I have tried option 1 using FileZilla, however, I am unable to access the folder which is where the article suggests the file should be stored /home/deploy/my-rails-project/shared/config/master.key -> Error: Directory /home/my-rails-project/app/shared/config: permission denied. I am also unable to see the master.key file on my local computer through FileZilla. Similarly, if I use the console on Digital Ocean I get the permission denied error

Please could you advise me how to move master.key to the production server

Thanks in advance for your help

回答1:

I ended up working out how to do option 2, as suggested by @edudepetris. This involved adding the line RAILS_MASTER_KEY=<my_master.key> to the top of my .bashrc - this was done by typing nano .bashrc when logged into the server



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!