Module: Orchestration::DockerCompose::ComposeHelpers

Included in:
AppService, DatabaseService, MongoService, RabbitMQService, RedisService
Defined in:
lib/orchestration/docker_compose/compose_helpers.rb

Instance Method Summary collapse

Instance Method Details

#networksObject



17
18
19
20
21
# File 'lib/orchestration/docker_compose/compose_helpers.rb', line 17

def networks
  service = self.class.name.rpartition('::').last.partition('Service').first.downcase
  network_alias = %i[development test].include?(@environment) ? service : "#{service}-local"
  { 'local' => { 'aliases' => [network_alias] } }
end

#sidecar_port(environment) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/orchestration/docker_compose/compose_helpers.rb', line 6

def sidecar_port(environment)
  port = Orchestration.random_local_port
  return "#{port}:" unless environment == :test

  # If env var `sidecar` is not set then ports will be configured as e.g.:
  # "50123:3306"
  # otherwise it will be:
  # "3306" (docker will use an ephemeral host port which we will not use)
  "${sidecar-#{port}:}"
end