From aba833f2a76925a528fb1eae29dc0670b4a4968d Mon Sep 17 00:00:00 2001 From: Raul E Rangel Date: Wed, 7 May 2014 09:28:52 -0600 Subject: [PATCH 1/3] Update to Docker Registry 0.6.8 * Fixes #4 * Fix `vagrant up` --- README.md | 2 +- attributes/default.rb | 4 ++-- metadata.rb | 2 +- recipes/default.rb | 17 ++++++++++++++--- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7aa588a..0726937 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ License and Author Author:: Raul E Rangel () -Copyright 2013, Raul E Rangel. +Copyright 2014, Raul E Rangel. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/attributes/default.rb b/attributes/default.rb index 779883d..754c6a8 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -20,7 +20,7 @@ # default['docker-registry']['repository'] = "https://github.com/dotcloud/docker-registry.git" -default['docker-registry']['revision'] = "0.6.3" +default['docker-registry']['revision'] = "0.6.8" default['docker-registry']['install_dir'] = "/opt/docker-registry" @@ -32,7 +32,7 @@ default['docker-registry']['workers'] = 8 default['docker-registry']['max_requests'] = 100 default['docker-registry']['timeout'] = 3600 -default['docker-registry']['packages'] = %w(libevent-dev git) +default['docker-registry']['packages'] = %w(libevent-dev git libffi-dev liblzma-dev) default['docker-registry']['flavor'] = 'dev' default['docker-registry']['secret_key'] = nil diff --git a/metadata.rb b/metadata.rb index 2f91eda..0285cfb 100644 --- a/metadata.rb +++ b/metadata.rb @@ -3,7 +3,7 @@ maintainer_email "Raul.Rangel@Disney.com.com" license "Apache 2.0" description "Installs and configures docker-registry" -version "0.0.4dev" +version "0.0.5" recipe "docker-registry", "Installs the docker-registry and sets up configuration" diff --git a/recipes/default.rb b/recipes/default.rb index 1c5359b..19245ef 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -85,6 +85,15 @@ raise ArgumentError, "secret_key is not defined" unless secret_key +# Make sure we create the env directory before gunicorn +[node['docker-registry']['install_dir'], ::File.join(node['docker-registry']['install_dir'], "env")].each do |path| + directory path do + owner node['docker-registry']['owner'] + group node['docker-registry']['group'] + mode 00755 + end +end + application "docker-registry" do owner node['docker-registry']['owner'] group node['docker-registry']['group'] @@ -93,8 +102,10 @@ revision node['docker-registry']['revision'] packages node['docker-registry']['packages'] + shallow_clone false + action :force_deploy - symlinks "config.yml" => "config.yml" + symlinks "config.yml" => "config/config.yml" before_migrate do template "#{new_resource.path}/shared/config.yml" do @@ -103,11 +114,11 @@ owner node['docker-registry']['owner'] group node['docker-registry']['group'] variables({ - :secret_key => secret_key, + :secret_key => secret_key, :storage => node['docker-registry']['storage'], :storage_path => node['docker-registry']['storage_path'], :standalone => node['docker-registry']['standalone'], - :index_endpoint => node['docker-registry']['index_endpoint'], + :index_endpoint => node['docker-registry']['index_endpoint'], :s3_access_key => node['docker-registry']['s3_access_key'], :s3_secret_key => s3_secret_key, :s3_bucket => node['docker-registry']['s3_bucket'], From d208b8a5be95e4829aa840d1953b74b210ec6b0a Mon Sep 17 00:00:00 2001 From: Martin Forssen Date: Mon, 12 May 2014 09:45:09 +0200 Subject: [PATCH 2/3] Refactored the code to not depend on the name of the roles in the run list. Instead I added two new recipes which each just sets an attribute and include the default recipe. The checks in teh default recipe now looks at these attributes rather than at which roles are in the run-list. --- recipes/application_server.rb | 23 +++++++++++++++++++ recipes/default.rb | 4 ++-- recipes/load_balancer.rb | 23 +++++++++++++++++++ roles/docker-registry_application_server.json | 2 +- roles/docker-registry_load_balancer.json | 2 +- 5 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 recipes/application_server.rb create mode 100644 recipes/load_balancer.rb diff --git a/recipes/application_server.rb b/recipes/application_server.rb new file mode 100644 index 0000000..cf609f8 --- /dev/null +++ b/recipes/application_server.rb @@ -0,0 +1,23 @@ +# +# Cookbook Name:: docker-registry +# Recipe:: application_server +# Author:: Raul E Rangel () +# +# Copyright 2013, Raul E Rangel +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +node.default['docker-registry']['application_server'] = true + +include_recipe "docker-registry" diff --git a/recipes/default.rb b/recipes/default.rb index 19245ef..6311287 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -127,7 +127,7 @@ end gunicorn do - only_if { node['roles'].include?('docker-registry_application_server') } + only_if { node['docker-registry']['application_server'] } requirements "requirements.txt" max_requests node['docker-registry']['max_requests'] @@ -141,7 +141,7 @@ end nginx_load_balancer do - only_if { node['roles'].include?('docker-registry_load_balancer') } + only_if { node['docker-registry']['load_balancer'] } application_port node['docker-registry']['internal_port'] application_server_role node['docker-registry']['application_server_role'] diff --git a/recipes/load_balancer.rb b/recipes/load_balancer.rb new file mode 100644 index 0000000..cc6746a --- /dev/null +++ b/recipes/load_balancer.rb @@ -0,0 +1,23 @@ +# +# Cookbook Name:: docker-registry +# Recipe:: load_balancer +# Author:: Raul E Rangel () +# +# Copyright 2013, Raul E Rangel +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +node.default['docker-registry']['load_balancer'] = true + +include_recipe "docker-registry" diff --git a/roles/docker-registry_application_server.json b/roles/docker-registry_application_server.json index 0d9ea3e..bbc82db 100644 --- a/roles/docker-registry_application_server.json +++ b/roles/docker-registry_application_server.json @@ -8,7 +8,7 @@ }, "chef_type": "role", "run_list": [ - "recipe[docker-registry]" + "recipe[docker-registry::application_server]" ], "env_run_lists": { } diff --git a/roles/docker-registry_load_balancer.json b/roles/docker-registry_load_balancer.json index 78251e0..828871f 100644 --- a/roles/docker-registry_load_balancer.json +++ b/roles/docker-registry_load_balancer.json @@ -15,7 +15,7 @@ }, "chef_type": "role", "run_list": [ - "recipe[docker-registry]" + "recipe[docker-registry::load_balancer]" ], "env_run_lists": { } From b682ef04b02e72217ab68ab7dcf8074ea8ae472a Mon Sep 17 00:00:00 2001 From: Martin Forssen Date: Mon, 12 May 2014 09:48:44 +0200 Subject: [PATCH 3/3] Updated copyright years --- recipes/application_server.rb | 2 +- recipes/load_balancer.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/application_server.rb b/recipes/application_server.rb index cf609f8..637bc06 100644 --- a/recipes/application_server.rb +++ b/recipes/application_server.rb @@ -3,7 +3,7 @@ # Recipe:: application_server # Author:: Raul E Rangel () # -# Copyright 2013, Raul E Rangel +# Copyright 2014, Raul E Rangel # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/recipes/load_balancer.rb b/recipes/load_balancer.rb index cc6746a..9192441 100644 --- a/recipes/load_balancer.rb +++ b/recipes/load_balancer.rb @@ -3,7 +3,7 @@ # Recipe:: load_balancer # Author:: Raul E Rangel () # -# Copyright 2013, Raul E Rangel +# Copyright 2014, Raul E Rangel # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.