capistrano-dockerbuild 0.1.0 → 0.2.0

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
- SHA1:
3
- metadata.gz: 20a884c1147fd81d4f831378fd286fedf5498d4a
4
- data.tar.gz: 227ca91c65a6227320fb8b275befc12cca072ba1
2
+ SHA256:
3
+ metadata.gz: 5c76b5158e48a01111cf0484a73d6a29bb0a5fbf739e6436fc07953597368f4a
4
+ data.tar.gz: 8d3f8902a8b6c0d236d2b3b2ecf6739ed47eaed40e82419f229bc0dd3215aaac
5
5
  SHA512:
6
- metadata.gz: a3ee23aff127683494ba9ddd071492e4d197b3a21e9ff400924e99017d9f2d82379beeba57802e2071c95048b5d56d508e7ee08e243f66f7a881576dc699cb1a
7
- data.tar.gz: 273a531f78913872dd10e2ebf288f16978e3dde3bbbaba9e273c4dccf22aadaa2ead72599329badc3b7aefd7a45c1090ae6d7fccd77bb47be0b79c36dbde354c
6
+ metadata.gz: b1bc3546464847bfcacff5899ea1a06764eccec638a28e897958b270fb8d4dce3020743fc3f59f5085bc765501b1d5a4514f28b668429a1eee3490720ce819df
7
+ data.tar.gz: 545b691af1175f8775765cd478e5f0100aa472e5b4235a57de9c5c7018365fbb584b0d2b347f2ec6a7cfc432e4b0394afb4d33ebfae4e295760253e55c86375c
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "capistrano-dockerbuild"
7
- spec.version = "0.1.0"
7
+ spec.version = "0.2.0"
8
8
  spec.authors = ["joker1007"]
9
9
  spec.email = ["kakyoin.hierophant@gmail.com"]
10
10
 
@@ -22,6 +22,6 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_runtime_dependency "capistrano", ">= 3.2"
24
24
 
25
- spec.add_development_dependency "bundler", "~> 1.15"
26
- spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "bundler", "~> 2.3"
26
+ spec.add_development_dependency "rake", "~> 13.0"
27
27
  end
@@ -7,7 +7,10 @@ class Capistrano::Dockerbuild < Capistrano::Plugin
7
7
  set_if_empty :docker_remote_repository_name, -> { fetch(:docker_repository_name) }
8
8
  set_if_empty :docker_remote_tag, -> { fetch(:docker_tag) }
9
9
  set_if_empty :docker_remote_tag_full, -> { "#{fetch(:docker_registry) &.+ "/"}#{fetch(:docker_remote_repository_name)}:#{fetch(:docker_remote_tag)}" }
10
+ set_if_empty :docker_latest_tag, false
10
11
  set_if_empty :keep_docker_image_count, 10
12
+ set_if_empty :git_gc_prune_date, "3.days.ago"
13
+ set_if_empty :docker_build_no_worktree, false
11
14
  end
12
15
 
13
16
  def define_tasks
@@ -12,11 +12,21 @@ namespace :docker do
12
12
  desc "Clone the repo to docker build base directory"
13
13
  task :clone => [:'docker:check'] do
14
14
  on fetch(:docker_build_server_host) do
15
- if test " [ -f #{dockerbuild_plugin.docker_build_base_path}/HEAD ] "
16
- info t(:mirror_exists, at: dockerbuild_plugin.docker_build_base_path.to_s)
15
+ if fetch(:docker_build_no_worktree)
16
+ if test " [ -f #{dockerbuild_plugin.docker_build_base_path}/.git/HEAD ] "
17
+ info "The repository is at #{dockerbuild_plugin.docker_build_base_path}"
18
+ else
19
+ within dockerbuild_plugin.docker_build_base_path.dirname do
20
+ execute :git, :clone, repo_url, dockerbuild_plugin.docker_build_base_path.to_s
21
+ end
22
+ end
17
23
  else
