Module: Docker::Rails

Extended by:
Docker, Helpers, Rails
Included in:
Rails
Defined in:
lib/docker/rails.rb,
lib/docker/rails/server.rb,
lib/docker/rails/console.rb

Defined Under Namespace

Classes: Console, Server

Constant Summary

Constants included from Docker

USER_NAME

Instance Method Summary collapse

Methods included from Helpers

rails_image, rails_server

Methods included from Docker

ID, PATH, all_containers, containers, find_container, find_containers, find_image, images, inspekt, validate_search_parameters

Instance Method Details

#add_default_instructions_to(server, path) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/docker/rails.rb', line 34

def add_default_instructions_to(server, path)
  path = Docker::PATH(path)
  server.add_removal_instructions do |container|
    # Give all users Read/Write Access to App
    Docker.run(
      "#{rails_image(path.name)}", 
      "--rm -v #{path}:/usr/src/app",
      "chmod -R a+rw /usr/src/app"
    )
    # Remove the tmp dir files and sub directories
    `rm -rf #{path}/tmp/*`
  end
end

#build(app_path) ⇒ Object



8
9
10
11
# File 'lib/docker/rails.rb', line 8

def build(app_path)
  path = Docker::PATH(app_path)
  Image.build(path, "rails-#{path.name}")
end

#find_server(path) ⇒ Object



48
49
50
51
52
# File 'lib/docker/rails.rb', line 48

def find_server(path)
  path   = Docker::PATH(path)
  server = Docker.find_container(name: rails_server(path.name))
  Rails::Server.load(server.id, path) if server
end

#postgresObject



13
14
15
# File 'lib/docker/rails.rb', line 13

def postgres
  Docker::Postgres.run('db')
end

#run(app_path, options = "", command = "") ⇒ Object



17
18
19
20
21
22
# File 'lib/docker/rails.rb', line 17

def run(app_path, options = "", command = "")
  path = Docker::PATH(app_path)
  image = rails_image(path.name)
  options = "#{options} -v #{path}:/usr/src/app"
  Docker::Container.run(image, options, command, path)
end

#run_console(app_path, options = "") ⇒ Object



29
30
31
32
# File 'lib/docker/rails.rb', line 29

def run_console(app_path, options = "")
  path = Docker::PATH(app_path)
  Docker::Rails::Console.run(path, postgres, options)
end

#run_server(app_path, options = "") ⇒ Object



24
25
26
27
# File 'lib/docker/rails.rb', line 24

def run_server(app_path, options = "")
  path = Docker::PATH(app_path)
  Docker::Rails::Server.run(path, postgres, options)
end