odania-static-pages 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3367af5072b1e9be5310054749f59e1c614fd2da
4
- data.tar.gz: 6da2cbedc60cba4fbbe7ec7a29835179f4d8acf3
3
+ metadata.gz: 0baa2c52d548e23641889addb9bad4f553a9b96d
4
+ data.tar.gz: ddab7c74d9821064703a8aba1be792eae86687a5
5
5
  SHA512:
6
- metadata.gz: 4c177898819b04578d39429dc53eb880cbde802425d41b9e5012e66912282964b218f861d89c2764c7945544ce52bec30805cc696a83e1966923d80be079ef31
7
- data.tar.gz: 419327034c55947c6046b8b29f4673256a0092f8df4cdbeb8334142d77078665d2573444e94ed99914768e73a5b8d0ccd53ca7cc40b3b3b5b7bbb42ba8df10d3
6
+ metadata.gz: b42ea397e077f6bc548e8d4f5f357551619a58f9b004f3c6c93863b3d7594dd61e0b4d1bbfc68cbe18fa00fa54a271bf86703455a61b6be6a2b228b4fd1b4c83
7
+ data.tar.gz: bedf3a45c11f951e934d16affb548f0b0a9272e2e27ec83354c045ff1f0ab669cd7f1c4bb685dc767e402efbfc911fea22f861249335c71979d67e0968a48581
@@ -13,6 +13,7 @@ require_relative 'odania_static_pages/deploy/docker_compose'
13
13
  require_relative 'odania_static_pages/deploy/rsync'
14
14
  require_relative 'odania_static_pages/deploy/s3'
15
15
  require_relative 'odania_static_pages/generator/jekyll'
16
+ require_relative 'odania_static_pages/helper/nginx'
16
17
  require_relative 'odania_static_pages/server/nginx'
17
18
  require_relative 'odania_static_pages/version'
18
19
 
@@ -63,6 +63,10 @@ module OdaniaStaticPages
63
63
  File.join @project_dir, 'pages'
64
64
  end
65
65
 
66
+ def output_nginx_conf_d_path
67
+ File.join @output_nginx_path, 'conf.d'
68
+ end
69
+
66
70
  def current_environment
67
71
  if @environments[@environment].nil?
68
72
  puts "Environment #{environment} no found!"
@@ -50,7 +50,7 @@ module OdaniaStaticPages
50
50
 
51
51
  puts ' -> Linking Gemfile*'
52
52
  dot_bundle_folder = File.join(full_common_folder, '.bundle')
53
- FileUtils.ln_s dot_bundle_folder, page_path, force: true if File.exist? dot_bundle_folder
53
+ FileUtils.ln_s(dot_bundle_folder, page_path, force: true) if File.exist? dot_bundle_folder
54
54
  FileUtils.ln_s File.join(full_common_folder, 'Gemfile'), File.join(page_path, 'Gemfile'), force: true
55
55
  FileUtils.ln_s File.join(full_common_folder, 'Gemfile.lock'), File.join(page_path, 'Gemfile.lock'), force: true
56
56
 
@@ -1,6 +1,8 @@
1
1
  module OdaniaStaticPages
2
2
  module Deploy
3
3
  class DockerCompose
4
+ include NginxHelper
5
+
4
6
  def initialize
5
7
  @config = OdaniaStaticPages.config
6
8
  @environment = @config.current_environment
@@ -28,7 +30,7 @@ module OdaniaStaticPages
28
30
  puts " -> Deploying to color: #{new_color} [Path: #{@site_path}]"
29
31
 
30
32
  generate_compose_config
31
- generate_nginx_config(do_rebuild)
33
+ NginxHelper.generate_nginx_config(do_rebuild)
32
34
  prepare_varnish
33
35
 
34
36
  @config.current_environment.do_notify new_color, color
@@ -59,35 +61,6 @@ module OdaniaStaticPages
59
61
  docker_compose_generator.write compose_file
60
62
  end
61
63
 
62
- def generate_nginx_config(do_rebuild)
63
- vhost_renderer = ERB.new(File.read(File.join(@config.base_dir, 'templates', 'nginx', 'vhost.conf.erb')))
64
- sites = {}
65
- grouped_domains.each_pair do |site_name, page_config|
66
- full_site_name = "#{site_name}.lvh.me"
67
- puts "Writing vhost for: #{full_site_name}"
68
- expires = @deploy_config.expires
69
- FileUtils.mkdir_p @nginx_conf_dir
70
- File.write File.join(@nginx_conf_dir, "#{site_name}.conf"), vhost_renderer.result(binding)
71
-
72
- sites[site_name] = "#{site_name}.lvh.me:8080"
73
-
74
- page_config.each do |config|
75
- sites["#{site_name}#{config[:baseurl]}"] = "#{site_name}.lvh.me:8080#{config[:baseurl]}"
76
- end if page_config.count > 1
77
- end
78
-
79
- puts 'Generating index.html'
80
- FileUtils.mkdir_p @config.output_site_path
81
- renderer = ERB.new(File.read(File.join(@config.base_dir, 'templates', 'nginx', 'index.html.erb')))
82
- File.write File.join(@config.output_site_path, 'index.html'), renderer.result(binding)
83
-
84
- puts 'Copy default vhost'
85
- FileUtils.cp File.join(@config.base_dir, 'templates', 'nginx', 'default-vhost.conf'), File.join(@nginx_conf_dir, 'default.conf')
86
-
87
- puts 'Copy nginx.conf'
88
- FileUtils.cp File.join(@config.base_dir, 'templates', 'nginx', 'nginx.conf'), File.join(@nginx_dir, 'nginx.conf')
89
- end
90
-
91
64
  def prepare_varnish
