Class: Shiplane::Deploy::ContainerConfiguration
Instance Attribute Summary
#env, #name, #options
Instance Method Summary
collapse
#docker_command, #initialize
Instance Method Details
#container_name ⇒ Object
24
25
26
|
# File 'lib/shiplane/deploy/container_configuration.rb', line 24
def container_name
@container_name ||= "#{env.fetch(:application)}_#{name}_#{env.fetch(:sha)}"
end
|
#exposed_ports ⇒ Object
18
19
20
21
22
|
# File 'lib/shiplane/deploy/container_configuration.rb', line 18
def exposed_ports
@exposed_ports ||= [options.fetch(:expose, [])].flatten - published_ports
rescue => e
binding.pry
end
|
#image_name ⇒ Object
28
29
30
|
# File 'lib/shiplane/deploy/container_configuration.rb', line 28
def image_name
@image_name ||= "#{options.fetch(:repo)}:#{image_tag}"
end
|
#image_tag ⇒ Object
32
33
34
|
# File 'lib/shiplane/deploy/container_configuration.rb', line 32
def image_tag
@image_tag ||= options.fetch(:tag, "#{env.fetch(:stage)}-#{env.fetch(:sha)}")
end
|
#letsencrypt_email ⇒ Object
44
45
46
|
# File 'lib/shiplane/deploy/container_configuration.rb', line 44
def letsencrypt_email
@letsencrypt_email ||= options[:letsencrypt_email]
end
|
#letsencrypt_host ⇒ Object
40
41
42
|
# File 'lib/shiplane/deploy/container_configuration.rb', line 40
def letsencrypt_host
@letsencrypt_host ||= options.fetch(:letsencrypt_host, virtual_host)
end
|
#network_alias ⇒ Object
6
7
8
|
# File 'lib/shiplane/deploy/container_configuration.rb', line 6
def network_alias
@network_alias ||= options.fetch(:alias, container_name)
end
|
#network_connect_commands(role) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/shiplane/deploy/container_configuration.rb', line 56
def network_connect_commands(role)
@network_commands ||= networks.map do |network|
[
docker_command(role),
"network connect",
"--alias #{network_alias}",
network,
container_name,
"|| true",
].flatten.compact.join(" ")
end
end
|
#networks ⇒ Object
48
49
50
|
# File 'lib/shiplane/deploy/container_configuration.rb', line 48
def networks
@networks ||= options.fetch(:networks, [])
end
|
#published_ports ⇒ Object
14
15
16
|
# File 'lib/shiplane/deploy/container_configuration.rb', line 14
def published_ports
@published_ports ||= [options.fetch(:publish, [])].flatten
end
|
#run_command(role) ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/shiplane/deploy/container_configuration.rb', line 69
def run_command(role)
@command ||= [
docker_command(role),
"run -d",
volumes.map{|volume_set| "-v #{volume_set}" },
published_ports.map{|port| "--expose #{port} -p #{port}" },
exposed_ports.map{|port| "--expose #{port}" },
"--name #{container_name}",
virtual_host ? "-e VIRTUAL_HOST=#{virtual_host}" : nil,
letsencrypt_host ? "-e LETSENCRYPT_HOST=#{letsencrypt_host}" : nil,
letsencrypt_email ? "-e LETSENCRYPT_EMAIL=#{letsencrypt_email}" : nil,
image_name,
startup_command ? startup_command : nil,
].flatten.compact.join(" ")
end
|
#run_commands(role) ⇒ Object
85
86
87
88
89
90
|
# File 'lib/shiplane/deploy/container_configuration.rb', line 85
def run_commands(role)
@run_commands ||= [
run_command(role),
network_connect_commands(role),
].flatten
end
|
#startup_command ⇒ Object
52
53
54
|
# File 'lib/shiplane/deploy/container_configuration.rb', line 52
def startup_command
@startup_command ||= options[:command]
end
|
#virtual_host ⇒ Object
36
37
38
|
# File 'lib/shiplane/deploy/container_configuration.rb', line 36
def virtual_host
@virtual_host ||= options[:virtual_host]
end
|
#volumes ⇒ Object
10
11
12
|
# File 'lib/shiplane/deploy/container_configuration.rb', line 10
def volumes
@volumes ||= options.fetch(:volumes, [])
end
|