Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate docker build & docker push steps #211

Merged
merged 2 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading