Sha256: 11e55944e409de0c9d56428e7f96277a997947c93d71e6a1ec3c304c9b24037e

Contents?: true

Size: 1009 Bytes

Versions: 3

Compression:

Stored size: 1009 Bytes

Contents

# frozen_string_literal: true

module Command
  class BuildImage < Base
    NAME = "build-image"
    OPTIONS = [
      app_option(required: true),
      commit_option
    ].freeze
    DESCRIPTION = "Builds and pushes the image to Control Plane"
    LONG_DESCRIPTION = <<~DESC
      - Builds and pushes the image to Control Plane
      - Automatically assigns image numbers, e.g., `app:1`, `app:2`, etc.
      - Uses `.controlplane/Dockerfile`
    DESC

    def call
      ensure_docker_running!

      dockerfile = config.current[:dockerfile] || "Dockerfile"
      dockerfile = "#{config.app_cpln_dir}/#{dockerfile}"

      progress.puts("Building image from Dockerfile '#{dockerfile}'...\n\n")

      cp.image_build(latest_image_next, dockerfile: dockerfile)
    end

    private

    def ensure_docker_running!
      `docker version > /dev/null 2>&1`
      return if $CHILD_STATUS.success?

      raise "Can't run Docker. Please make sure that it's installed and started, then try again."
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cpl-0.6.0 lib/command/build_image.rb
cpl-0.5.1 lib/command/build_image.rb
cpl-0.5.0 lib/command/build_image.rb