# Cookbook Name:: concourse-ci
# Recipe:: docker-compose
#
-# Copyright 2017, whitestar
+# Copyright 2017-2018, whitestar
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
env_local = {}
File.open(env_file) do |file|
file.each_line do |line|
- env_local[$1] = $2 if line =~ /^(.*)=(.*)$/
+ env_local[$1] = $2 if line =~ /^([^=]*)=(.*)$/
end
end
end
if File.exist?(config_file)
require 'yaml'
config_srvs_local = YAML.load_file(config_file)
- config_srvs_local = config_srvs_local['services'] if config_srvs_local.key?('version') && config_srvs_local['version'] == '2'
+ config_srvs_local = config_srvs_local['services'] if config_srvs_local.key?('version') && config_srvs_local['version'].to_i >= 2
end
config_format_version = node['concourse-ci']['docker-compose']['config_format_version']
-# if config_format_version == '1'
+# if config_format_version.to_i == 1
config_srvs = node['concourse-ci']['docker-compose']['config']
override_config_srvs = node.override['concourse-ci']['docker-compose']['config']
force_override_config_srvs = node.force_override['concourse-ci']['docker-compose']['config']
-if config_format_version == '2'
+if config_format_version.to_i == 2
config_srvs = config_srvs['services']
override_config_srvs = override_config_srvs['services']
force_override_config_srvs = force_override_config_srvs['services']
end
external_url = web_envs_org['CONCOURSE_EXTERNAL_URL']
-web_envs['CONCOURSE_EXTERNAL_URL'] = "http://#{node['ipaddress']}:8080" if external_url.nil?
+external_url = "http://#{node['ipaddress']}:8080" if external_url.nil?
+web_envs['CONCOURSE_EXTERNAL_URL'] = external_url
data_source = web_envs_org['CONCOURSE_POSTGRES_DATA_SOURCE']
# for backward compatibility.
end
if node['concourse-ci']['with_ssl_cert_cookbook']
- include_recipe 'ssl_cert::server_key_pairs'
::Chef::Recipe.send(:include, SSLCert::Helper)
-
cn = node['concourse-ci']['ssl_cert']['common_name']
+ append_server_ssl_cn(cn)
+ include_recipe 'ssl_cert::server_key_pairs'
+
# Concourse web process owner is root.
web_vols.push("#{server_cert_path(cn)}:/root/server.crt:ro")
web_vols.push("#{server_key_path(cn)}:/root/server.key:ro")
# Common
if node['concourse-ci']['docker-compose']['import_ca']
- include_recipe 'ssl_cert::ca_certs'
::Chef::Recipe.send(:include, SSLCert::Helper)
node['concourse-ci']['ssl_cert']['ca_names'].each {|ca_name|
+ append_ca_name(ca_name)
ca_cert_vol = "#{ca_cert_path(ca_name)}:/usr/share/ca-certificates/#{ca_name}.crt:ro"
web_vols.push(ca_cert_vol)
worker_vols.push(ca_cert_vol)
}
+ include_recipe 'ssl_cert::ca_certs'
import_ca_script = '/usr/local/bin/concourse_import_ca'
template "#{bin_dir}/concourse_import_ca" do
= "/bin/sh -c \"#{import_ca_script} && #{image_entrypoint} web\""
override_config_srvs['concourse-worker']['entrypoint'] \
= "/bin/sh -c \"#{import_ca_script} && #{image_entrypoint} worker\""
- if config_format_version == '2'
+ if config_format_version.to_i == 2
node.rm('concourse-ci', 'docker-compose', 'config', 'services', 'concourse-web', 'command')
node.rm('concourse-ci', 'docker-compose', 'config', 'services', 'concourse-worker', 'command')
else
mode '0600'
end
+template "#{bin_dir}/fly_prune_workers_main" do
+ source 'opt/docker-compose/app/concourse/bin/fly_prune_workers_main'
+ owner 'root'
+ group 'root'
+ mode '0755'
+ action :create
+ variables(
+ external_url: external_url
+ )
+end
+
log <<-"EOM"
Note: You must execute the following command manually.
See #{doc_url}
- - Start:
+ * Start:
$ cd #{app_dir}
$ sudo docker-compose up
- - Stop
+ * Stop
$ sudo docker-compose down
EOM