Created
February 28, 2019 21:41
-
-
Save mraaroncruz/52c3f0028b7b07f8a91c2e68f7d85a1e to your computer and use it in GitHub Desktop.
mina script for Phoenix deployment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mina/git' | |
set :domain, 'your_domain' | |
set :deploy_to, 'your_path_on_server' | |
set :repository, 'your_git' | |
set :branch, 'master' | |
set :app_name, 'your_app_name' | |
set :shared_paths, ['log'] | |
set :user, 'your_user' | |
set :forward_agent, true | |
set :env_vars, "MIX_ENV=prod PORT=4001" | |
set :log_path, "#{deploy_to}/#{current_path}/rel/#{app_name}/log" | |
set :shared_paths, ["rel"] | |
task :setup do | |
queue! %[mkdir -p "#{deploy_to}/#{shared_path}/log"] | |
queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/log"] | |
end | |
desc "Deploys the current version to the server." | |
task :deploy do | |
deploy do | |
invoke :'git:clone' | |
invoke :'deploy:link_shared_paths' | |
queue %[mix deps.get] | |
queue %[npm install] | |
queue %[sudo npm install -g brunch] | |
queue %[brunch build] | |
queue %[mix phoenix.digest] | |
queue %[mix release] | |
queue %[mix ecto.migrate] | |
to :launch do | |
# invoke :'elixir:restart' | |
end | |
end | |
end | |
elixir_commands = [:start, :stop, :ping, :restart, :console] | |
namespace :elixir do | |
elixir_commands.each do |cmd| | |
desc "elixir command[#{cmd}]" | |
task cmd do | |
queue %[cd #{deploy_to}/#{current_path}/rel/#{app_name}/bin && pwd && ./#{app_name} #{cmd}] | |
end | |
end | |
end | |
task :logs do | |
queue 'echo "Contents of the log file are as follows:"' | |
queue "tail -f `/bin/ls -1td #{log_path}/*| /usr/bin/head -n1`" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment