Class: Kuby::Docker::SetupPhase

Inherits:
Layer
  • Object
show all
Defined in:
lib/kuby/docker/setup_phase.rb

Constant Summary collapse

DEFAULT_WORKING_DIR =

extend T::Sig

'/usr/src/app'.freeze

Instance Attribute Summary collapse

Attributes inherited from Layer

#environment

Instance Method Summary collapse

Constructor Details

#initialize(environment, docker_spec) ⇒ SetupPhase

T::Sig::WithoutRuntime.sig { params(environment: Environment, docker_spec: Docker::Spec).void }



29
30
31
32
33
34
35
36
# File 'lib/kuby/docker/setup_phase.rb', line 29

def initialize(environment, docker_spec)
  super(environment)

  # @base_image = T.let(@base_image, T.nilable(String))
  # @working_dir = T.let(@working_dir, T.nilable(String))
  # @rails_env = T.let(@rails_env, T.nilable(String))
  @docker_spec = docker_spec
end

Instance Attribute Details

#base_imageObject

T::Sig::WithoutRuntime.sig { returns(String) }



48
49
50
# File 'lib/kuby/docker/setup_phase.rb', line 48

def base_image
  @base_image || default_base_image
end

#docker_specObject (readonly)

T::Sig::WithoutRuntime.sig { returns(Docker::Spec) }



26
27
28
# File 'lib/kuby/docker/setup_phase.rb', line 26

def docker_spec
  @docker_spec
end

#rails_envObject

T::Sig::WithoutRuntime.sig { returns(T.nilable(String)) }



20
21
22
# File 'lib/kuby/docker/setup_phase.rb', line 20

def rails_env
  @rails_env
end

#working_dirObject

T::Sig::WithoutRuntime.sig { returns(T.nilable(String)) }



14
15
16
# File 'lib/kuby/docker/setup_phase.rb', line 14

def working_dir
  @working_dir
end

Instance Method Details

#apply_to(dockerfile) ⇒ Object

T::Sig::WithoutRuntime.sig { override.params(dockerfile: Dockerfile).void }



39
40
41
42
43
44
45
# File 'lib/kuby/docker/setup_phase.rb', line 39

def apply_to(dockerfile)
  dockerfile.from(base_image)
  dockerfile.workdir(working_dir || DEFAULT_WORKING_DIR)
  dockerfile.env("RAILS_ENV=#{rails_env || Kuby.env}")
  dockerfile.env("KUBY_ENV=#{Kuby.env}")
  dockerfile.arg('RAILS_MASTER_KEY')
end