Skip to content

Instantly share code, notes, and snippets.

@carlosipe
Created January 30, 2018 14:31
Show Gist options
  • Save carlosipe/dc6e161d4711ec346ff653c7f3e0b419 to your computer and use it in GitHub Desktop.
Save carlosipe/dc6e161d4711ec346ff653c7f3e0b419 to your computer and use it in GitHub Desktop.
mina script for Phoenix deployment
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