Sha256: 2f746075e7ce91a0f0a12cbac5ac2355841b0132aeef67eb2ab44ed987988657

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

module Percheron
  module Actions
    class Build

      include Base

      def initialize(container, nocache: false)
        @container = container
        @nocache = nocache
      end

      def execute!
        build!
        container
      end

      private

        attr_reader :container, :nocache

        def build_opts
          {
            'dockerfile'  => container.dockerfile.basename.to_s,
            't'           => container.image_name,
            'forcerm'     => true,
            'nocache'     => nocache
          }
        end

        def build!
          in_working_directory(base_dir) do
            execute_pre_build_scripts!  unless container.pre_build_scripts.empty?
            $logger.info "Building '#{container.image_name}'"
            Docker::Image.build_from_dir(base_dir, build_opts) do |out|
              $logger.debug '%s' % [ out.strip ]
            end
          end
        end

        def execute_pre_build_scripts!
          ExecLocal.new(container, container.pre_build_scripts, 'PRE build').execute!
        end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
percheron-0.6.3 lib/percheron/actions/build.rb
percheron-0.6.2 lib/percheron/actions/build.rb