Module: Drydock

Defined in:
lib/drydock.rb,
lib/drydock/phase.rb,
lib/drydock/errors.rb,
lib/drydock/logger.rb,
lib/drydock/drydock.rb,
lib/drydock/project.rb,
lib/drydock/cli_flags.rb,
lib/drydock/formatters.rb,
lib/drydock/tar_writer.rb,
lib/drydock/phase_chain.rb,
lib/drydock/plugins/apk.rb,
lib/drydock/plugins/npm.rb,
lib/drydock/file_manager.rb,
lib/drydock/plugins/base.rb,
lib/drydock/stream_monitor.rb,
lib/drydock/runtime_options.rb,
lib/drydock/container_config.rb,
lib/drydock/image_repository.rb,
lib/drydock/plugins/rubygems.rb,
lib/drydock/instructions/base.rb,
lib/drydock/instructions/copy.rb,
lib/drydock/object_caches/base.rb,
lib/drydock/ignorefile_definition.rb,
lib/drydock/object_caches/no_cache.rb,
lib/drydock/plugins/package_manager.rb,
lib/drydock/object_caches/in_memory_cache.rb,
lib/drydock/object_caches/filesystem_cache.rb

Overview

Drydock is a command line program that provides a DSL for you to create your own build pipeline for your docker images. See README for more information and background on the design.

Defined Under Namespace

Modules: Formatters, Instructions, ObjectCaches, Plugins Classes: CliFlags, ContainerConfig, ExecutionError, FileManager, Formatter, IgnorefileDefinition, ImageRepository, InsufficientVersionError, InvalidCommandExecutionError, InvalidInstructionError, Logger, OperationError, Phase, PhaseChain, Project, RuntimeOptions, StreamMonitor, TarWriter

Class Method Summary collapse

Class Method Details

The application's banner.

Returns:

  • (String)

    the banner



10
11
12
# File 'lib/drydock/drydock.rb', line 10

def self.banner
  "Drydock v#{Drydock.version}"
end

.build(build_opts = {}) {|project| ... } ⇒ Object

Create a new project, then run and finalize the build.

Parameters:

  • build_opts (Hash) (defaults to: {})

    Build-time options

Options Hash (build_opts):

  • :auto_remove (Boolean)

    Whether intermediate images created during the build of this project should be automatically removed.

  • :author (String)

    The default author field when an author is not provided explicitly with Drydock::Project#author.

  • :cache (ObjectCaches::Base)

    An object cache manager.

  • :event_handler (#call)

    A handler that responds to a #call message with four arguments: [event, is_new, serial_no, event_type] most useful to override logging.

  • :chain (PhaseChain)

    A phase chain manager.

  • :ignorefile (String)

    The name of the ignore-file to load.

Yields:

  • (project)

    A block that describes the logic on how to search for a Drydockfile.

Yield Parameters:

  • project (Project)

    A newly-instantiated project object.

Yield Returns:

  • (Array<String>)

    An array of exactly two elements: the contents of the Drydockfile, and the path to the Drydockfile. The directory of the path will be made as the working directory.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/drydock/drydock.rb', line 24

def self.build(build_opts = {}, &blk)
  Project.new(build_opts).tap do |project|
    dryfile, dryfilename = yield project

    Dir.chdir(File.dirname(dryfilename))
    Drydock.logger.info("Working directory set to #{Dir.pwd}")

    begin
      catch :done do
        project.instance_eval(dryfile, dryfilename)
      end
    rescue => e
      Drydock.logger.error("Error processing #{dryfilename}:")
      Drydock.logger.error(message: "#{e.class}: #{e.message}")
      e.backtrace.each do |backtrace|
        Drydock.logger.debug(message: "#{backtrace}", indent: 1)
      end
    ensure
      Drydock.logger.info("Cleaning up")
      project.finalize!
    end
  end
end

.from(repo, opts = {}, &blk) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/drydock/drydock.rb', line 48

def self.from(repo, opts = {}, &blk)
  opts = opts.clone
  tag  = opts.delete(:tag, 'latest')

  build(opts).tap do |project|
    project.from(repo, tag)
    yield project
  end
end

.loggerObject



58
59
60
# File 'lib/drydock/drydock.rb', line 58

def self.logger
  @logger ||= Logger.new(File.new('/dev/null', 'w+'))
end

.logger=(logger) ⇒ Object



62
63
64
# File 'lib/drydock/drydock.rb', line 62

def self.logger=(logger)
  @logger = logger
end

.versionObject



66
67
68
69
# File 'lib/drydock/drydock.rb', line 66

def self.version
  version_file = File.join(File.dirname(__FILE__), '..', '..', 'VERSION')
  File.exist?(version_file) ? File.read(version_file).chomp : ""
end