Sha256: d0c23fb771350d05cd35cd34543ac0f25c1e31d10b9ec85dc78f66906ab3f495

Contents?: true

Size: 790 Bytes

Versions: 27

Compression:

Stored size: 790 Bytes

Contents

# frozen_string_literal: true

module Orchestration
  module DockerCompose
    module ComposeHelpers
      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

      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
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
orchestration-0.7.15 lib/orchestration/docker_compose/compose_helpers.rb
orchestration-0.6.16 lib/orchestration/docker_compose/compose_helpers.rb
orchestration-0.7.14 lib/orchestration/docker_compose/compose_helpers.rb
orchestration-0.7.13 lib/orchestration/docker_compose/compose_helpers.rb
orchestration-0.6.15 lib/orchestration/docker_compose/compose_helpers.rb
orchestration-0.7.12 lib/orchestration/docker_compose/compose_helpers.rb
orchestration-0.6.14 lib/orchestration/docker_compose/compose_helpers.rb
orchestration-0.7.11 lib/orchestration/docker_compose/compose_helpers.rb
orchestration-0.6.13 lib/orchestration/docker_compose/compose_helpers.rb
orchestration-0.7.10 lib/orchestration/docker_compose/compose_helpers.rb
orchestration-0.7.9 lib/orchestration/docker_compose/compose_helpers.rb
orchestration-0.6.12 lib/orchestration/docker_compose/compose_helpers.rb
orchestration-0.7.8 lib/orchestration/docker_compose/compose_helpers.rb
orchestration-0.6.11 lib/orchestration/docker_compose/compose_helpers.rb
orchestration-0.7.6 lib/orchestration/docker_compose/compose_helpers.rb
orchestration-0.6.10 lib/orchestration/docker_compose/compose_helpers.rb
orchestration-0.7.5 lib/orchestration/docker_compose/compose_helpers.rb
orchestration-0.7.4 lib/orchestration/docker_compose/compose_helpers.rb
orchestration-0.6.9 lib/orchestration/docker_compose/compose_helpers.rb
orchestration-0.6.8 lib/orchestration/docker_compose/compose_helpers.rb