class Dapp::Dimg::Build::Stage::ArtifactBase

Public Instance Methods

artifact?() click to toggle source
# File lib/dapp/dimg/build/stage/artifact_base.rb, line 32
def artifact?
  true
end
artifacts() click to toggle source
# File lib/dapp/dimg/build/stage/artifact_base.rb, line 22
def artifacts
  @artifacts ||= begin
    dimg.config.public_send("_#{name}").map do |artifact|
      artifact_dimg = dimg.dapp.artifact_dimg(config: artifact._config,
                                              ignore_signature_auto_calculation: dimg.ignore_signature_auto_calculation)
      { options: artifact._artifact_options, dimg: artifact_dimg }
    end
  end
end
dependencies() click to toggle source
# File lib/dapp/dimg/build/stage/artifact_base.rb, line 6
def dependencies
  @dependencies ||= artifacts_signatures
end
prepare_image() click to toggle source
Calls superclass method
# File lib/dapp/dimg/build/stage/artifact_base.rb, line 10
def prepare_image
  super do
    artifacts_dimgs_build!
    artifacts_labels = {}
    artifacts.each do |artifact|
      apply_artifact(artifact, image)
      artifacts_labels["dapp-artifact-#{artifact[:dimg].name}".to_sym] = artifact[:dimg].last_stage.image.built_id
    end
    image.add_service_change_label artifacts_labels
  end
end

Protected Instance Methods

artifacts_dimgs_build!() click to toggle source
# File lib/dapp/dimg/build/stage/artifact_base.rb, line 50
def artifacts_dimgs_build!
  artifacts.uniq { |artifact| artifact[:dimg] }.each do |artifact|
    process = dimg.dapp.t(code: 'process.artifact_building', data: { name: artifact[:dimg].name })
    dimg.dapp.log_secondary_process(process) { artifact[:dimg].build! }
  end
end
artifacts_signatures() click to toggle source
# File lib/dapp/dimg/build/stage/artifact_base.rb, line 46
def artifacts_signatures
  artifacts.map { |artifact| hashsum [artifact[:dimg].signature, artifact[:options]] }
end
ignore_log_commands?() click to toggle source
# File lib/dapp/dimg/build/stage/artifact_base.rb, line 42
def ignore_log_commands?
  true
end
run_artifact_dimg(artifact_dimg, commands) click to toggle source
# File lib/dapp/dimg/build/stage/artifact_base.rb, line 57
def run_artifact_dimg(artifact_dimg, commands)
  docker_options = ['--rm',
                    "--volume=#{dimg.tmp_path('artifact', artifact_dimg.name )}:#{artifact_dimg.container_tmp_path(artifact_dimg.name)}",
                    "--volumes-from=#{dimg.dapp.toolchain_container}",
                    "--volumes-from=#{dimg.dapp.base_container}",
                    "--entrypoint=#{dimg.dapp.bash_bin}"]
  dimg.dapp.log_secondary_process(dimg.dapp.t(code: 'process.artifact_copy', data:
    { name: artifact_dimg.name }), short: true) do
    artifact_dimg.run(docker_options, ["-ec", dimg.dapp.shellout_pack(commands)])
  end
rescue Error::Dimg => e
  raise unless e.net_status[:code] == :dimg_not_run
  raise Error::Build, code: :export_failed, data: { artifact_name: artifact_dimg.name }
end
should_not_be_detailed?() click to toggle source
# File lib/dapp/dimg/build/stage/artifact_base.rb, line 38
def should_not_be_detailed?
  true
end