rails, 未分类

基于Rails 6的credentials 部署

By jere on 2021-02-09 0 Comments • Tags: #deploy

几个注意事项

  • 对于production 环境,可以使用
EDITOR=vim rails credentials:edit --environment production

来生成生产环境的master.key 和credentials.yml,文件分别对应 ./credentials/production.key 和 ./credentials/production.yml.enc

  • 在编辑内容的时候,对于production环境不需要再写如下
production:
secret_key_base: xxxxxx

直接写

secret_key_base: xxxxxx
  • 目前rails是直接识别production环境的文件,在cap里的link_files为
append :linked_files, "config/credentials/production.key", "config/credentials/production.yml.enc", "config/database.yml"
  • database.yml设置可以为:
production:
adapter: xxx
encoding: unicode
pool: N
timeout: N
database: <%= Rails.application.credentials.db[:database] %>
username: <%= Rails.application.credentials.db[:username] %>
password: <%= Rails.application.credentials.db[:password] %>
host: <%= Rails.application.credentials.db[:host] %>
打赏

Leave a comment

您的电子邮箱地址不会被公开。