Sha256: 1c2b59c2e2cf97d63435073fc8e56c23b2f03ae1e249ae70a27c1518c6af1cd0

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

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 = <<~HEREDOC
      - Builds and pushes the image to Control Plane
      - Automatically assigns image numbers, e.g., `app:1`, `app:2`, etc.
      - Uses `.controlplane/Dockerfile`
    HEREDOC

    def call
      ensure_docker_running!

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

      cp.image_build(latest_image_next, dockerfile: dockerfile)
    end

    private

    def ensure_docker_running!
      `docker version > /dev/null 2>&1`
      return if $?.success? # rubocop:disable Style/SpecialGlobalVars

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cpl-0.4.1 lib/command/build_image.rb
cpl-0.4.0 lib/command/build_image.rb