capdocker 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/capdocker.gemspec +25 -0
- data/lib/capdocker.rb +4 -0
- data/lib/docker.rb +13 -0
- data/lib/docker_deploy.rb +57 -0
- data/lib/templates/nginx_container.erb +21 -0
- data/lib/templates/nginx_host.erb +7 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7cad73324659bf6662f73edd6dd2d96de7a78937
|
4
|
+
data.tar.gz: 10f8596d8b5e5a66719806fd5b11a1f30e701b54
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c753d609ed0c8840f917c47550005ebbdd2979125321c560c9dda5d26f41e66ce620bc0dafffd6845dc27bebed27dc173eb30716071e9fdad82254ee32e65a24
|
7
|
+
data.tar.gz: f6fff6dd345903b1ca0d93b071cd9e578f7a0e1e6be3be6549e8b7fcdf3abc125ec8a742fcd075791396de5cab2de929e55dda8b6c24e97854b2f8b5af42f9b1
|
data/capdocker.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{capdocker}
|
5
|
+
s.version = "1.0.1"
|
6
|
+
s.authors = ["Ross Riley", "One Black Bear"]
|
7
|
+
s.email = %q{ross@oneblackbear.com}
|
8
|
+
s.date = Time.now
|
9
|
+
s.require_paths = ["lib"]
|
10
|
+
s.description = %q{An extension to Capistrano to handle deploys for One Black Bear docker containers.}
|
11
|
+
s.files = [
|
12
|
+
"capdocker.gemspec",
|
13
|
+
"lib/capdocker.rb",
|
14
|
+
"lib/docker.rb",
|
15
|
+
"lib/docker_deploy.rb",
|
16
|
+
"lib/templates/nginx_host.erb",
|
17
|
+
"lib/templates/nginx_container.erb"
|
18
|
+
]
|
19
|
+
s.homepage = %q{http://oneblackbear.com}
|
20
|
+
s.summary = %q{Deploy skeleton apps to docker container.}
|
21
|
+
s.add_dependency 'capistrano', "~> 2.13.5"
|
22
|
+
s.add_dependency 'colored', ">= 1.2.0"
|
23
|
+
s.add_dependency 'inifile', ">= 2.0.2"
|
24
|
+
end
|
25
|
+
|
data/lib/capdocker.rb
ADDED
data/lib/docker.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
|
3
|
+
namespace :docker do
|
4
|
+
|
5
|
+
desc "build an updated box, restart container"
|
6
|
+
task :build do
|
7
|
+
run "docker build -t oneblackbear/#{application} #{release_path}/"
|
8
|
+
run "docker ps | grep #{app_port} | awk '{print $1}' | xargs -n 1 docker kill"
|
9
|
+
run "docker run -p #{app_port}:80 -v /home/docker/data/#{application}/mysql:/data/mysql:rw -d -t oneblackbear/#{application}:latest"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
|
3
|
+
role :web, "obb1.oneblackbear.com"
|
4
|
+
set :user, "docker"
|
5
|
+
set :application, "docker-example-"+rand(2000)
|
6
|
+
set :user, "docker"
|
7
|
+
set :release_path, "./#{application}"
|
8
|
+
set :app_domain, "docker.oneblackbear.com"
|
9
|
+
set :app_port, rand(2000)+8100
|
10
|
+
|
11
|
+
namespace :deploy do
|
12
|
+
task :prepare do
|
13
|
+
run "cd #{release_path} && rm -Rf ./*"
|
14
|
+
run "mkdir -p #{release_path}/platform"
|
15
|
+
run "mkdir -m0777 -p data/#{application}/mysql"
|
16
|
+
end
|
17
|
+
task :start do ; end
|
18
|
+
task :stop do ; end
|
19
|
+
task :create_symlink do
|
20
|
+
run "ln -f -s #{basedir}/#{release_path}/platform/nginx_host.conf ./conf/nginx/#{application}.conf"
|
21
|
+
end
|
22
|
+
|
23
|
+
task :configure_platform do
|
24
|
+
host_content = from_template("platform/nginx_host.erb")
|
25
|
+
put host_content, "#{release_path}/platform/nginx_host.conf"
|
26
|
+
container_content = from_template("platform/nginx_container.erb")
|
27
|
+
put container_content, "#{release_path}/platform/nginx_container.conf"
|
28
|
+
end
|
29
|
+
|
30
|
+
task :update_code do
|
31
|
+
prepare
|
32
|
+
configure_platform
|
33
|
+
puts "Pushing code for current git commit ..."
|
34
|
+
set :basedir, capture("pwd").gsub(/\n|\r/, "")
|
35
|
+
set :tag, %x[git rev-parse --short HEAD].strip() + ".tar.gz"
|
36
|
+
run_locally "git archive HEAD | gzip > #{tag}"
|
37
|
+
top.upload "#{tag}", "#{release_path}", :via => :scp, :mkdir => true
|
38
|
+
run_locally "rm #{tag}"
|
39
|
+
run "cd #{release_path} && tar -xzvf #{tag}"
|
40
|
+
run "rm #{release_path}/#{tag}"
|
41
|
+
end
|
42
|
+
task :symlink do;end
|
43
|
+
task :restart do
|
44
|
+
run "sudo service nginx restart"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
def from_template(file)
|
52
|
+
require 'erb'
|
53
|
+
template = File.read(File.join(File.dirname(__FILE__), "..", file))
|
54
|
+
result = ERB.new(template).result(binding)
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
server {
|
2
|
+
listen 80 default_server;
|
3
|
+
listen [::]:80 default_server ipv6only=on;
|
4
|
+
|
5
|
+
root /var/www/public;
|
6
|
+
index index.php index.html index.htm;
|
7
|
+
|
8
|
+
|
9
|
+
location / {
|
10
|
+
try_files $uri $uri/ /index.php;
|
11
|
+
}
|
12
|
+
|
13
|
+
location ~ \.php$ {
|
14
|
+
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
15
|
+
fastcgi_param PATH_INFO $fastcgi_script_name;
|
16
|
+
include /etc/nginx/fastcgi_params;
|
17
|
+
fastcgi_index index.php;
|
18
|
+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capdocker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ross Riley
|
8
|
+
- One Black Bear
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-11-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capistrano
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 2.13.5
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 2.13.5
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: colored
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.2.0
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.2.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: inifile
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 2.0.2
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 2.0.2
|
56
|
+
description: An extension to Capistrano to handle deploys for One Black Bear docker
|
57
|
+
containers.
|
58
|
+
email: ross@oneblackbear.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- capdocker.gemspec
|
64
|
+
- lib/capdocker.rb
|
65
|
+
- lib/docker.rb
|
66
|
+
- lib/docker_deploy.rb
|
67
|
+
- lib/templates/nginx_host.erb
|
68
|
+
- lib/templates/nginx_container.erb
|
69
|
+
homepage: http://oneblackbear.com
|
70
|
+
licenses: []
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.1.10
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: Deploy skeleton apps to docker container.
|
92
|
+
test_files: []
|