docker-builder 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/CODE_OF_CONDUCT.md +49 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +21 -0
  6. data/Rakefile +140 -0
  7. data/bin/console +14 -0
  8. data/bin/setup +8 -0
  9. data/docker-builder.gemspec +36 -0
  10. data/examples/example-apps-php/.chef/knife.rb +6 -0
  11. data/examples/example-apps-php/config.rb +19 -0
  12. data/examples/example-apps-php/servers/apps-php/.chef/knife.rb +2 -0
  13. data/examples/example-apps-php/servers/apps-php/config.rb +69 -0
  14. data/examples/example-apps-php/servers/apps-php/cookbooks/apps-php/README.md +1 -0
  15. data/examples/example-apps-php/servers/apps-php/cookbooks/apps-php/metadata.rb +9 -0
  16. data/examples/example-apps-php/servers/apps-php/cookbooks/apps-php/recipes/build.rb +43 -0
  17. data/examples/example-apps-php/servers/apps-php/cookbooks/apps-php/recipes/install.rb +55 -0
  18. data/examples/example-apps-php/servers/apps-php/cookbooks/apps-php/recipes/install_app.rb +27 -0
  19. data/examples/example-apps-php/servers/apps-php/cookbooks/apps-php/recipes/install_host.rb +9 -0
  20. data/examples/example-apps-php/servers/apps-php/cookbooks/apps-php/templates/index.html.erb +4 -0
  21. data/examples/example-apps-php/servers/apps-php/cookbooks/apps-php/templates/nginx-sites/app.conf.erb +55 -0
  22. data/examples/example-apps-php/servers/apps-php/cookbooks/apps-php/templates/nginx-sites/app.conf.erb.1 +55 -0
  23. data/examples/example-apps-php/servers/apps-php/cookbooks/apps-php/templates/nginx-sites/default.conf.erb +45 -0
  24. data/examples/example-apps-php/servers/apps-php/readme.md +0 -0
  25. data/examples/example-nginx/config.rb +19 -0
  26. data/examples/example-nginx/servers/nginx/.chef/knife.rb +8 -0
  27. data/examples/example-nginx/servers/nginx/config.rb +54 -0
  28. data/examples/example-nginx/servers/nginx/cookbooks/nginx/README.md +1 -0
  29. data/examples/example-nginx/servers/nginx/cookbooks/nginx/metadata.rb +9 -0
  30. data/examples/example-nginx/servers/nginx/cookbooks/nginx/recipes/build.rb +10 -0
  31. data/examples/example-nginx/servers/nginx/cookbooks/nginx/recipes/install.rb +28 -0
  32. data/examples/example-nginx/servers/nginx/cookbooks/nginx/recipes/install_host.rb +9 -0
  33. data/examples/example-nginx/servers/nginx/cookbooks/nginx/templates/index.html.erb +4 -0
  34. data/examples/example-nginx/servers/nginx/cookbooks/nginx/templates/nginx-sites/default.conf.erb +45 -0
  35. data/examples/example-nginx/servers/nginx/readme.md +0 -0
  36. data/examples/example-nginx/temp/ex_nginx.json +20 -0
  37. data/examples/example-nginx/temp/nginx.json +1 -0
  38. data/exe/docker-builder +20 -0
  39. data/install_local.sh +2 -0
  40. data/lib/docker_builder.rb +18 -0
  41. data/lib/docker_builder/chef/.chef/knife.rb +115 -0
  42. data/lib/docker_builder/chef/chef_build_image.copy0.rb +60 -0
  43. data/lib/docker_builder/chef/chef_destroy_image.copy0.rb +35 -0
  44. data/lib/docker_builder/cli.rb +346 -0
  45. data/lib/docker_builder/config.rb +199 -0
  46. data/lib/docker_builder/config/dsl.rb +48 -0
  47. data/lib/docker_builder/config/helpers.rb +99 -0
  48. data/lib/docker_builder/manager.rb +364 -0
  49. data/lib/docker_builder/server_settings.rb +286 -0
  50. data/lib/docker_builder/version.rb +3 -0
  51. data/lib/templates/example-chef/config.rb.erb +18 -0
  52. data/lib/templates/example-chef/servers/server1/.chef/knife.rb +8 -0
  53. data/lib/templates/example-chef/servers/server1/config.rb.erb +54 -0
  54. data/lib/templates/example-chef/servers/server1/cookbooks/server1/README.md +1 -0
  55. data/lib/templates/example-chef/servers/server1/cookbooks/server1/metadata.rb.erb +8 -0
  56. data/lib/templates/example-chef/servers/server1/cookbooks/server1/recipes/build.rb +10 -0
  57. data/lib/templates/example-chef/servers/server1/cookbooks/server1/recipes/install.rb +36 -0
  58. data/lib/templates/example-chef/servers/server1/cookbooks/server1/recipes/install_host.rb +9 -0
  59. data/lib/templates/example-chef/servers/server1/cookbooks/server1/templates/index.html.erb +5 -0
  60. data/lib/templates/example-chef/servers/server1/cookbooks/server1/templates/nginx-sites/default.conf.erb +45 -0
  61. data/readme.md +233 -0
  62. data/readme_developers.md +54 -0
  63. data/temp.sh +21 -0
  64. data/temp/app-php.json +1 -0
  65. data/temp/build.sh +29 -0
  66. data/temp/chef_build_image.rb +37 -0
  67. data/temp/chef_destroy_image.rb +16 -0
  68. data/temp/cookbooks/temp1/README.md +1 -0
  69. data/temp/cookbooks/temp1/metadata.rb +9 -0
  70. data/temp/cookbooks/temp1/recipes/build.rb +42 -0
  71. data/temp/run.sh +2 -0
  72. 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,9 @@
