Как я могу переместить мой Rails 5.2 master.key на сервер с помощью развертывания Mina? - PullRequest
0 голосов
/ 12 октября 2018

Я хотел бы переместить мой master.key файл на сервер (в Digital Ocean), используя mina deploy.

В пределах deploy.rb у меня сейчас

set :shared_files, fetch(:shared_files, []).push('config/database.yml', 'config/secrets.yml', 'config/master.key')

# Put any custom commands you need to run at setup
# All paths in `shared_dirs` and `shared_paths` will be created on their own.
task :setup do

  in_path(fetch(:shared_path)) do

     command %[mkdir -p config]

     # Create database.yml for Postgres if it doesn't exist
     path_database_yml = "config/database.yml"
     database_yml = %[production:
     database: #{fetch(:user)}
     adapter: postgresql
     pool: 5
     timeout: 5000]
   command %[test -e #{path_database_yml} || echo "#{database_yml}" > #{path_database_yml}]

   # Create secrets.yml if it doesn't exist
   path_secrets_yml = "config/secrets.yml"
   secrets_yml = %[production:\n  secret_key_base:\n    #{`bundle exec rake secret`.strip}]
  command %[test -e #{path_secrets_yml} || echo "#{secrets_yml}" > #{path_secrets_yml}]

  # Remove others-permission for config directory
  command %[chmod -R o-rwx config]
  end
end

...

desc "Deploys the current version to the server."
    task :deploy do
      # uncomment this line to make sure you pushed your local branch to the remote origin
      # invoke :'git:ensure_pushed'
      deploy do
        # Put things that will set up an empty directory into a fully set-up
        # instance of your project.
        invoke :'git:clone'
        invoke :'deploy:link_shared_paths'
        invoke :'bundle:install'
        invoke :'rails:db_migrate'
        invoke :'rails:assets_precompile'
        invoke :'deploy:cleanup'

        on :launch do
          invoke :'whenever:update' # should update the cron file
          command "sudo service #{fetch(:user)} restart"
        end
      end

      # you can use `run :local` to run tasks on local machine before of after the deploy scripts
      # run(:local){ say 'done' }
    end

Пожалуйста,вы посоветуете мне, что мне нужно добавить в вышеприведенное, чтобы переместить файл config/master.key с моей машины разработки на shared/config/master.key на сервере

1 Ответ

0 голосов
/ 14 октября 2018

Поскольку я не получил никакого ответа на этот вопрос, я закончил тем, что добавил RAILS_MASTER_KEY=<my_master.key> в начало моего .bashrc файла на сервере через nano .bashrc.

В статьях, которые я читал, предлагалось добавить это в самый верх файла .bashrc, и, похоже, оно успешно работает

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...