Class: Orchestration::DockerCompose::AppService

Inherits:
Object
  • Object
show all
Includes:
ComposeHelpers
Defined in:
lib/orchestration/docker_compose/app_service.rb

Overview

rubocop:disable Metrics/ClassLength

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ComposeHelpers

#networks, #sidecar_port

Constructor Details

#initialize(config, environment) ⇒ AppService

Returns a new instance of AppService.



9
10
11
12
# File 'lib/orchestration/docker_compose/app_service.rb', line 9

def initialize(config, environment)
  @environment = environment
  @config = config
end

Class Method Details

.commandObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/orchestration/docker_compose/app_service.rb', line 15

def command
  server = env.web_server
  %w[bundle exec] + case env.web_server
                    when 'puma'
                      %w[puma -C config/puma.rb]
                    when 'unicorn'
                      %w[unicorn -c config/unicorn.rb]
                    else
                      unsupported_web_server(server)
                    end
end

.entrypointObject



27
28
29
# File 'lib/orchestration/docker_compose/app_service.rb', line 27

def entrypoint
  ["/app/#{orchestration}/entrypoint.sh"]
end

.healthcheckObject



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/orchestration/docker_compose/app_service.rb', line 31

def healthcheck
  {
    'test' => ['bundle', 'exec', 'rake', 'orchestration:healthcheck'],
    # Defaults according to
    # https://docs.docker.com/engine/reference/builder/#healthcheck
    # Except start_period which cannot be set to 0s
    'interval' => '30s',
    'timeout' => '30s',
    'start_period' => '5s',
    'retries' => 3
  }
end

Instance Method Details

#definitionObject



64
65
66
67
68
69
70
71
72
73
# File 'lib/orchestration/docker_compose/app_service.rb', line 64

def definition
  {
    'image' => image,
    'environment' => environment,
    'ports' => ports,
    'deploy' => deploy,
    'logging' => logging,
    'networks' => networks
  }
end