capistrano-dockerbuild 0.2.0 → 0.2.1
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 +4 -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: 7580dbb05690bf6529b2fa5c84cf8c31c8d38b3335858af7aa3afdfcda8a8d7d
|
4
|
+
data.tar.gz: 691b01a48a7ff2aca50ca20ddcfd93275bc5b77ce27f43e7843564fbeac61d83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5a7110eb23e53fd10aa05df4520690637e41a08847b788dd510f7b6ec5b8f48a2ff8919431873ce3e0f15b68ad5e07d0296aff8d4f13503bfacb38946eb0751
|
7
|
+
data.tar.gz: a94036ec200c90d80fe321cbb1519e52c933a09d2db08a292d4375b96fd32a072e4c622af238faa85b2d39aa0a6c85255c5be52ea65f69a1abc38fbcb46183f6
|
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
|
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.1
|
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-05-22 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.9
|
92
92
|
signing_key:
|
93
93
|
specification_version: 4
|
94
94
|
summary: Capistrano task definition for `docker build`
|