18
- within dockerbuild_plugin.docker_build_base_path.dirname do
19
- execute :git, :clone, "--mirror", repo_url, dockerbuild_plugin.docker_build_base_path.to_s
24
+ if test " [ -f #{dockerbuild_plugin.docker_build_base_path}/HEAD ] "
25
+ info t(:mirror_exists, at: dockerbuild_plugin.docker_build_base_path.to_s)
26
+ else
27
+ within dockerbuild_plugin.docker_build_base_path.dirname do
28
+ execute :git, :clone, "--mirror", repo_url, dockerbuild_plugin.docker_build_base_path.to_s
29
+ end
20
30
  end
21
31
  end
22
32
  end
@@ -35,20 +45,26 @@ namespace :docker do
35
45
  task :build => [:'docker:update_mirror'] do
36
46
  on fetch(:docker_build_server_host) do
37
47
  within dockerbuild_plugin.docker_build_base_path do
38
- timestamp = Time.now.to_i
39
- worktree_dir_name = "worktree-#{fetch(:docker_tag)}-#{timestamp}"
48
+ if fetch(:docker_build_no_worktree)
49
+ commands = "sha1=$(git rev-parse #{fetch(:branch)}); git reset --hard ${sha1}; #{fetch(:docker_build_cmd).map {|c| c.to_s.shellescape }.join(" ")}"
50
+ execute(:flock, "capistrano_dockerbuild.lock", "-c", "'#{commands}'")
51
+ else
52
+ timestamp = Time.now.to_i
53
+ git_sha1 = `git rev-parse #{fetch(:branch)}`.chomp
54
+ worktree_dir_name = "worktree-#{git_sha1}-#{timestamp}"
40
55
 
41
- execute(:git, :worktree, :add, worktree_dir_name, fetch(:branch))
56
+ execute(:git, :worktree, :add, worktree_dir_name, git_sha1)
42
57
 
43
- begin
44
- within worktree_dir_name do
45
- execute(*fetch(:docker_build_cmd))
58
+ begin
59
+ within worktree_dir_name do
60
+ execute(*fetch(:docker_build_cmd))
61
+ end
62
+ ensure
63
+ execute(:rm, "-rf", worktree_dir_name)
64
+ execute(:git, :worktree, :prune)
65
+ # Execute "git gc" manually to avoid "There are too many unreachable loose objects" warning
66
+ execute(:git, :gc, "--auto", "--prune=#{fetch(:git_gc_prune_date)}")
46
67
  end
47
- ensure
48
- execute(:rm, "-rf", worktree_dir_name)
49
- execute(:git, :worktree, :prune)
50
- # Execute "git gc" manually to avoid "There are too many unreachable loose objects" warning
51
- execute(:git, :gc, "--auto", "--prune=3.days.ago")
52
68
  end
53
69
  end
54
70
  end
@@ -58,6 +74,11 @@ namespace :docker do
58
74
  on fetch(:docker_build_server_host) do
59
75
  execute(:docker, :tag, fetch(:docker_tag_full), fetch(:docker_remote_tag_full))
60
76
  execute(:docker, :push, fetch(:docker_remote_tag_full))
77
+ if fetch(:docker_latest_tag)
78
+ latest_tag = "#{fetch(:docker_registry) &.+ "/"}#{fetch(:docker_remote_repository_name)}:latest"
79
+ execute(:docker, :tag, fetch(:docker_tag_full), latest_tag)
80
+ execute(:docker, :push, latest_tag)
81
+ end
61
82
  end
62
83
  end
63
84
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-dockerbuild
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - joker1007
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-29 00:00:00.000000000 Z
11
+ date: 2022-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.15'
33
+ version: '2.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.15'
40
+ version: '2.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '13.0'
55
55
  description: Capistrano task definition for `docker build`
56
56
  email:
57
57
  - kakyoin.hierophant@gmail.com
@@ -73,7 +73,7 @@ homepage: https://github.com/reproio/capistrano-dockerbuild
73
73
  licenses:
74
74
  - MIT
75
75
  metadata: {}
76
- post_install_message:
76
+ post_install_message:
77
77
  rdoc_options: []
78
78
  require_paths:
79
79
  - lib
@@ -88,9 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  requirements: []
91
- rubyforge_project:
92
- rubygems_version: 2.6.12
93
- signing_key:
91
+ rubygems_version: 3.3.7
92
+ signing_key:
94
93
  specification_version: 4
95
94
  summary: Capistrano task definition for `docker build`
96
95
  test_files: []