Class: Kuby::Docker::AppPhase

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

Instance Attribute Summary

Attributes inherited from Layer

#environment

Instance Method Summary collapse

Constructor Details

#initialize(environment) ⇒ AppPhase

T::Sig::WithoutRuntime.sig { params(environment: Environment).void }



9
10
11
12
13
# File 'lib/kuby/docker/app_phase.rb', line 9

def initialize(environment)
  super

  @env_vars = {}
end

Instance Method Details

#apply_to(dockerfile) ⇒ Object

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



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/kuby/docker/app_phase.rb', line 16

def apply_to(dockerfile)
  @env_vars.each_pair do |key, value|
    dockerfile.env("#{key}='#{value}'")
  end

  absolute_app_root = Pathname(dockerfile.current_workdir)
    .join(environment.docker.app_root_path)
    .to_s

  if dockerfile.current_workdir != absolute_app_root
    dockerfile.workdir(absolute_app_root)
  end
end

#env(key, value) ⇒ Object

T::Sig::WithoutRuntime.sig { params(key: String, value: String).void }



31
32
33
# File 'lib/kuby/docker/app_phase.rb', line 31

def env(key, value)
  @env_vars[key] = value
end