Class: Dapp::Build::Stage::SourceBase

Inherits:
Base
  • Object
show all
Defined in:
lib/dapp/build/stage/source_base.rb

Overview

Base of source stages

Direct Known Subclasses

Source1, Source1Archive, Source2, Source3, Source4, Source5

Constant Summary collapse

GITARTIFACT_IMAGE =
'dappdeps/gitartifact:0.1.3'.freeze

Instance Attribute Summary collapse

Attributes inherited from Base

#application, #next_stage, #prev_stage

Instance Method Summary collapse

Methods inherited from Base

#build!, #initialize

Methods included from Mod::Logging

#image_info, #log_build, #log_image_commands, #log_image_info, #should_be_introspected?, #should_be_not_present?, #should_be_skipped?, #size_difference?

Methods included from Mod::Artifact

#after_artifacts, #apply_artifact, #artifact_app_options, #artifacts_signatures, #before_artifacts, #do_artifacts, #safe_cp

Methods included from Helper::Trivia

class_to_lowercase, #class_to_lowercase, #delete_file, #kwargs

Methods included from Helper::Sha256

#hashsum, #sha256

Constructor Details

This class inherits a constructor from Dapp::Build::Stage::Base

Instance Attribute Details

#next_source_stage ⇒ Object

Returns the value of attribute next_source_stage.



6
7
8
# File 'lib/dapp/build/stage/source_base.rb', line 6

def next_source_stage
  @next_source_stage
end

#prev_source_stage ⇒ Object

Returns the value of attribute prev_source_stage.



6
7
8
# File 'lib/dapp/build/stage/source_base.rb', line 6

def prev_source_stage
  @prev_source_stage
end

Instance Method Details

#dependencies_checksum ⇒ Object



45
46
47
# File 'lib/dapp/build/stage/source_base.rb', line 45

def dependencies_checksum
  hashsum [prev_stage.signature, artifacts_signatures]
end

#image ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/dapp/build/stage/source_base.rb', line 27

def image
  super do |image|
    bash_commands = []
    volumes = []
    application.git_artifacts.each do |git_artifact|
      volumes << "#{git_artifact.repo.path}:#{git_artifact.repo.container_path}"
      bash_commands.concat(git_artifact.send(apply_command_method, self))
    end

    unless bash_commands.empty?
      image.add_volumes_from(gitartifact_container)
      image.add_volume(volumes)
      image.add_commands 'export PATH=/.dapp/deps/gitartifact/bin:$PATH', *bash_commands
    end
    yield image if block_given?
  end
end

#layer_commit(git_artifact) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/dapp/build/stage/source_base.rb', line 49

def layer_commit(git_artifact)
  commits[git_artifact] ||= begin
    if layer_commit_file_path(git_artifact).exist?
      layer_commit_file_path(git_artifact).read.strip
    else
      git_artifact.latest_commit
    end
  end
end

#save_in_cache! ⇒ Object



18
19
20
21
# File 'lib/dapp/build/stage/source_base.rb', line 18

def save_in_cache!
  super
  layers_commits_write!
end

#signature ⇒ Object



23
24
25
# File 'lib/dapp/build/stage/source_base.rb', line 23

def signature
  hashsum [dependencies_checksum, *commit_list]
end