Class: Command::BuildImage
Constant Summary collapse
- NAME =
"build-image"
- OPTIONS =
[ app_option(required: true), commit_option ].freeze
- ACCEPTS_EXTRA_OPTIONS =
true
- 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` or a different Dockerfile specified through `dockerfile` in the `.controlplane/controlplane.yml` file - If a commit is provided through `--commit` or `-c`, it will be set as the runtime env var `GIT_COMMIT` - Accepts extra options that are passed to `docker build` DESC
Constants inherited from Base
Command::Base::DEFAULT_ARGS, Command::Base::EXAMPLES, Command::Base::HIDE, Command::Base::NO_IMAGE_AVAILABLE, Command::Base::REQUIRES_ARGS, Command::Base::USAGE, Command::Base::WITH_INFO_HEADER
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#call ⇒ Object
rubocop:disable Metrics/MethodLength.
Methods inherited from Base
all_commands, all_options, all_options_by_key_name, #app_identity, #app_identity_link, #app_image_link, #app_location_link, app_option, #app_secrets, #app_secrets_policy, #args_join, clean_on_failure_option, commit_option, common_options, #cp, domain_option, #ensure_workload_deleted, #extract_image_commit, image_option, #initialize, #latest_image, #latest_image_from, #latest_image_next, location_option, org_option, #perform!, #progress, run_release_phase_option, skip_confirm_option, skip_secret_access_binding_option, #step, #step_error, #step_finish, terminal_size_option, trace_option, upstream_token_option, use_local_token_option, verbose_option, version_option, #wait_for_replica, #wait_for_workload, wait_option, workload_option
Methods included from Helpers
#random_four_digits, #strip_str_and_validate
Constructor Details
This class inherits a constructor from Command::Base
Instance Method Details
#call ⇒ Object
rubocop:disable Metrics/MethodLength
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/command/build_image.rb', line 20 def call # rubocop:disable Metrics/MethodLength ensure_docker_running! dockerfile = config.current[:dockerfile] || "Dockerfile" dockerfile = "#{config.app_cpln_dir}/#{dockerfile}" raise "Can't find Dockerfile at '#{dockerfile}'." unless File.exist?(dockerfile) progress.puts("Building image from Dockerfile '#{dockerfile}'...\n\n") image_name = latest_image_next image_url = "#{config.org}.registry.cpln.io/#{image_name}" commit = config.[:commit] build_args = [] build_args.push("GIT_COMMIT=#{commit}") if commit cp.image_build(image_url, dockerfile: dockerfile, docker_args: config.args, build_args: build_args) progress.puts("\nPushed image to '/org/#{config.org}/image/#{image_name}'.") end |