capistrano-decompose 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +32 -16
- data/lib/capistrano/decompose/version.rb +1 -1
- data/lib/capistrano/tasks/decompose.rake +1 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ee987eae8bc6a437a8964b9d7a40d012ac764d9
|
4
|
+
data.tar.gz: 67c6f9504c421d0f760990647a5169a93e8bb9b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c1206bb0dbd43f6e80052994366aa258cfc9f03f94636134cf201f6475cba0ed339428aff33a9c748609de3c40c058bd6e601f836e21e310888e2acc01fae64
|
7
|
+
data.tar.gz: 09a6537feacf72d0558d432d9ed2ff82b1458e44ab6d7884b22f627a07346714c81ef9ace409032c8f8c11bc334bb24c4c441c636cd5183a5b5d02a4b173175e
|
data/README.md
CHANGED
@@ -1,16 +1,23 @@
|
|
1
1
|
# Capistrano::Decompose
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/capistrano-decompose.svg)](https://badge.fury.io/rb/capistrano-decompose)
|
4
|
+
|
3
5
|
Add tasks for capistrano to deploy with docker-compose.
|
4
6
|
|
7
|
+
## Why?
|
8
|
+
|
9
|
+
when I was working on my project [Who is popular today](https://www.whoispopulartoday.com) I had that problem that I have a VPS server and I need to isolate each of my apps to a separate environment so the solutions are pretty limited in here, it's Docker or LXC,
|
10
|
+
I choose Docker and Docker-Compose as it's easier to get a set of disposable environments up and running in no time and link them to the host data directories which is what I needed, but there where not any kind of integeration with Capistrano to roll out new versions, so here is Capistrano-Decompose a Docker-Compose integeration with capistrano, I hope it solves your problem as it did to mine.
|
11
|
+
|
5
12
|
## How it works
|
6
13
|
|
7
|
-
|
14
|
+
After capistrano pull your repo and link it to the `current` directory, decompose will invoke `docker-compose build` to build your images and then run some rake tasks that you configured in your deployment with the key `decompose_rake_tasks`, you can add your rails tasks like `db:migration`, `assets:precompile`...etc here, then it will invoke `docker-compose up` or restart only the web service you specified in key `decompose_restart`, also you can use `cap <env> decompose:run` to run any command inside a service, so anytime you need to invoke `rails console` inside you docker image on your server you can use `cap production decompose:run rails console`.
|
8
15
|
|
9
|
-
|
16
|
+
At the end decompose will delete the older images from remote server to keep the server clean.
|
10
17
|
|
11
18
|
## Installation
|
12
19
|
|
13
|
-
|
20
|
+
Add this line to your Gemfile
|
14
21
|
|
15
22
|
``` ruby
|
16
23
|
gem 'capistrano-decompose'
|
@@ -38,30 +45,39 @@ require 'capistrano/decompose
|
|
38
45
|
|
39
46
|
## Options for deployment
|
40
47
|
|
41
|
-
|
48
|
+
You can specify the following options in you `deploy.rb` script or the environment specific deploy file:
|
42
49
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
decompose_rake_tasks: a set of rake tasks to execute after each deploy, default value is `nil`
|
47
|
-
```
|
50
|
+
* **decompose_restart**: An array of services that should be restarted each deployment, if not specified decompose will restart all services
|
51
|
+
* **decompose_web_service**: The web service that will be used to execute commands inside like `rake` or any interactive command from `decompose:run`, default value: :web
|
52
|
+
* **decompose_rake_tasks**: A set of rake tasks to execute after each deploy, default value is `nil`
|
48
53
|
|
49
|
-
|
54
|
+
For a typical rails application the previous options should be as follows, given that the application container service name is `web`:
|
50
55
|
|
51
56
|
```ruby
|
52
57
|
set :decompose_restart, [:web]
|
53
58
|
set :decompose_web_service, :web
|
54
|
-
set :
|
59
|
+
set :decompose_rake_tasks, ['db:migrate', 'assets:precompile']
|
60
|
+
```
|
61
|
+
|
62
|
+
## Defined Tasks
|
63
|
+
|
64
|
+
```
|
65
|
+
decompose:build # build docker-compose services
|
66
|
+
decompose:clean # delete docker images that are not related to current build
|
67
|
+
decompose:down # shutdown all project services with docker-compose
|
68
|
+
decompose:rake_tasks # execute a set of rake tasts inside the web container
|
69
|
+
decompose:restart # restart services of docker-compose and if not services listed restart all services
|
70
|
+
decompose:run # run an interactive command inside the web container
|
71
|
+
decompose:up # boot up all docker-compose services
|
55
72
|
```
|
56
73
|
|
57
|
-
##
|
74
|
+
## After the first deployment of a rails application
|
58
75
|
|
59
|
-
|
76
|
+
You would need to setup your database by invoking the `db:setup` task to create and seed your database:
|
60
77
|
|
61
|
-
* `cap production decompose:db_setup`
|
62
78
|
* `cap production decompose:run rake db:setup`
|
63
79
|
|
64
80
|
## General note
|
65
81
|
|
66
|
-
*
|
67
|
-
*
|
82
|
+
* This gem doesn't provide a `dockerfile` nor `docker-compose.yml` file, you have to create these files yourself
|
83
|
+
* The linked directories and files will not work and you should use docker data volumes anyway
|
@@ -48,7 +48,7 @@ namespace :decompose do
|
|
48
48
|
on roles(:app) do
|
49
49
|
within release_path do
|
50
50
|
images_to_delete = capture('docker images -f "dangling=true" -q')
|
51
|
-
execute 'docker rmi $(docker images -f "dangling=true" -q)' unless images_to_delete.empty?
|
51
|
+
execute 'docker rmi -f $(docker images -f "dangling=true" -q)' unless images_to_delete.empty?
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -62,15 +62,6 @@ namespace :decompose do
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
desc 'execute rake db:setup inside the web container'
|
66
|
-
task :db_setup do
|
67
|
-
on roles(:app) do
|
68
|
-
within release_path do
|
69
|
-
docker_rake('db:setup')
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
65
|
desc 'run an interactive command inside the web container'
|
75
66
|
task :run do
|
76
67
|
on roles(:app) do |host|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-decompose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emad Elsaid
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|