Sha256: bdffe65628a3b7b2d41953cf7686fae8c289f86b3f9619fedae463bb6b6e8cb0

Contents?: true

Size: 1.09 KB

Versions: 6

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

module Orchestration
  module DockerCompose
    class ApplicationService
      def initialize(config)
        @config = config
      end

      def definition
        {
          'image' => image,
          'entrypoint' => '/entrypoint.sh',
          'command' => %w[
            bundle exec unicorn -c /application/config/unicorn.rb
          ],
          'environment' => environment,
          'expose' => [8080]
        }
      end

      private

      def image
        "#{@config.docker_username}/#{@config.application_name}"
      end

      def environment
        {
          'DATABASE_URL' => @config.database_url,
          'RAILS_LOG_TO_STDOUT' => '1',
          'UNICORN_PRELOAD_APP' => '1',
          'UNICORN_TIMEOUT' => '60',
          'UNICORN_WORKER_PROCESSES' => '8',
          'VIRTUAL_PORT' => '8080',
          'VIRTUAL_HOST' => 'localhost'
        }.merge(inherited_environment)
      end

      def inherited_environment
        {
          'HOST_UID' => nil,
          'RAILS_ENV' => nil,
          'SECRET_KEY_BASE' => nil
        }
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
orchestration-0.2.8 lib/orchestration/docker_compose/application_service.rb
orchestration-0.2.7 lib/orchestration/docker_compose/application_service.rb
orchestration-0.2.6 lib/orchestration/docker_compose/application_service.rb
orchestration-0.2.5 lib/orchestration/docker_compose/application_service.rb
orchestration-0.2.4 lib/orchestration/docker_compose/application_service.rb
orchestration-0.2.3 lib/orchestration/docker_compose/application_service.rb