92
65
  docker_folder = File.join(@config.project_dir, 'docker')
93
66
  FileUtils.mkdir_p docker_folder
@@ -1,6 +1,8 @@
1
1
  module OdaniaStaticPages
2
2
  module Deploy
3
3
  class Rsync
4
+ include NginxHelper
5
+
4
6
  def initialize
5
7
  @config = OdaniaStaticPages.config
6
8
  @deploy_config = @config.current_environment.deploy_module
@@ -11,6 +13,11 @@ module OdaniaStaticPages
11
13
  puts 'Preparing rsync state'
12
14
  load_state
13
15
  save_state
16
+
17
+ puts 'Copying Dockerfile'
18
+ FileUtils.cp File.join(@config.base_dir, 'templates', 'live', 'Dockerfile'), File.join(@config.output_path, 'Dockerfile')
19
+
20
+ NginxHelper.generate_nginx_config(false)
14
21
  end
15
22
 
16
23
  def publish(color, do_rebuild)
@@ -0,0 +1,31 @@
1
+ module NginxHelper
2
+ def generate_nginx_config(do_rebuild)
3
+ vhost_renderer = ERB.new(File.read(File.join(@config.base_dir, 'templates', 'nginx', 'vhost.conf.erb')))
4
+ sites = {}
5
+ grouped_domains.each_pair do |site_name, page_config|
6
+ full_site_name = "#{site_name}.lvh.me"
7
+ puts "Writing vhost for: #{full_site_name}"
8
+ expires = @deploy_config.expires
9
+ FileUtils.mkdir_p @nginx_conf_dir
10
+ File.write File.join(@nginx_conf_dir, "#{site_name}.conf"), vhost_renderer.result(binding)
11
+
12
+ sites[site_name] = "#{site_name}.lvh.me:8080"
13
+
14
+ page_config.each do |config|
15
+ sites["#{site_name}#{config[:baseurl]}"] = "#{site_name}.lvh.me:8080#{config[:baseurl]}"
16
+ end if page_config.count > 1
17
+ end
18
+
19
+ puts 'Generating index.html'
20
+ FileUtils.mkdir_p @config.output_site_path
21
+ renderer = ERB.new(File.read(File.join(@config.base_dir, 'templates', 'nginx', 'index.html.erb')))
22
+ File.write File.join(@config.output_site_path, 'index.html'), renderer.result(binding)
23
+
24
+ puts 'Copy default vhost'
25
+ default_vhost_file = 'live'.eql?(@config.environment) ? 'default-live-vhost.conf' : 'default-vhost.conf'
26
+ FileUtils.cp File.join(@config.base_dir, 'templates', 'nginx', default_vhost_file), File.join(@nginx_conf_dir, 'default.conf')
27
+
28
+ puts 'Copy nginx.conf'
29
+ FileUtils.cp File.join(@config.base_dir, 'templates', 'nginx', 'nginx.conf'), File.join(@nginx_dir, 'nginx.conf')
30
+ end
31
+ end
@@ -1,3 +1,3 @@
1
1
  module OdaniaStaticPages
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -42,7 +42,7 @@ services:
42
42
  depends_on:
43
43
  - generator
44
44
  ports:
45
- - "3000:80/tcp"
45
+ - "8088:80/tcp"
46
46
 
47
47
  generator:
48
48
  build: ../docker/varnish-generator
@@ -0,0 +1,6 @@
1
+ FROM nginx:stable
2
+ MAINTAINER Mike Petersen <mike@odania-it.de>
3
+
4
+ COPY sites /srv
5
+ COPY nginx/nginx.conf /etc/nginx/nginx.conf
6
+ COPY nginx/conf.d /etc/nginx/conf.d
@@ -5,7 +5,7 @@
5
5
  <ul>
6
6
  <% sites.each do |site_name, site_path| %>
7
7
  <li>
8
- <a href="<%= site_path.gsub(':8080', ':3000') %>" target="_blank"><%= site_name %></a>
8
+ <a href="<%= site_path.gsub(':8080', ':8088') %>" target="_blank"><%= site_name %></a>
9
9
  (<a href="<%= site_path %>" target="_blank">Nginx</a>)
10
10
  </li>
11
11
  <% end %>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: odania-static-pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Petersen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-05 00:00:00.000000000 Z
11
+ date: 2018-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -156,6 +156,7 @@ files:
156
156
  - lib/odania_static_pages/deploy/rsync.rb
157
157
  - lib/odania_static_pages/deploy/s3.rb
158
158
  - lib/odania_static_pages/generator/jekyll.rb
159
+ - lib/odania_static_pages/helper/nginx.rb
159
160
  - lib/odania_static_pages/server/nginx.rb
160
161
  - lib/odania_static_pages/version.rb
161
162
  - odania-static-pages.gemspec
@@ -163,6 +164,7 @@ files:
163
164
  - templates/docker-compose/docker-compose.yml.erb
164
165
  - templates/jekyll/Gemfile.erb
165
166
  - templates/jekyll/example_config.yml
167
+ - templates/live/Dockerfile
166
168
  - templates/nginx/default-live-vhost.conf.erb
167
169
  - templates/nginx/default-vhost.conf
168
170
  - templates/nginx/index.html.erb
@@ -189,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
191
  version: '0'
190
192
  requirements: []
191
193
  rubyforge_project:
192
- rubygems_version: 2.6.14
194
+ rubygems_version: 2.6.10
193
195
  signing_key:
194
196
  specification_version: 4
195
197
  summary: Helper For creating static pages