开发主机,项目目录下,执行 mina deploy --trace,运行到
Migrating database
rake aborted!
提示:ArgumentError: Missing secret_key_base
for 'production' environment, set this string with bin/rails credentials:edit
使用 rails 6.1.7.6,ruby 3.0.0。
deploy.rb 配置文件如下
require 'mina/rails' require 'mina/git' require 'mina/rbenv' require 'mina/bundler'
set :application_name, 'cool' set :domain, '127.0.0.1'
set :deploy_to, '/var/www/html' set :repository, '[email protected]:PP_heroGrow/cool.git' set :branch, 'main'
set :user, 'f' # Username in the server to SSH to. set :port, '8022' # SSH port number. set :forward_agent, false # SSH forward_agent.
mina/rails
add public/assets
, vendor/bundle
and many moremina -d
to see all folders and files already included in shared_dirs
and shared_files
mina deploy
or mina rake
.task :remote_environment do # If you're using rbenv, use this to load the rbenv environment. # Be sure to commit your .ruby-version or .rbenv-version to your repository. invoke :'rbenv:load'
# For those using RVM, use this to load an RVM version@gemset. # invoke :'rvm:use', 'ruby-2.5.3@default' end
shared_dirs
and shared_paths
will be created on their own.task :setup do # command %{rbenv install 2.5.3 --skip-existing} # command %{rvm install ruby-2.5.3} # command %{gem install bundler} 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 in_path(fetch(:current_path)) do command %(mkdir -p tmp/) command %(touch tmp/restart.txt) end end end
# you can use run :local
to run tasks on local machine before or after the deploy scripts
# run(:local){ say 'done' }
end
#
请问使用 mina 部署 rails 项目时,生产环境下的 secret_key_base 如何配置?基本流程是什么?求专家指点迷津。