Class: Docker::Rails::Server
Instance Attribute Summary
Attributes inherited from Container
#id, #removal_instructions
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Helpers
rails_image, rails_server
Methods inherited from Container
#add_removal_instructions, #attach!, #disable!, #exists_in?, #from_a?, #from_klass, #inspekt, #ip, #logs, #method_missing, #path, #remove!, #removed?, #to_klass, #up?
Methods included from Equality
#==
Constructor Details
#initialize(id) ⇒ Server
Returns a new instance of Server.
7
8
9
|
# File 'lib/docker/rails/server.rb', line 7
def initialize(id)
super
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Docker::Container
Class Method Details
.existing_server(path) ⇒ Object
45
46
47
48
49
50
|
# File 'lib/docker/rails/server.rb', line 45
def self.existing_server(path)
server = Rails.find_server(path)
return server if server && server.up?
server.remove! if server
nil
end
|
.load(id, path) ⇒ Object
29
30
31
32
|
# File 'lib/docker/rails/server.rb', line 29
def self.load(id, path)
server = new(id)
Docker::Rails.add_default_instructions_to(server, path)
end
|
.load_from(container) ⇒ Object
25
26
27
|
# File 'lib/docker/rails/server.rb', line 25
def self.load_from(container)
load(container.id, container.path)
end
|
.migrate_database!(path, postgres) ⇒ Object
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/docker/rails/server.rb', line 34
def self.migrate_database!(path, postgres)
['create', 'migrate'].each do |cmd|
Docker.run(
"#{rails_image(path.name)}",
"--rm --link db:db -e PG_HOST=#{postgres.ip} " +
"-v #{path}:/usr/src/app",
"rake db:#{cmd}"
)
end
end
|
.run(path, postgres) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/docker/rails/server.rb', line 11
def self.run(path, postgres)
server = existing_server(path)
return server if server
migrate_database!(path, postgres)
server = super(
"#{rails_image(path.name)}",
"-d --name #{rails_server(path.name)} --link db:db " +
"-e PG_HOST=#{postgres.ip} -v #{path}:/usr/src/app",
nil,
path
)
self.load(server.id, path)
end
|