Skip to content

Commit

Permalink
Separate docker build & docker push steps (#211)
Browse files Browse the repository at this point in the history
* Separete docker build & docker push steps

* Remove :push kwarg from Controlplane#image_build
  • Loading branch information
zzaakiirr authored Jul 19, 2024
1 parent c595899 commit ed1bcad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/command/build_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ def call # rubocop:disable Metrics/MethodLength
docker_args: config.args,
build_args: build_args)

progress.puts("\nPushed image to '/org/#{config.org}/image/#{image_name}'.\n\n")
push_path = "/org/#{config.org}/image/#{image_name}"

progress.puts("\nPushing image to '#{push_path}'...\n\n")
cp.image_push(image_url)
progress.puts("\nPushed image to '#{push_path}'.\n\n")

step("Waiting for image to be available", retry_on_failure: true) do
images = cp.query_images["items"]
Expand Down
5 changes: 2 additions & 3 deletions lib/core/controlplane.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def query_images(a_gvc = gvc, a_org = org, partial_gvc_match: nil)
api.query_images(org: a_org, gvc: a_gvc, gvc_op_type: gvc_op)
end

def image_build(image, dockerfile:, docker_args: [], build_args: [], push: true)
def image_build(image, dockerfile:, docker_args: [], build_args: [])
# https://docs.controlplane.com/guides/push-image#step-2
# Might need to use `docker buildx build` if compatiblitity issues arise
cmd = "docker build --platform=linux/amd64 -t #{image} -f #{dockerfile}"
Expand All @@ -99,9 +99,8 @@ def image_build(image, dockerfile:, docker_args: [], build_args: [], push: true)
cmd += " #{docker_args.join(' ')}" if docker_args.any?
build_args.each { |build_arg| cmd += " --build-arg #{build_arg}" }
cmd += " #{config.app_dir}"
perform!(cmd)

image_push(image) if push
perform!(cmd)
end

def fetch_image_details(image)
Expand Down

0 comments on commit ed1bcad

Please sign in to comment.