Class: OdaniaStaticPages::Deploy::DockerCompose

Inherits:
Object
  • Object
show all
Includes:
NginxHelper
Defined in:
lib/odania_static_pages/deploy/docker_compose.rb

Defined Under Namespace

Classes: DockerComposeGenerator

Instance Method Summary collapse

Methods included from NginxHelper

#generate_nginx_config, #grouped_domains

Constructor Details

#initializeDockerCompose

Returns a new instance of DockerCompose.



6
7
8
9
10
11
12
13
# File 'lib/odania_static_pages/deploy/docker_compose.rb', line 6

def initialize
	@config = OdaniaStaticPages.config
	@environment = @config.current_environment
	@deploy_config = @environment.deploy_module
	@generator_config = @config.generator
	@nginx_dir = File.join(@config.output_path, 'nginx')
	@nginx_conf_dir = File.join(@nginx_dir, 'conf.d')
end

Instance Method Details

#prepareObject



15
16
17
18
19
20
21
# File 'lib/odania_static_pages/deploy/docker_compose.rb', line 15

def prepare
	puts 'Preparing docker-compose state'
	load_state
	state_path = File.dirname(@deploy_config.state_file)
	FileUtils.mkdir_p state_path unless File.exist? state_path
	save_state
end

#publish(color, do_rebuild) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/odania_static_pages/deploy/docker_compose.rb', line 23

def publish(color, do_rebuild)
	puts 'docker-compose'
	load_state
	color = color.nil? ? @state[:color] : color
	new_color = 'green'.eql?(color) ? 'blue' : 'green'
	puts " -> Current color: #{color}"
	@site_path = @config.output_site_path
	puts " -> Deploying to color: #{new_color} [Path: #{@site_path}]"

	generate_compose_config
	generate_nginx_config(do_rebuild)
	prepare_varnish

	@config.current_environment.do_notify new_color, color
	puts
	puts "Finished deploying color #{new_color}"
end