capistrano-nomad 0.8.2 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0748cefe640533eb1e27bf32b49f399a59f481d9d6fc3a5526f32371bdaa49d
4
- data.tar.gz: 2a440dc3cba7df056faba0aedc71ec9d3d5e089189697eb4d75a91a0636cc2e6
3
+ metadata.gz: d72090f2b054d4e263ca57df89aa4d5ae5c85dccfc9200313520cec17eeaef57
4
+ data.tar.gz: 854f1b1cde505d12cdd12f9acb2c31da2b9d60b24121a3e85d7277dd81bdc397
5
5
  SHA512:
6
- metadata.gz: 1741648c6769f84e8ed3f2c5ad3f14a4ea742bc07be4b27f3fdc3b68af684a9b9c7a7346cf060f477ca576a7fc6ce1e775e8d1cf9f6dfdb173c5ed9c8047671b
7
- data.tar.gz: 6ddb34c43f24c92b86f1fb9055c15e45ad851ebad706a750187c09f1f454f8d5102ee82bbddf66857d201ccc91657e043f34cf24e0f1a407ccb406b42f629bca
6
+ metadata.gz: d9d109aea1b53f1f383f40ed95136d56857f61ad4fe3c15097e7c40d6babb07e2c8d2bb76a7971f4a0ae0293738ab33f4b55b72b5fda85a174bff341a26ac1fc
7
+ data.tar.gz: 9c3671c5c5b4cfe2c29d81ba4b5b7ec7a96fd50648f062ad03aa8547214d3e69a7fe8ec0d641679e49d99e130e8587e78a1d8d7c5759c9118da1bccd02d65aec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capistrano-nomad (0.8.2)
4
+ capistrano-nomad (0.8.4)
5
5
  activesupport (<= 7.0.8)
6
6
  byebug
7
7
  capistrano (~> 3.0)
data/README.md CHANGED
@@ -49,6 +49,19 @@ set :nomad_template_vars, (lambda do
49
49
  }
50
50
  end)
51
51
 
52
+ # Change docker build command
53
+ set :nomad_docker_build_command, (lambda do
54
+ "docker buildx build"
55
+ end)
56
+
57
+ # Pass additional options into `docker build`
58
+ set :nomad_docker_build_command_options, (lambda do
59
+ [
60
+ "--cache-to type=gha",
61
+ "--cache-from type=gha",
62
+ ]
63
+ end)
64
+
52
65
  # Make helpers available to all template .erb files
53
66
  nomad_template_helpers do
54
67
  def restart_stanza(interval = "1m")
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "capistrano-nomad"
5
- spec.version = "0.8.2"
5
+ spec.version = "0.8.4"
6
6
  spec.authors = ["James Hu"]
7
7
 
8
8
  spec.summary = "Capistrano plugin for deploying and managing Nomad jobs"
@@ -67,39 +67,42 @@ end
67
67
  def capistrano_nomad_build_docker_image_for_type(image_type)
68
68
  image_type = image_type.to_sym
69
69
  attributes = fetch(:nomad_docker_image_types)[image_type]
70
+ command = fetch(:nomad_docker_build_command) || "docker build"
71
+ options = Array(fetch(:nomad_docker_build_command_options)) || []
70
72
 
71
73
  return unless attributes
72
74
 
73
75
  # No need to build if there's no path
74
76
  return unless attributes[:path]
75
77
 
76
- args = [
77
- # Ensure images are built for x86_64 which is production env otherwise it will default to local development env
78
- # which can be arm64 (Apple Silicon)
79
- "--platform linux/amd64",
80
- ]
78
+ # Ensure images are built for x86_64 which is production env otherwise it will default to local development env which
79
+ # can be arm64 (Apple Silicon)
80
+ options << "--platform linux/amd64"
81
81
 
82
82
  if (target = attributes[:target])
83
- args << "--target #{target}"
83
+ options << "--target #{target}"
84
84
  end
85
85
 
86
86
  build_args = attributes[:build_args]
87
87
  build_args = build_args.call if build_args&.is_a?(Proc)
88
88
 
89
89
  (build_args || []).each do |key, value|
90
- args << "--build-arg #{key}=#{value}"
90
+ # Escape single quotes so that we can properly pass in build arg values that have spaces and special characters
91
+ # e.g. Don't escape strings (#123) => $'Don\'t escape strings (#123)'
92
+ value_escaped = value.gsub("'", "\\\\'")
93
+ options << "--build-arg #{key}=$'#{value_escaped}'"
91
94
  end
92
95
 
93
96
  docker_build_command = lambda do |path|
94
- image_alias_args = args.dup
97
+ build_options = options.dup
95
98
 
96
99
  [capistrano_nomad_build_docker_image_alias(image_type)]
97
100
  .compact
98
101
  .each do |tag|
99
- image_alias_args << "--tag #{tag}"
102
+ build_options << "--tag #{tag}"
100
103
  end
101
104
 
102
- "docker build #{image_alias_args.join(' ')} #{path}"
105
+ "#{command} #{build_options.join(' ')} #{path}"
103
106
  end
104
107
 
105
108
  case attributes[:strategy]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-nomad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Hu
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-22 00:00:00.000000000 Z
11
+ date: 2024-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport