From f4bee9cb048357f5c59ef89d27281906ee836af4 Mon Sep 17 00:00:00 2001 From: Sergey Tarasov Date: Tue, 17 Dec 2024 21:35:24 +0200 Subject: [PATCH 1/3] Add docker-context option (#250) --- CHANGELOG.md | 8 ++++++-- lib/command/base.rb | 11 +++++++++++ lib/command/build_image.rb | 8 ++++++-- lib/command/deploy_image.rb | 2 ++ lib/core/controlplane.rb | 4 ++-- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c3e190e..b7b10498 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,10 +17,14 @@ _Please add entries here for your pull requests that have not yet been released. ### Fixed - Fixed issue where `run` command fails when runner workload has ENV but original workload does not. [PR 227](https://github.com/shakacode/control-plane-flow/pull/227) by [Rafael Gomes](https://github.com/rafaelgomesxyz). - - Fixed potential infinite loop that could occur for a command if one of the execution steps fails and gets stuck. [PR 217](https://github.com/shakacode/control-plane-flow/pull/217) by [Zakir Dzhamaliddinov](https://github.com/zzaakiirr). - - Fixed issue where app cannot be deleted because one of the workloads has a volumeset in-use. [PR 245](https://github.com/shakacode/control-plane-flow/pull/245) by [Zakir Dzhamaliddinov](https://github.com/zzaakiirr). +- Fixed `resolv` may be not properly required [PR 250](https://github.com/shakacode/control-plane-flow/pull/250) by [Sergey Tarasov](https://github.com/dzirtusss). + +### Added + +- Added `--docker-context` option to `build-image` command. [PR 250](https://github.com/shakacode/control-plane-flow/pull/250) by [Sergey Tarasov](https://github.com/dzirtusss). + ## [4.0.0] - 2024-08-21 diff --git a/lib/command/base.rb b/lib/command/base.rb index dd05997b..74c69909 100644 --- a/lib/command/base.rb +++ b/lib/command/base.rb @@ -442,6 +442,17 @@ def self.add_app_identity_option(required: false) } } end + + def self.docker_context_option + { + name: :docker_context, + params: { + desc: "Path to the docker build context directory", + type: :string, + required: false + } + } + end # rubocop:enable Metrics/MethodLength def self.all_options diff --git a/lib/command/build_image.rb b/lib/command/build_image.rb index 6a75c509..6d56402a 100644 --- a/lib/command/build_image.rb +++ b/lib/command/build_image.rb @@ -5,7 +5,8 @@ class BuildImage < Base NAME = "build-image" OPTIONS = [ app_option(required: true), - commit_option + commit_option, + docker_context_option ].freeze ACCEPTS_EXTRA_OPTIONS = true DESCRIPTION = "Builds and pushes the image to Control Plane" @@ -34,9 +35,12 @@ def call # rubocop:disable Metrics/MethodLength build_args = [] build_args.push("GIT_COMMIT=#{commit}") if commit + docker_context = config.options[:docker_context] || config.app_dir + cp.image_build(image_url, dockerfile: dockerfile, docker_args: config.args, - build_args: build_args) + build_args: build_args, + docker_context: docker_context) push_path = "/org/#{config.org}/image/#{image_name}" diff --git a/lib/command/deploy_image.rb b/lib/command/deploy_image.rb index 485a48d8..cfde9050 100644 --- a/lib/command/deploy_image.rb +++ b/lib/command/deploy_image.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "resolv" + module Command class DeployImage < Base NAME = "deploy-image" diff --git a/lib/core/controlplane.rb b/lib/core/controlplane.rb index 601bd032..e1665a03 100644 --- a/lib/core/controlplane.rb +++ b/lib/core/controlplane.rb @@ -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: []) + def image_build(image, dockerfile:, docker_context:, 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}" @@ -98,7 +98,7 @@ def image_build(image, dockerfile:, docker_args: [], build_args: []) cmd += " #{docker_args.join(' ')}" if docker_args.any? build_args.each { |build_arg| cmd += " --build-arg #{build_arg}" } - cmd += " #{config.app_dir}" + cmd += " #{docker_context}" perform!(cmd) end From 95910ad611e555e5809f214634305d2c8e9af096 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Tue, 17 Dec 2024 09:44:52 -1000 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7b10498..428c8807 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ Changes since the last non-beta release. _Please add entries here for your pull requests that have not yet been released._ +## [4.1.0] - 2024-12-17 + ### Fixed - Fixed issue where `run` command fails when runner workload has ENV but original workload does not. [PR 227](https://github.com/shakacode/control-plane-flow/pull/227) by [Rafael Gomes](https://github.com/rafaelgomesxyz). @@ -274,7 +276,8 @@ Deprecated `cpl` gem. New gem is `cpflow`. First release. -[Unreleased]: https://github.com/shakacode/control-plane-flow/compare/v4.0.0...HEAD +[Unreleased]: https://github.com/shakacode/control-plane-flow/compare/v4.1.0...HEAD +[4.1.0]: https://github.com/shakacode/control-plane-flow/compare/v4.0.0...v4.1.0 [4.0.0]: https://github.com/shakacode/control-plane-flow/compare/v3.0.1...v4.0.0 [3.0.1]: https://github.com/shakacode/control-plane-flow/compare/v3.0.0...v3.0.1 [3.0.0]: https://github.com/shakacode/control-plane-flow/compare/v2.2.4...v3.0.0 From 44de9a717344c8feff800707c89c6a637118112f Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Tue, 17 Dec 2024 09:46:37 -1000 Subject: [PATCH 3/3] Bump version to 4.1.0 --- Gemfile.lock | 2 +- lib/cpflow/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 78bec0b6..1fdcdd83 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - cpflow (4.0.1) + cpflow (4.1.0) dotenv (~> 2.8.1) jwt (~> 2.8.1) psych (~> 5.1.0) diff --git a/lib/cpflow/version.rb b/lib/cpflow/version.rb index b42c4a5e..d224a513 100644 --- a/lib/cpflow/version.rb +++ b/lib/cpflow/version.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true module Cpflow - VERSION = "4.0.1" + VERSION = "4.1.0" MIN_CPLN_VERSION = "3.1.0" end