envirobly-orchestra 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a146603656b0f7d989daba62fac148bed321781ad26c5a822da7ec1b75bcc18
4
- data.tar.gz: 7c8d3a88177da3422c850bc371c821ced7704413bcfcc5d3b475d7c812939083
3
+ metadata.gz: 649c4efdb1b871fd9da2d82daee65246626bcade95f6ebe96660e8864c9a1fc3
4
+ data.tar.gz: 36d68bc5b20e51c7ef1f594fb3b0f31cfeb439b93bfc813bdbaa0af56a50ec3d
5
5
  SHA512:
6
- metadata.gz: cdfee431c6e723f79c5cfb647104f974cb12ca40b1975bfe1b1c1a43528cf51f84cf7dc110b1bd9549c520cd93f79210be674484787a5b9077bf9b21c407fb72
7
- data.tar.gz: d16acac39984a4d0d15dd2de18cf0460c7b1b4973449774a904c87ed521fa89062bd36995b276b532f20bed69148720ee7e95e03ce43d9380896dc09341b77d0
6
+ metadata.gz: a26add478d2971183ed4dcedc6cec9f8b23aae2cda5682c0fea41d9560a2f0bc2abdd8c1bf05cb56abc48fab65b942e7df220701469dc690a1701fca78ffb1b0
7
+ data.tar.gz: 646480972fe697e48b5eca15fed1100657a6799adfdcdb710d1675f4fb7f454d97f926ca5b81c76429ebb6efd797c6f0153fd10ae38ba5fb98057eefb204b5f6
@@ -28,14 +28,18 @@ class Orchestra::Base < Thor
28
28
  end
29
29
 
30
30
  def log(text)
31
- # Size-based rotated logging: 3 10-megabyte files.
32
- @logger ||= Logger.new("/var/log/orchestra.log", 3, 10485760)
31
+ @logger ||= Logger.new("/var/log/orchestra.log")
33
32
 
34
33
  @logger.info text
35
34
  end
36
35
 
37
- def execute(cmd, exit_on_failure: true)
38
- stdout_and_err, status = Open3.capture2e *cmd
36
+ def execute(cmd, exit_on_failure: true, escape_arguments: true)
37
+ stdout_and_err, status =
38
+ if escape_arguments
39
+ Open3.capture2e *cmd
40
+ else
41
+ Open3.capture2e cmd.join(" ")
42
+ end
39
43
 
40
44
  log stdout_and_err unless stdout_and_err.nil? || stdout_and_err.empty?
41
45
 
@@ -6,30 +6,27 @@ class Orchestra::Cli::Images < Orchestra::Base
6
6
  desc "build", "Build and push a Docker image"
7
7
  method_option :git_url, type: :string, required: true
8
8
  method_option :commit_id, type: :string, required: true
9
- method_option :cache_bucket, type: :string, required: true
10
- method_option :cache_region, type: :string, required: true
11
9
  method_option :image_uri, type: :string, required: true
12
10
  method_option :dockerfile, type: :string, required: true
13
11
  method_option :build_context, type: :string, required: true
14
12
  def build
15
- status = 1
16
-
17
- puts "Checking out commit #{options.commit_id}..."
13
+ log "Checking out commit #{options.commit_id}..."
18
14
 
19
15
  checkout_time = Benchmark.realtime do
20
- output, status =
21
- Open3.capture2e "envirobly-git-checkout-commit", git_checkout_path.to_s, options.git_url, options.commit_id
22
-
23
- puts output
16
+ execute git_checkout_cmd, escape_arguments: false
24
17
  end
25
18
 
26
- puts "Checkout finished in #{checkout_time.to_i}s\n"
19
+ log "Checkout finished in #{checkout_time.to_i}s\n"
27
20
 
28
- $stdout.flush
21
+ build_time = Benchmark.realtime do
22
+ execute buildx_build_cmd, escape_arguments: false
23
+ end
29
24
 
30
- exit 1 if status.to_i > 0
25
+ log "Build finished in #{build_time.to_i}s"
31
26
 
32
- exec *buildx_build_cmd
27
+ if FileUtils.rm_rf git_checkout_path
28
+ log "Removed #{git_checkout_path}"
29
+ end
33
30
  end
34
31
 
35
32
  private
@@ -37,16 +34,16 @@ class Orchestra::Cli::Images < Orchestra::Base
37
34
  [
38
35
  "docker", "buildx", "build",
39
36
  "--progress=plain",
40
- "--cache-from=type=s3,region=#{options.cache_region},bucket=#{options.cache_bucket},name=app",
41
- "--cache-to=type=s3,region=#{options.cache_region},bucket=#{options.cache_bucket},name=app,mode=max",
42
- "-t", options.image_uri, "--push",
37
+ "--push",
38
+ "-t", options.image_uri,
43
39
  "-f", dockerfile_path.to_s,
44
- build_context.to_s
40
+ build_context.to_s,
41
+ ">> /var/log/orchestra.log 2>&1"
45
42
  ]
46
43
  end
47
44
 
48
45
  def git_checkout_path
49
- Pathname.new "/tmp/build"
46
+ Pathname.new "/tmp/build-#{options.commit_id}"
50
47
  end
51
48
 
52
49
  def build_context
@@ -56,4 +53,14 @@ class Orchestra::Cli::Images < Orchestra::Base
56
53
  def dockerfile_path
57
54
  git_checkout_path.join options.dockerfile
58
55
  end
56
+
57
+ def git_checkout_cmd
58
+ [
59
+ "envirobly-git-checkout-commit",
60
+ git_checkout_path.to_s,
61
+ options.git_url,
62
+ options.commit_id,
63
+ "&> /dev/null"
64
+ ]
65
+ end
59
66
  end
@@ -1,6 +1,10 @@
1
1
  class Orchestra::Cli::Stack < Orchestra::Base
2
2
  desc "prune", "Stop inactive services and clean up their data volumes"
3
3
  def prune
4
+ # Get running containers:
5
+ # curl -s --unix-socket /var/run/docker.sock "http://localhost/v1.43/containers/json"
6
+
7
+ # Actual "prune":
4
8
  # docker compose up -d --quiet-pull --no-recreate --remove-orphans --no-start
5
9
  end
6
10
  end
@@ -1,3 +1,3 @@
1
1
  module Orchestra
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: envirobly-orchestra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Starsi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-22 00:00:00.000000000 Z
11
+ date: 2024-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor