Class: Docker::Compose::RakeTasks

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/docker/compose/rake_tasks.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ RakeTasks

Construct Rake wrapper tasks for docker-compose. If a block is given, yield self to the block before defining any tasks so their behavior can be configured by calling #server_env=, #file= and so forth.

Yields:

  • (_self)

Yield Parameters:



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/docker/compose/rake_tasks.rb', line 48

def initialize
  self.dir = Rake.application.original_dir
  self.file = 'docker-compose.yml'
  self.server_env = {}
  self.extra_server_env = {}
  yield self if block_given?

  @shell = Docker::Compose::Shell.new
  @session = Docker::Compose::Session.new(@shell, dir:dir, file:file)
  @net_info = Docker::Compose::NetInfo.new

  @shell.interactive = true

  define
end

Instance Attribute Details

#dirString

Set the directory in which docker-compose commands will be run. Default is the directory in which Rakefile is located.

Returns:

  • (String)


12
13
14
# File 'lib/docker/compose/rake_tasks.rb', line 12

def dir
  @dir
end

#extra_server_envObject

Extra environment variables that should be set before invoking the command specified for docker:compose:server. These are set _in addition_ to server_env (and should be disjoint from server_env), and do not necessarily need to map the location of a container; they are simply extra environment values that are useful to change the server’s behavior when it runs in cooperation with containers.

If there is overlap between server_env and extra_server_env, then keys of extra_server_env will “win”; they are set last.



38
39
40
# File 'lib/docker/compose/rake_tasks.rb', line 38

def extra_server_env
  @extra_server_env
end

#fileString

Set the name of the docker-compose file. Default is`docker-compose.yml`.

Returns:

  • (String)


16
17
18
# File 'lib/docker/compose/rake_tasks.rb', line 16

def file
  @file
end

#serverObject

Command to exec on the host when someone invokes docker:compose:server. This is used to start up all containers and then run a server that depends on them and is properly linked to them.



43
44
45
# File 'lib/docker/compose/rake_tasks.rb', line 43

def server
  @server
end

#server_envObject

Provide a mapping of environment variables that should be set in the host shell for docker:compose:env or docker:compose:server. The values of the environment variables can refer to names of services and ports defined in the docker-compose file, and this gem will query docker-compose to find out which host IP and port the services are reachable on. This allows components running on the host to connect to services running inside containers.



27
28
29
# File 'lib/docker/compose/rake_tasks.rb', line 27

def server_env
  @server_env
end