capistrano-dockerbuild 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/capistrano-dockerbuild.gemspec +1 -1
- data/lib/capistrano/dockerbuild.rb +18 -0
- data/lib/capistrano/tasks/docker.rake +12 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1478c1f08638b7fbd90429775a474e501920403a455dc222b43bb7c031d2c873
|
4
|
+
data.tar.gz: 6d77122f43ed9fe79f9c672f4b2d209056c44396a4767efa24f0bd7886a94b45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db2802cde724287f42aadc207c9f195d6a14b9475196c49d3f8a476a6ef61babdf23b3013a1a5d18dfee0c3703beb7b8ace4d989c1af8bf977f4f178b4ed0fe4
|
7
|
+
data.tar.gz: 759048b911f58047325cd50aae2f84937cee18834b78cb8596a4e185d88e0e8a241eb3c82019cec2e18b64bbc6942d179564bd8514af987bf59d5e7425476560
|
data/README.md
CHANGED
@@ -50,7 +50,24 @@ Use common variables
|
|
50
50
|
| docker_remote_tag | no | `-> { fetch(:docker_tag) }` | Use by `docker push docker_registry/docker_remote_repository_name:{{docker_remote_tag}}` |
|
51
51
|
| docker_remote_tag_full | no | `-> { "#{fetch(:docker_registry) &.+ "/"}#{fetch(:docker_remote_repository_name)}:#{fetch(:docker_remote_tag)}" }` | Use by `docker push {{docker_remote_tag_full}}` |
|
52
52
|
| keep_docker_image_count | no | 10 | |
|
53
|
+
| git_http_username | no | nil | See below |
|
54
|
+
| git_http_password | no | nil | See below |
|
53
55
|
|
56
|
+
If you want to use GitHub Apps installation access token or something to authorize repository access using HTTPS protocol. You can set variables in your config/deploy.rb:
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
set :git_http_username, -> { ENV["GIT_HTTP_USERNAME"] }
|
60
|
+
set :git_http_password, -> { ENV["GIT_HTTP_PASSWORD"] }
|
61
|
+
set :repo_url, -> do
|
62
|
+
if fetch(:git_http_username) && fetch(:git_http_password)
|
63
|
+
"https://github.com/owner/repo.git"
|
64
|
+
else
|
65
|
+
"git@github.com:owner/repo.git"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
```
|
69
|
+
|
70
|
+
Update remote URL always if you set proper value to all of `repo_url`, `git_http_username`, and `git_http_password`.
|
54
71
|
|
55
72
|
## Tasks
|
56
73
|
|
@@ -1,3 +1,6 @@
|
|
1
|
+
require "cgi"
|
2
|
+
require "uri"
|
3
|
+
|
1
4
|
class Capistrano::Dockerbuild < Capistrano::Plugin
|
2
5
|
def set_defaults
|
3
6
|
set_if_empty :docker_build_cmd, -> { [:docker, "build", "-t", fetch(:docker_tag_full), "."] }
|
@@ -21,4 +24,19 @@ class Capistrano::Dockerbuild < Capistrano::Plugin
|
|
21
24
|
raise "Need to set :docker_build_base_dir" unless fetch(:docker_build_base_dir)
|
22
25
|
Pathname(fetch(:docker_build_base_dir))
|
23
26
|
end
|
27
|
+
|
28
|
+
def git_repo_url
|
29
|
+
if fetch(:git_http_username) && fetch(:git_http_password)
|
30
|
+
URI.parse(repo_url).tap do |repo_uri|
|
31
|
+
repo_uri.user = fetch(:git_http_username)
|
32
|
+
repo_uri.password = CGI.escape(fetch(:git_http_password))
|
33
|
+
end.to_s
|
34
|
+
elsif fetch(:git_http_username)
|
35
|
+
URI.parse(repo_url).tap do |repo_uri|
|
36
|
+
repo_uri.user = fetch(:git_http_username)
|
37
|
+
end.to_s
|
38
|
+
else
|
39
|
+
repo_url
|
40
|
+
end
|
41
|
+
end
|
24
42
|
end
|
@@ -5,7 +5,7 @@ namespace :docker do
|
|
5
5
|
task :check do
|
6
6
|
on fetch(:docker_build_server_host) do
|
7
7
|
execute :mkdir, "-p", dockerbuild_plugin.docker_build_base_path.dirname.to_s
|
8
|
-
execute :git, :'ls-remote',
|
8
|
+
execute :git, :'ls-remote', dockerbuild_plugin.git_repo_url, "HEAD"
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -17,7 +17,7 @@ namespace :docker do
|
|
17
17
|
info "The repository is at #{dockerbuild_plugin.docker_build_base_path}"
|
18
18
|
else
|
19
19
|
within dockerbuild_plugin.docker_build_base_path.dirname do
|
20
|
-
execute :git, :clone,
|
20
|
+
execute :git, :clone, dockerbuild_plugin.git_repo_url, dockerbuild_plugin.docker_build_base_path.to_s
|
21
21
|
end
|
22
22
|
end
|
23
23
|
else
|
@@ -25,7 +25,7 @@ namespace :docker do
|
|
25
25
|
info t(:mirror_exists, at: dockerbuild_plugin.docker_build_base_path.to_s)
|
26
26
|
else
|
27
27
|
within dockerbuild_plugin.docker_build_base_path.dirname do
|
28
|
-
execute :git, :clone, "--mirror",
|
28
|
+
execute :git, :clone, "--mirror", dockerbuild_plugin.git_repo_url, dockerbuild_plugin.docker_build_base_path.to_s
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -36,6 +36,7 @@ namespace :docker do
|
|
36
36
|
task update_mirror: :'docker:clone' do
|
37
37
|
on fetch(:docker_build_server_host) do
|
38
38
|
within dockerbuild_plugin.docker_build_base_path do
|
39
|
+
execute :git, :remote, "set-url", :origin, dockerbuild_plugin.git_repo_url
|
39
40
|
execute :git, :remote, :update, "--prune"
|
40
41
|
end
|
41
42
|
end
|
@@ -82,6 +83,14 @@ namespace :docker do
|
|
82
83
|
end
|
83
84
|
end
|
84
85
|
|
86
|
+
task :push_unless_exists => [:'docker:build'] do
|
87
|
+
on fetch(:docker_build_server_host) do
|
88
|
+
unless test "docker manifest inspect #{fetch(:docker_remote_tag_full)}"
|
89
|
+
invoke "docker:push"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
85
94
|
task :cleanup_local_images do
|
86
95
|
on fetch(:docker_build_server_host) do
|
87
96
|
local_images = []
|
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.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- joker1007
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
requirements: []
|
91
|
-
rubygems_version: 3.
|
91
|
+
rubygems_version: 3.5.11
|
92
92
|
signing_key:
|
93
93
|
specification_version: 4
|
94
94
|
summary: Capistrano task definition for `docker build`
|