Project

caracara

0.0
No commit activity in last 3 years
No release in over 3 years
This rubygem does not have a description or summary.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.0.0

Runtime

~> 1.0
 Project Readme

Caracara Build Status Gem Version

Task runner based on Envoy and Mina

Concepts

Task: Everything is based on this entity, it has steps that are the commands that will be performed somewhere. Ex: git clone

Group: Group of tasks that represents an business operation. Ex: deploy

Usage

How to use this crazy gem.

Define some tasks

class GitCloneTask < Caracara::Task
  # Clone the repository
  step 'git clone {{repository}} {{dest}}/scm/{{version}} --recursive'

  # Run commands inside the repo folder
  dir '{{dest}}/scm/{{version}}' do
    # Checkout to the lastest tag
    step 'git checkout {{version}}'

    # Remove .git/ folder
    step 'rm -rf .git/'
  end
end

class DockerTask < Caracara::Task
  # Access new app folder
  dir '{{dest}}/scm/{{version}}' do
    # Build the image
    step 'docker build -t {{image}} .'

    # Remove  the current container
    step 'docker rm -f {{container}}'

    # Start it again
    step 'docker run -d --name {{container}} {{image}}'
  end
end

Group these tasks

class DeployGroup < Caracara::Group
  # Clone it
  task :clone, GitCloneTask

  # Dockernize it
  task :docker, DockerTask
end

Intialize the group

# Set the options
options = {
  repository: 'git@github.com:gabrielcorado/caracara.git',
  dest: '/home/user/apps',
  version: '0.0.0.alpha',
  image: 'caracara',
  container: 'caracara_app'
}

# Initialize the group
deploy = DeployGroup.init options

Generate the commands

# Compile the group commands
commands = deploy.compile_all

Generate the SSH Command

ssh_command = Caracara::SSH.generate 'user', 'localhost', commands

Run the command in your server

Caracara::SSH.exec ssh_command

Development

  • Generating docker image
    • docker build -t caracara .
  • Running the RSpec (for shell fish)
    • docker run -v (pwd):/caracara --rm caracara bundle exec rspec