Class: Kraaken::App
- Inherits:
-
Object
- Object
- Kraaken::App
- Defined in:
- lib/kraaken/app.rb
Instance Attribute Summary collapse
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
- #create ⇒ Object
- #deploy(file) ⇒ Object
- #destroy ⇒ Object
- #environment ⇒ Object
- #environment=(content) ⇒ Object
- #full_name ⇒ Object
-
#initialize(name:, destination:, server:, config:) ⇒ App
constructor
A new instance of App.
- #logs ⇒ Object
Constructor Details
#initialize(name:, destination:, server:, config:) ⇒ App
Returns a new instance of App.
6 7 8 9 10 11 |
# File 'lib/kraaken/app.rb', line 6 def initialize(name:, destination:, server:, config:) @name = name @destination = destination @server = server @config = config end |
Instance Attribute Details
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
4 5 6 |
# File 'lib/kraaken/app.rb', line 4 def destination @destination end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/kraaken/app.rb', line 4 def name @name end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
4 5 6 |
# File 'lib/kraaken/app.rb', line 4 def server @server end |
Instance Method Details
#create ⇒ Object
26 27 28 29 30 31 |
# File 'lib/kraaken/app.rb', line 26 def create ssh.connect(server) do |ssh| ssh.run("mkdir -p ~/#{full_name}") ssh.run("touch ~/#{full_name}/.env") end end |
#deploy(file) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/kraaken/app.rb', line 33 def deploy(file) ssh.connect(server) do |ssh| ssh.run <<~BASH mkdir -p ~/#{full_name} cd ~/#{full_name} touch .env BASH ssh.write_file("~/#{full_name}/docker-compose.yml", config.load_template(file.path, app: self)) ssh.run <<~BASH cd ~/#{full_name} docker-compose pull docker-compose up -d BASH end end |
#destroy ⇒ Object
49 50 51 52 53 54 |
# File 'lib/kraaken/app.rb', line 49 def destroy ssh.connect(server) do |ssh| ssh.run("cd ~/#{full_name} && docker-compose down --volumes --remove-orphans") ssh.run("rm -rf ~/#{full_name}") end end |
#environment ⇒ Object
13 14 15 16 17 18 |
# File 'lib/kraaken/app.rb', line 13 def environment create ssh.connect(server) do |ssh| ssh.read_file("~/#{full_name}/.env") end end |
#environment=(content) ⇒ Object
20 21 22 23 24 |
# File 'lib/kraaken/app.rb', line 20 def environment=(content) ssh.connect(server) do |ssh| ssh.write_file("~/#{full_name}/.env", content) end end |
#full_name ⇒ Object
62 63 64 |
# File 'lib/kraaken/app.rb', line 62 def full_name "#{name}-#{destination}" end |
#logs ⇒ Object
56 57 58 59 60 |
# File 'lib/kraaken/app.rb', line 56 def logs ssh.connect(server) do |ssh| ssh.run("cd ~/#{full_name} && docker-compose logs -f") end end |