Sha256: e1e234589278280ddefd714db309a3b9b1490f9d64df0db032db307bf91fb6ab

Contents?: true

Size: 1.13 KB

Versions: 6

Compression:

Stored size: 1.13 KB

Contents

require 'shipitron'

module Shipitron
  module Server
    module Docker
      class RunBuildScript
        include Metaractor

        required :application
        required :docker_image
        required :git_sha
        optional :build_script

        before do
          context.build_script ||= 'shipitron/build.sh'
        end

        def call
          Logger.info 'Building docker image'

          docker_image.tag = git_sha

          FileUtils.cd("/home/shipitron/#{application}") do
            unless Pathname.new(build_script).exist?
              fail_with_error!(message: "#{build_script} does not exist")
            end
            Logger.info `#{build_script} #{docker_image}`
            if $? != 0
              fail_with_error!(message: "build script exited with non-zero code: #{$?}")
            end
          end
        end

        private
        def application
          context.application
        end

        def docker_image
          context.docker_image
        end

        def git_sha
          context.git_sha
        end

        def build_script
          context.build_script
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
shipitron-0.3.3 lib/shipitron/server/docker/run_build_script.rb
shipitron-0.3.1 lib/shipitron/server/docker/run_build_script.rb
shipitron-0.3.0 lib/shipitron/server/docker/run_build_script.rb
shipitron-0.2.2 lib/shipitron/server/docker/run_build_script.rb
shipitron-0.2.1 lib/shipitron/server/docker/run_build_script.rb
shipitron-0.2.0 lib/shipitron/server/docker/run_build_script.rb