1
+ # will be run on the host machine
2
+
3
+ file '/tmp/example-app-php-intalled.txt' do
4
+ content '22'
5
+ end
6
+
7
+
8
+
9
+
@@ -0,0 +1,4 @@
1
+ Placeholder for a home page.
2
+ <br>
3
+ site:
4
+ <%=node['nginx']['sitename'] %>
@@ -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
+
@@ -0,0 +1,19 @@
1
+ common({
2
+ 'prefix' => "example-",
3
+ 'image_prefix' => 'example-',
4
+ 'dir_data' => '/disk3/data/my-examples/',
5
+
6
+ })
7
+
8
+ servers({
9
+ 'nginx'=>{
10
+ # some server options here
11
+ },
12
+
13
+
14
+ })
15
+
16
+
17
+ base({
18
+
19
+ })
@@ -0,0 +1,8 @@
1
+ #node_name ENV["NODE_NAME"] || ENV['SERVER_NAME'] || 'nginx-front'
2
+
3
+ # cookbooks
4
+ cookbook_path [
5
+ File.expand_path("../cookbooks", __FILE__)
6
+ ]
7
+
8
+
@@ -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,9 @@
1
+ name 'nginx'
2
+ maintainer 'YOUR_COMPANY_NAME'
3
+ maintainer_email 'YOUR_EMAIL'
4
+ license 'All rights reserved'
5
+ description 'Nginx server'
6
+ long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7
+ version '0.1.0'
8
+
9
+ #depends "apt"
@@ -0,0 +1,10 @@
1
+ # will be added to Docker image
2
+
3
+
4
+ file '/tmp/example-nginx.txt' do
5
+ content '555'
6
+ end
7
+
8
+
9
+
10
+
@@ -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
+
@@ -0,0 +1,9 @@
1
+ # will be run on the host machine
2
+
3
+ file '/tmp/example-nginx-intalled.txt' do
4
+ content '22'
5
+ end
6
+
7
+
8
+
9
+
@@ -0,0 +1,4 @@
1
+ Placeholder for a home page.
2
+ <br>
3
+ site:
4
+ <%=node['nginx']['sitename'] %>
@@ -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
+