2 # Cookbook Name:: docker-grid
5 # Copyright 2016, whitestar
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
20 doc_url = 'https://docs.docker.com/registry/deploying/#/managing-with-compose'
22 include_recipe 'docker-grid::compose'
24 app_dir = node['docker-grid']['registry']['docker-compose']['app_dir']
25 auth_dir = "#{app_dir}/auth"
26 etc_dir = "#{app_dir}/etc"
32 resources(directory: dir) rescue directory dir do
43 host_data_volume = node['docker-grid']['registry']['docker-compose']['host_data_volume']
44 unless host_data_volume.nil?
45 directory host_data_volume do
52 volumes.push("#{host_data_volume}:/var/lib/registry")
55 if node['docker-grid']['registry']['with_ssl_cert_cookbook']
56 ::Chef::Recipe.send(:include, SSLCert::Helper)
57 cn = node['docker-grid']['registry']['ssl_cert']['common_name']
59 environment['REGISTRY_HTTP_TLS_CERTIFICATE'] = '/certs/domain.crt'
60 environment['REGISTRY_HTTP_TLS_KEY'] = '/certs/domain.key'
61 volumes.push("#{server_cert_path(cn)}:/certs/domain.crt:ro")
62 volumes.push("#{server_key_path(cn)}:/certs/domain.key:ro")
65 unless node['docker-grid']['registry']['docker-compose']['registry-config'].nil?
66 template "#{app_dir}/etc/config.yml" do
67 source 'opt/docker-compose/app/registry/etc/config.yml'
73 volumes.push('./etc/config.yml:/etc/docker/registry/config.yml:ro')
76 service_name = node['docker-grid']['registry']['docker-compose']['service_name']
82 version_1_config[service_name]['environment'] = environment unless environment.empty?
83 version_1_config[service_name]['volumes'] = volumes unless volumes.empty?
86 'services' => version_1_config,
89 node.override['docker-grid']['registry']['docker-compose']['config'] = \
90 node['docker-grid']['registry']['docker-compose']['config_format_version'] == '2' ? version_2_config : version_1_config
95 template "#{app_dir}/#{conf_file}" do
96 source "opt/docker-compose/app/registry/#{conf_file}"
104 Note: You must execute the following command manually.
108 $ docker-compose up -d
110 $ docker-compose down