Project

mina-ec2

0.01
No commit activity in last 3 years
No release in over 3 years
Adds support for Mina to deploy to EC2
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.3.5
>= 0

Runtime

>= 0.2.1
 Project Readme

Mina EC2

Helper library to deploy to several EC2 instances using Mina

Installing

Add to gemfile:

gem 'mina-ec2'

Add to config/deploy.rb

require 'mina/ec2'

Configuration

AWS Credentials

Set AWS credentials to use, and which region(s) to deploy to.

set :ec2_settings, {
  regions: %w{eu-west-1},
  access_key_id: ENV['AWS_ACCESS_KEY_ID'],
  secret_access_key: ENV['AWS_SECRET_ACCESS_KEY_ID']
}

Filtering instance

Set tags to find your instances by:

set :ec2_tags, {
  'Team' => 'my-team',
  'Project' => 'my-app',
  'Stages' => 'staging'
}

Migrations

Split out the rails:db_migrate invocation, since we don't want to run it from several servers. If you do want to run it from several servers (for example if each of your app servers has their own sqlite3 database), just leave it as a part of the deploy {} block.

desc "Deploys the current version to the server."
task :deploy => :environment do
  deploy do
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'
    invoke :'bundle:install'
    invoke :'rails:assets_precompile'
    invoke :'deploy:cleanup'

    to :launch do
      queue "mkdir -p #{deploy_to}/#{current_path}/tmp/"
      queue "touch #{deploy_to}/#{current_path}/tmp/restart.txt"
    end
  end

  set :domain, fetch(:ec2_domains).sample
  invoke :'rails:db_migrate'
end

Usage

Invoke with

mina ec2:deploy