docker-builder 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/Rakefile +140 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docker-builder.gemspec +36 -0
- data/examples/example-apps-php/.chef/knife.rb +6 -0
- data/examples/example-apps-php/config.rb +19 -0
- data/examples/example-apps-php/servers/apps-php/.chef/knife.rb +2 -0
- data/examples/example-apps-php/servers/apps-php/config.rb +69 -0
- data/examples/example-apps-php/servers/apps-php/cookbooks/apps-php/README.md +1 -0
- data/examples/example-apps-php/servers/apps-php/cookbooks/apps-php/metadata.rb +9 -0
- data/examples/example-apps-php/servers/apps-php/cookbooks/apps-php/recipes/build.rb +43 -0
- data/examples/example-apps-php/servers/apps-php/cookbooks/apps-php/recipes/install.rb +55 -0
- data/examples/example-apps-php/servers/apps-php/cookbooks/apps-php/recipes/install_app.rb +27 -0
- data/examples/example-apps-php/servers/apps-php/cookbooks/apps-php/recipes/install_host.rb +9 -0
- data/examples/example-apps-php/servers/apps-php/cookbooks/apps-php/templates/index.html.erb +4 -0
- data/examples/example-apps-php/servers/apps-php/cookbooks/apps-php/templates/nginx-sites/app.conf.erb +55 -0
- data/examples/example-apps-php/servers/apps-php/cookbooks/apps-php/templates/nginx-sites/app.conf.erb.1 +55 -0
- data/examples/example-apps-php/servers/apps-php/cookbooks/apps-php/templates/nginx-sites/default.conf.erb +45 -0
- data/examples/example-apps-php/servers/apps-php/readme.md +0 -0
- data/examples/example-nginx/config.rb +19 -0
- data/examples/example-nginx/servers/nginx/.chef/knife.rb +8 -0
- data/examples/example-nginx/servers/nginx/config.rb +54 -0
- data/examples/example-nginx/servers/nginx/cookbooks/nginx/README.md +1 -0
- data/examples/example-nginx/servers/nginx/cookbooks/nginx/metadata.rb +9 -0
- data/examples/example-nginx/servers/nginx/cookbooks/nginx/recipes/build.rb +10 -0
- data/examples/example-nginx/servers/nginx/cookbooks/nginx/recipes/install.rb +28 -0
- data/examples/example-nginx/servers/nginx/cookbooks/nginx/recipes/install_host.rb +9 -0
- data/examples/example-nginx/servers/nginx/cookbooks/nginx/templates/index.html.erb +4 -0
- data/examples/example-nginx/servers/nginx/cookbooks/nginx/templates/nginx-sites/default.conf.erb +45 -0
- data/examples/example-nginx/servers/nginx/readme.md +0 -0
- data/examples/example-nginx/temp/ex_nginx.json +20 -0
- data/examples/example-nginx/temp/nginx.json +1 -0
- data/exe/docker-builder +20 -0
- data/install_local.sh +2 -0
- data/lib/docker_builder.rb +18 -0
- data/lib/docker_builder/chef/.chef/knife.rb +115 -0
- data/lib/docker_builder/chef/chef_build_image.copy0.rb +60 -0
- data/lib/docker_builder/chef/chef_destroy_image.copy0.rb +35 -0
- data/lib/docker_builder/cli.rb +346 -0
- data/lib/docker_builder/config.rb +199 -0
- data/lib/docker_builder/config/dsl.rb +48 -0
- data/lib/docker_builder/config/helpers.rb +99 -0
- data/lib/docker_builder/manager.rb +364 -0
- data/lib/docker_builder/server_settings.rb +286 -0
- data/lib/docker_builder/version.rb +3 -0
- data/lib/templates/example-chef/config.rb.erb +18 -0
- data/lib/templates/example-chef/servers/server1/.chef/knife.rb +8 -0
- data/lib/templates/example-chef/servers/server1/config.rb.erb +54 -0
- data/lib/templates/example-chef/servers/server1/cookbooks/server1/README.md +1 -0
- data/lib/templates/example-chef/servers/server1/cookbooks/server1/metadata.rb.erb +8 -0
- data/lib/templates/example-chef/servers/server1/cookbooks/server1/recipes/build.rb +10 -0
- data/lib/templates/example-chef/servers/server1/cookbooks/server1/recipes/install.rb +36 -0
- data/lib/templates/example-chef/servers/server1/cookbooks/server1/recipes/install_host.rb +9 -0
- data/lib/templates/example-chef/servers/server1/cookbooks/server1/templates/index.html.erb +5 -0
- data/lib/templates/example-chef/servers/server1/cookbooks/server1/templates/nginx-sites/default.conf.erb +45 -0
- data/readme.md +233 -0
- data/readme_developers.md +54 -0
- data/temp.sh +21 -0
- data/temp/app-php.json +1 -0
- data/temp/build.sh +29 -0
- data/temp/chef_build_image.rb +37 -0
- data/temp/chef_destroy_image.rb +16 -0
- data/temp/cookbooks/temp1/README.md +1 -0
- data/temp/cookbooks/temp1/metadata.rb +9 -0
- data/temp/cookbooks/temp1/recipes/build.rb +42 -0
- data/temp/run.sh +2 -0
- metadata +157 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
=begin
|
2
|
+
## nginx default server
|
3
|
+
template "/etc/nginx/conf.d/default.conf" do
|
4
|
+
source "nginx-sites/default.conf.erb"
|
5
|
+
|
6
|
+
#owner 'root'
|
7
|
+
#group 'root'
|
8
|
+
|
9
|
+
mode '0775'
|
10
|
+
end
|
11
|
+
=end
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
### apps on nginx
|
16
|
+
node.run_state['apps'] = node['apps']
|
17
|
+
|
18
|
+
node['apps'].each do |name, opt|
|
19
|
+
node.run_state['app_name'] = name
|
20
|
+
node.run_state['app'] = node['apps'][name]
|
21
|
+
|
22
|
+
#include_recipe 'apps-php::install_app'
|
23
|
+
|
24
|
+
template "/etc/nginx/conf.d/#{name}.conf" do
|
25
|
+
source "nginx-sites/app.conf.erb"
|
26
|
+
|
27
|
+
variables({
|
28
|
+
:app_name => name,
|
29
|
+
:app => node['apps'][name]
|
30
|
+
})
|
31
|
+
|
32
|
+
|
33
|
+
#owner 'root'
|
34
|
+
#group 'root'
|
35
|
+
mode '0775'
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
#
|
45
|
+
bash 'reload nginx' do
|
46
|
+
code <<-EOH
|
47
|
+
service nginx reload
|
48
|
+
EOH
|
49
|
+
|
50
|
+
ignore_failure true
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
#command '/etc/init.d/nginx reload'
|
55
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# install PHP app for Nginx
|
2
|
+
|
3
|
+
name = node.run_state['app_name']
|
4
|
+
|
5
|
+
# dir
|
6
|
+
dir_base = "/var/www/html/#{name}"
|
7
|
+
dir_logs = "/var/www/logs/#{name}"
|
8
|
+
|
9
|
+
[dir_base, dir_logs].each do |d|
|
10
|
+
directory d do
|
11
|
+
recursive true
|
12
|
+
action :create
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
# nginx server
|
19
|
+
|
20
|
+
template "/etc/nginx/conf.d/#{name}.conf" do
|
21
|
+
source "nginx-sites/app.conf.erb"
|
22
|
+
|
23
|
+
|
24
|
+
#owner 'root'
|
25
|
+
#group 'root'
|
26
|
+
mode '0775'
|
27
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
server {
|
2
|
+
<% if @app['app_port'] %>
|
3
|
+
listen <%=@app['app_port']%>;
|
4
|
+
<% else %>
|
5
|
+
listen 80;
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
|
9
|
+
<% if @app['app_domain_aliases'] %>
|
10
|
+
server_name <%=@app['app_domain']%> <%=@app['app_domain_aliases'].join(' ') %>;
|
11
|
+
<% else %>
|
12
|
+
server_name <%=@app['app_domain']%>;
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
|
16
|
+
root /var/www/html/<%=@app_name%>;
|
17
|
+
index index.html index.htm index.php;
|
18
|
+
error_page 404 /index.php;
|
19
|
+
|
20
|
+
access_log /var/log/nginx/access.log;
|
21
|
+
error_log /var/log/nginx/error.log error;
|
22
|
+
|
23
|
+
charset utf-8;
|
24
|
+
|
25
|
+
location / {
|
26
|
+
try_files $uri $uri/ /index.html /index.php?$query_string;
|
27
|
+
}
|
28
|
+
|
29
|
+
location = /favicon.ico {
|
30
|
+
log_not_found off;
|
31
|
+
access_log off;
|
32
|
+
}
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
location = /robots.txt {
|
37
|
+
access_log off;
|
38
|
+
log_not_found off;
|
39
|
+
}
|
40
|
+
|
41
|
+
location ~ \.php$ {
|
42
|
+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
43
|
+
# With php5-fpm:
|
44
|
+
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
45
|
+
fastcgi_index index.php;
|
46
|
+
include fastcgi_params;
|
47
|
+
fastcgi_param HTTPS off;
|
48
|
+
}
|
49
|
+
|
50
|
+
# Deny .htaccess file access
|
51
|
+
location ~ /\.ht {
|
52
|
+
deny all;
|
53
|
+
}
|
54
|
+
|
55
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
server {
|
2
|
+
<% if node.run_state['app']['app_port'] %>
|
3
|
+
listen <%=node.run_state['app']['app_port']%>;
|
4
|
+
<% else %>
|
5
|
+
listen 80;
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
|
9
|
+
<% if node.run_state['app']['app_domain_aliases'] %>
|
10
|
+
server_name <%=node.run_state['app']['app_domain']%> <%=node.run_state['app']['app_domain_aliases'].join(' ') %>;
|
11
|
+
<% else %>
|
12
|
+
server_name <%=node.run_state['app']['app_domain']%>;
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
|
16
|
+
root /var/www/html/<%=node.run_state['app_name']%>;
|
17
|
+
index index.html index.htm index.php;
|
18
|
+
error_page 404 /index.php;
|
19
|
+
|
20
|
+
access_log /var/log/nginx/access.log;
|
21
|
+
error_log /var/log/nginx/error.log error;
|
22
|
+
|
23
|
+
charset utf-8;
|
24
|
+
|
25
|
+
location / {
|
26
|
+
try_files $uri $uri/ /index.html /index.php?$query_string;
|
27
|
+
}
|
28
|
+
|
29
|
+
location = /favicon.ico {
|
30
|
+
log_not_found off;
|
31
|
+
access_log off;
|
32
|
+
}
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
location = /robots.txt {
|
37
|
+
access_log off;
|
38
|
+
log_not_found off;
|
39
|
+
}
|
40
|
+
|
41
|
+
location ~ \.php$ {
|
42
|
+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
43
|
+
# With php5-fpm:
|
44
|
+
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
45
|
+
fastcgi_index index.php;
|
46
|
+
include fastcgi_params;
|
47
|
+
fastcgi_param HTTPS off;
|
48
|
+
}
|
49
|
+
|
50
|
+
# Deny .htaccess file access
|
51
|
+
location ~ /\.ht {
|
52
|
+
deny all;
|
53
|
+
}
|
54
|
+
|
55
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
server {
|
2
|
+
listen 80;
|
3
|
+
server_name localhost <%=node['nginx']['sitename']%> ;
|
4
|
+
|
5
|
+
#charset koi8-r;
|
6
|
+
#access_log /var/log/nginx/log/access.log main;
|
7
|
+
|
8
|
+
location / {
|
9
|
+
root /usr/share/nginx/html;
|
10
|
+
index index.html index.htm;
|
11
|
+
}
|
12
|
+
|
13
|
+
#error_page 404 /404.html;
|
14
|
+
|
15
|
+
# redirect server error pages to the static page /50x.html
|
16
|
+
#
|
17
|
+
error_page 500 502 503 504 /50x.html;
|
18
|
+
location = /50x.html {
|
19
|
+
root /usr/share/nginx/html;
|
20
|
+
}
|
21
|
+
|
22
|
+
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
|
23
|
+
#
|
24
|
+
#location ~ \.php$ {
|
25
|
+
# proxy_pass http://127.0.0.1;
|
26
|
+
#}
|
27
|
+
|
28
|
+
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
|
29
|
+
#
|
30
|
+
#location ~ \.php$ {
|
31
|
+
# root html;
|
32
|
+
# fastcgi_pass 127.0.0.1:9000;
|
33
|
+
# fastcgi_index index.php;
|
34
|
+
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
|
35
|
+
# include fastcgi_params;
|
36
|
+
#}
|
37
|
+
|
38
|
+
# deny access to .htaccess files, if Apache's document root
|
39
|
+
# concurs with nginx's one
|
40
|
+
#
|
41
|
+
#location ~ /\.ht {
|
42
|
+
# deny all;
|
43
|
+
#}
|
44
|
+
}
|
45
|
+
|
File without changes
|
@@ -0,0 +1,54 @@
|
|
1
|
+
|
2
|
+
add 'build', {
|
3
|
+
"image_name" => "nginx",
|
4
|
+
'build_type' => 'chef',
|
5
|
+
|
6
|
+
"base_image" => {
|
7
|
+
"name" => "nginx",
|
8
|
+
"repository" => "nginx",
|
9
|
+
"tag" => "1.10"
|
10
|
+
|
11
|
+
},
|
12
|
+
|
13
|
+
}
|
14
|
+
|
15
|
+
add 'install', {
|
16
|
+
"host" => {
|
17
|
+
'script_type' => 'chef_recipe',
|
18
|
+
'script' => 'install_host',
|
19
|
+
},
|
20
|
+
"node" => {
|
21
|
+
'script_type' => 'chef_recipe',
|
22
|
+
'script' => 'install',
|
23
|
+
}
|
24
|
+
|
25
|
+
|
26
|
+
}
|
27
|
+
|
28
|
+
|
29
|
+
add 'docker', {
|
30
|
+
#'command' => "/sbin/my_init",
|
31
|
+
"command"=> "nginx -g 'daemon off;'",
|
32
|
+
#"command"=> "",
|
33
|
+
'ports' => [
|
34
|
+
[8080,80],
|
35
|
+
],
|
36
|
+
'volumes' => [
|
37
|
+
['html', '/usr/share/nginx/html'],
|
38
|
+
['log/nginx', '/var/log/nginx/'],
|
39
|
+
],
|
40
|
+
'links' => [
|
41
|
+
]
|
42
|
+
}
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
add 'attributes', {
|
47
|
+
'nginx' =>{
|
48
|
+
"sitename" =>"mysite.local"
|
49
|
+
},
|
50
|
+
|
51
|
+
|
52
|
+
}
|
53
|
+
|
54
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
# nginx
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
## nginx default server
|
3
|
+
template "/etc/nginx/conf.d/default.conf" do
|
4
|
+
source "nginx-sites/default.conf.erb"
|
5
|
+
|
6
|
+
#owner 'root'
|
7
|
+
#group 'root'
|
8
|
+
|
9
|
+
mode '0775'
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
#
|
18
|
+
bash 'reload nginx' do
|
19
|
+
code <<-EOH
|
20
|
+
service nginx reload
|
21
|
+
EOH
|
22
|
+
|
23
|
+
ignore_failure true
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
#command '/etc/init.d/nginx reload'
|
28
|
+
|
data/examples/example-nginx/servers/nginx/cookbooks/nginx/templates/nginx-sites/default.conf.erb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
server {
|
2
|
+
listen 80;
|
3
|
+
server_name localhost <%=node['nginx']['sitename']%> ;
|
4
|
+
|
5
|
+
#charset koi8-r;
|
6
|
+
#access_log /var/log/nginx/log/access.log main;
|
7
|
+
|
8
|
+
location / {
|
9
|
+
root /usr/share/nginx/html;
|
10
|
+
index index.html index.htm;
|
11
|
+
}
|
12
|
+
|
13
|
+
#error_page 404 /404.html;
|
14
|
+
|
15
|
+
# redirect server error pages to the static page /50x.html
|
16
|
+
#
|
17
|
+
error_page 500 502 503 504 /50x.html;
|
18
|
+
location = /50x.html {
|
19
|
+
root /usr/share/nginx/html;
|
20
|
+
}
|
21
|
+
|
22
|
+
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
|
23
|
+
#
|
24
|
+
#location ~ \.php$ {
|
25
|
+
# proxy_pass http://127.0.0.1;
|
26
|
+
#}
|
27
|
+
|
28
|
+
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
|
29
|
+
#
|
30
|
+
#location ~ \.php$ {
|
31
|
+
# root html;
|
32
|
+
# fastcgi_pass 127.0.0.1:9000;
|
33
|
+
# fastcgi_index index.php;
|
34
|
+
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
|
35
|
+
# include fastcgi_params;
|
36
|
+
#}
|
37
|
+
|
38
|
+
# deny access to .htaccess files, if Apache's document root
|
39
|
+
# concurs with nginx's one
|
40
|
+
#
|
41
|
+
#location ~ /\.ht {
|
42
|
+
# deny all;
|
43
|
+
#}
|
44
|
+
}
|
45
|
+
|