Skip to content

Commit

Permalink
Add docker-context option
Browse files Browse the repository at this point in the history
  • Loading branch information
dzirtusss committed Dec 17, 2024
1 parent f8b544d commit 34010aa
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +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).

### 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

### Fixed
Expand Down
11 changes: 11 additions & 0 deletions lib/command/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions lib/command/build_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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}"

Expand Down
4 changes: 2 additions & 2 deletions lib/core/controlplane.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ 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}"
cmd += " --progress=plain" if ControlplaneApiDirect.trace

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
Expand Down

0 comments on commit 34010aa

Please sign in to comment.