Class: Orchestration::DockerCompose::AppService

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, environment) ⇒ AppService

Returns a new instance of AppService.



6
7
8
9
# File 'lib/orchestration/docker_compose/app_service.rb', line 6

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

Class Method Details

.commandObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/orchestration/docker_compose/app_service.rb', line 12

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



24
25
26
# File 'lib/orchestration/docker_compose/app_service.rb', line 24

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

.healthcheckObject



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/orchestration/docker_compose/app_service.rb', line 28

def healthcheck
  {
    'test' => ['ruby', "/app/#{orchestration}/healthcheck.rb"],
    # 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



61
62
63
64
65
66
67
68
69
# File 'lib/orchestration/docker_compose/app_service.rb', line 61

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