From 74fe333e4009ddcf18ad748a5152cac116ed95f2 Mon Sep 17 00:00:00 2001 From: whitestar Date: Thu, 3 Aug 2017 22:11:24 +0900 Subject: [PATCH] adds the Nexus 2 support. --- cookbooks/nexus-grid/CHANGELOG.md | 5 +++++ cookbooks/nexus-grid/README.md | 26 ++++++++++++++++++++-- cookbooks/nexus-grid/attributes/default.rb | 13 ++++++++++- cookbooks/nexus-grid/recipes/docker-compose.rb | 12 +++++++--- .../docker-compose/app/nexus/etc/nginx/nginx.conf | 5 +++-- cookbooks/nexus-grid/version | 2 +- 6 files changed, 54 insertions(+), 9 deletions(-) diff --git a/cookbooks/nexus-grid/CHANGELOG.md b/cookbooks/nexus-grid/CHANGELOG.md index 3b5c429..f3b786e 100644 --- a/cookbooks/nexus-grid/CHANGELOG.md +++ b/cookbooks/nexus-grid/CHANGELOG.md @@ -1,5 +1,10 @@ # nexus-grid CHANGELOG +0.1.2 +----- +- adds the Nexus 2 support. +- adds Concourse pipeline configurations. + 0.1.1 ----- - adds a reverse proxy (nginx) service to the `nexus-grid::docker-compose` recipe. diff --git a/cookbooks/nexus-grid/README.md b/cookbooks/nexus-grid/README.md index c5fffd6..97af9a5 100644 --- a/cookbooks/nexus-grid/README.md +++ b/cookbooks/nexus-grid/README.md @@ -70,6 +70,7 @@ run_list( ) image = 'sonatype/nexus3' +#image = 'sonatype/nexus' # Nexus2 port = '8081' override_attributes( @@ -92,12 +93,22 @@ override_attributes( 'image' => image, 'volumes' => [ # This volume will be set by the nexus-grid::docker-compose recipe automatically. - #"#{node['nexus-grid']['docker-compose']['data_dir']}:/nexus-data", + # * Nexus3 + #"#{node['nexus-grid']['docker-compose']['data_dir']}:/nexus-data:rw", + # * Nexus2 + #"#{node['nexus-grid']['docker-compose']['data_dir']}:/sonatype-work:rw", ], 'environment' => { + # * Nexus3 #'JAVA_MAX_HEAP' => '1200m', # passed as -Xmx. Defaults to 1200m. #'JAVA_MIN_HEAP' => '1200m', # passed as -Xms. Defaults to 1200m. #'EXTRA_JAVA_OPTS' => '', # Additional options can be passed to the JVM via this variable. + # * Nexus2 + #'CONTEXT_PATH' => '/nexus', + #'MAX_HEAP' => '768m', + #'MIN_HEAP' => '256m', + #'JAVA_OPTS' => '-server -XX:MaxPermSize=192m -Djava.net.preferIPv4Stack=true', + #'LAUNCHER_CONF' => './conf/jetty.xml ./conf/jetty-requestlog.xml', }, }, }, @@ -120,6 +131,7 @@ run_list( ) image = 'sonatype/nexus3' +#image = 'sonatype/nexus' # Nexus2 port = '8081' cn = 'nexus.io.example.com' @@ -153,12 +165,22 @@ override_attributes( 'image' => image, 'volumes' => [ # This volume will be set by the nexus-grid::docker-compose recipe automatically. - #"#{node['nexus-grid']['docker-compose']['data_dir']}:/nexus-data", + # * Nexus3 + #"#{node['nexus-grid']['docker-compose']['data_dir']}:/nexus-data:rw", + # * Nexus2 + #"#{node['nexus-grid']['docker-compose']['data_dir']}:/sonatype-work:rw", ], 'environment' => { + # * Nexus3 #'JAVA_MAX_HEAP' => '1200m', # passed as -Xmx. Defaults to 1200m. #'JAVA_MIN_HEAP' => '1200m', # passed as -Xms. Defaults to 1200m. #'EXTRA_JAVA_OPTS' => '', # Additional options can be passed to the JVM via this variable. + # * Nexus2 + #'CONTEXT_PATH' => '/nexus', + #'MAX_HEAP' => '768m', + #'MIN_HEAP' => '256m', + #'JAVA_OPTS' => '-server -XX:MaxPermSize=192m -Djava.net.preferIPv4Stack=true', + #'LAUNCHER_CONF' => './conf/jetty.xml ./conf/jetty-requestlog.xml', }, }, }, diff --git a/cookbooks/nexus-grid/attributes/default.rb b/cookbooks/nexus-grid/attributes/default.rb index e156fc7..fe649f3 100644 --- a/cookbooks/nexus-grid/attributes/default.rb +++ b/cookbooks/nexus-grid/attributes/default.rb @@ -51,6 +51,7 @@ version_2_config = { }, 'nexus' => { 'restart' => 'always', + #'image' => 'sonatype/nexus', # Nexus2 'image' => 'sonatype/nexus3', 'ports' => [ # Do not expose! @@ -59,12 +60,22 @@ version_2_config = { ], 'volumes' => [ # This volume will be set by the nexus-grid::docker-compose recipe automatically. - #"#{node['nexus-grid']['docker-compose']['data_dir']}:/nexus-data", + # * Nexus3 + #"#{node['nexus-grid']['docker-compose']['data_dir']}:/nexus-data:rw", + # * Nexus2 + #"#{node['nexus-grid']['docker-compose']['data_dir']}:/sonatype-work:rw", ], 'environment' => { + # * Nexus3 #'JAVA_MAX_HEAP' => '1200m', # passed as -Xmx. Defaults to 1200m. #'JAVA_MIN_HEAP' => '1200m', # passed as -Xms. Defaults to 1200m. #'EXTRA_JAVA_OPTS' => '', # Additional options can be passed to the JVM via this variable. + # * Nexus2 + #'CONTEXT_PATH' => '/nexus', + #'MAX_HEAP' => '768m', + #'MIN_HEAP' => '256m', + #'JAVA_OPTS' => '-server -XX:MaxPermSize=192m -Djava.net.preferIPv4Stack=true', + #'LAUNCHER_CONF' => './conf/jetty.xml ./conf/jetty-requestlog.xml', }, }, }, diff --git a/cookbooks/nexus-grid/recipes/docker-compose.rb b/cookbooks/nexus-grid/recipes/docker-compose.rb index cf6b741..3f29d06 100644 --- a/cookbooks/nexus-grid/recipes/docker-compose.rb +++ b/cookbooks/nexus-grid/recipes/docker-compose.rb @@ -17,8 +17,6 @@ # limitations under the License. # -doc_url = 'https://hub.docker.com/r/sonatype/nexus3/' - include_recipe 'platform_utils::kernel_user_namespace' include_recipe 'docker-grid::compose' @@ -46,6 +44,10 @@ override_config_srvs = node.override['nexus-grid']['docker-compose']['config'][' rproxy_vols = config_srvs['reverseproxy']['volumes'].to_a nexus_vols = config_srvs['nexus']['volumes'].to_a +nexus_ver = config_srvs['nexus']['image'] =~ %r{^sonatype/nexus3} ? '3' : '2' +doc_url = 'https://hub.docker.com/r/sonatype' +doc_url = nexus_ver == '3' ? "#{doc_url}/nexus3/" : "#{doc_url}/nexus/" + ports = config_srvs['reverseproxy']['ports'] override_config_srvs['reverseproxy']['ports'] = ['8081:8081'] if ports.empty? @@ -55,6 +57,9 @@ template "#{etc_dir}/nginx/nginx.conf" do group 'root' mode '0644' action :create + variables( + nexus_ver: nexus_ver + ) end rproxy_vols.push("#{etc_dir}/nginx/nginx.conf:/etc/nginx/nginx.conf:ro") @@ -67,7 +72,8 @@ resources(directory: data_dir) rescue directory data_dir do recursive true end if !data_dir.nil? && !data_dir.empty? -nexus_vols.push("#{data_dir}:/nexus-data") if !data_dir.nil? && !data_dir.empty? +container_data_dir = nexus_ver == '3' ? '/nexus-data' : '/sonatype-work' +nexus_vols.push("#{data_dir}:#{container_data_dir}:rw") if !data_dir.nil? && !data_dir.empty? if node['nexus-grid']['with_ssl_cert_cookbook'] ::Chef::Recipe.send(:include, SSLCert::Helper) diff --git a/cookbooks/nexus-grid/templates/default/opt/docker-compose/app/nexus/etc/nginx/nginx.conf b/cookbooks/nexus-grid/templates/default/opt/docker-compose/app/nexus/etc/nginx/nginx.conf index 8f0908d..f69e316 100644 --- a/cookbooks/nexus-grid/templates/default/opt/docker-compose/app/nexus/etc/nginx/nginx.conf +++ b/cookbooks/nexus-grid/templates/default/opt/docker-compose/app/nexus/etc/nginx/nginx.conf @@ -1,5 +1,6 @@ <% ssl_enabled = node['nexus-grid']['with_ssl_cert_cookbook'] +context_path = @nexus_ver == '3' ? '/' : '/nexus' -%> worker_processes 1; @@ -24,8 +25,8 @@ http { listen 8081; <% end %> - location / { - proxy_pass http://docker-nexus; + location <%= context_path %> { + proxy_pass http://docker-nexus<%= context_path %>; proxy_redirect off; proxy_set_header Host $http_host; # $host does not include the port number. proxy_set_header X-Real-IP $remote_addr; diff --git a/cookbooks/nexus-grid/version b/cookbooks/nexus-grid/version index 17e51c3..d917d3e 100644 --- a/cookbooks/nexus-grid/version +++ b/cookbooks/nexus-grid/version @@ -1 +1 @@ -0.1.1 +0.1.2 -- 2.11.0