|
| 1 | +require 'mina/rails' |
| 2 | +require 'mina/git' |
| 3 | +require 'mina/rbenv' # for rbenv support. (https://rbenv.org) |
| 4 | +# require 'mina/rvm' # for rvm support. (https://rvm.io) |
| 5 | + |
| 6 | +# Basic settings: |
| 7 | +# domain - The hostname to SSH to. |
| 8 | +# deploy_to - Path to deploy into. |
| 9 | +# repository - Git repo to clone from. (needed by mina/git) |
| 10 | +# branch - Branch name to deploy. (needed by mina/git) |
| 11 | + |
| 12 | +set :domain, 'xdev-server' |
| 13 | +set :deploy_to, '/home/tamnguyen/apps/rails_5_api' |
| 14 | +set :repository, 'git@github.com:ntamvl/rails_5_api_tutorial.git' |
| 15 | +set :branch, 'master' |
| 16 | + |
| 17 | +# Optional settings: |
| 18 | +# set :user, 'foobar' # Username in the server to SSH to. |
| 19 | +# set :port, '30000' # SSH port number. |
| 20 | +# set :forward_agent, true # SSH forward_agent. |
| 21 | + |
| 22 | +set :user, 'tamnguyen' |
| 23 | +set :port, '22' |
| 24 | + |
| 25 | +# They will be linked in the 'deploy:link_shared_paths' step. |
| 26 | +# set :shared_dirs, fetch(:shared_dirs, []).push('config') |
| 27 | +# set :shared_files, fetch(:shared_files, []).push('config/database.yml', 'config/secrets.yml') |
| 28 | +set :shared_dirs, fetch(:shared_dirs, []).push('config') |
| 29 | +set :shared_files, fetch(:shared_files, []).push('config/database.yml') |
| 30 | + |
| 31 | +# This task is the environment that is loaded all remote run commands, such as |
| 32 | +# `mina deploy` or `mina rake`. |
| 33 | +task :environment do |
| 34 | + # If you're using rbenv, use this to load the rbenv environment. |
| 35 | + # Be sure to commit your .ruby-version or .rbenv-version to your repository. |
| 36 | + invoke :'rbenv:load' |
| 37 | + |
| 38 | + # For those using RVM, use this to load an RVM version@gemset. |
| 39 | + # invoke :'rvm:use', 'ruby-1.9.3-p125@default' |
| 40 | +end |
| 41 | + |
| 42 | +# Put any custom commands you need to run at setup |
| 43 | +# All paths in `shared_dirs` and `shared_paths` will be created on their own. |
| 44 | +task :setup do |
| 45 | + # command %{rbenv install 2.3.1p112} |
| 46 | + |
| 47 | + # puts "\nStarting to setup app on #{fetch(:domain)}\n" |
| 48 | + # command %[mkdir -p "#{fetch(:deploy_to)}/#{fetch(:shared_path)}/tmp"] |
| 49 | + # command %[chmod g+rx,u+rwx "#{fetch(:deploy_to)}/#{fetch(:shared_path)}/tmp"] |
| 50 | + |
| 51 | + # command %[mkdir -p "#{fetch(:deploy_to)}/#{fetch(:shared_path)}/tmp/pids"] |
| 52 | + # command %[chmod g+rx,u+rwx "#{fetch(:deploy_to)}/#{fetch(:shared_path)}/tmp/pids"] |
| 53 | + |
| 54 | + # command %[mkdir -p "#{fetch(:deploy_to)}/#{fetch(:shared_path)}/tmp/sockets"] |
| 55 | + # command %[chmod g+rx,u+rwx "#{fetch(:deploy_to)}/#{fetch(:shared_path)}/tmp/sockets"] |
| 56 | + |
| 57 | + # command %[mkdir -p "#{fetch(:deploy_to)}/#{fetch(:shared_path)}/log"] |
| 58 | + # command %[chmod g+rx,u+rwx "#{fetch(:deploy_to)}/#{fetch(:shared_path)}/log"] |
| 59 | + |
| 60 | + # command %[mkdir -p "#{fetch(:deploy_to)}/#{fetch(:shared_path)}/config"] |
| 61 | + # command %[chmod g+rx,u+rwx "#{fetch(:deploy_to)}/#{fetch(:shared_path)}/config"] |
| 62 | + |
| 63 | + command %[touch "#{fetch(:deploy_to)}/shared/config/database.yml"] |
| 64 | + # command %[echo "-----> Fill in information below to populate 'shared/config/database.yml'."] |
| 65 | +end |
| 66 | + |
| 67 | +desc "Deploys the current version to the server." |
| 68 | +task :deploy do |
| 69 | + # uncomment this line to make sure you pushed your local branch to the remote origin |
| 70 | + # invoke :'git:ensure_pushed' |
| 71 | + deploy do |
| 72 | + # Put things that will set up an empty directory into a fully set-up |
| 73 | + # instance of your project. |
| 74 | + invoke :'git:clone' |
| 75 | + invoke :'deploy:link_shared_paths' |
| 76 | + invoke :'bundle:install' |
| 77 | + invoke :'rails:db_migrate' |
| 78 | + invoke :'rails:assets_precompile' |
| 79 | + invoke :'deploy:cleanup' |
| 80 | + |
| 81 | + on :launch do |
| 82 | + in_path(fetch(:current_path)) do |
| 83 | + command %{mkdir -p tmp/} |
| 84 | + command %{touch tmp/restart.txt} |
| 85 | + end |
| 86 | + end |
| 87 | + end |
| 88 | + |
| 89 | + # you can use `run :local` to run tasks on local machine before of after the deploy scripts |
| 90 | + # run :local { say 'done' } |
| 91 | +end |
| 92 | + |
| 93 | +# For help in making your deploy script, see the Mina documentation: |
| 94 | +# |
| 95 | +# - https://github.com/mina-deploy/mina/docs |
0 commit comments