Class: Capistrano::Dockerbuild
- Inherits:
-
Plugin
- Object
- Plugin
- Capistrano::Dockerbuild
- Defined in:
- lib/capistrano/dockerbuild.rb
Instance Method Summary collapse
- #define_tasks ⇒ Object
- #docker_build_base_path ⇒ Object
- #git_env(host) ⇒ Object
- #git_repo_host ⇒ Object
- #git_repo_url ⇒ Object
- #set_defaults ⇒ Object
- #tmp_home(host) ⇒ Object
Instance Method Details
#define_tasks ⇒ Object
22 23 24 |
# File 'lib/capistrano/dockerbuild.rb', line 22 def define_tasks eval_rakefile File.("../tasks/docker.rake", __FILE__) end |
#docker_build_base_path ⇒ Object
26 27 28 29 |
# File 'lib/capistrano/dockerbuild.rb', line 26 def docker_build_base_path raise "Need to set :docker_build_base_dir" unless fetch(:docker_build_base_dir) Pathname(fetch(:docker_build_base_dir)) end |
#git_env(host) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/capistrano/dockerbuild.rb', line 55 def git_env(host) return {} if fetch(:git_auth_token).to_s.empty? @git_env ||= {} @git_env[host.properties.arch] ||= { HOME: tmp_home(host), GIT_CONFIG_NOSYSTEM: "1" } end |
#git_repo_host ⇒ Object
46 47 48 |
# File 'lib/capistrano/dockerbuild.rb', line 46 def git_repo_host URI.parse(repo_url.sub(/^git@.*/) {|m| "https://#{m}" }).host end |
#git_repo_url ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/capistrano/dockerbuild.rb', line 31 def git_repo_url if fetch(:git_http_username) && fetch(:git_http_password) URI.parse(repo_url).tap do |repo_uri| repo_uri.user = fetch(:git_http_username) repo_uri.password = CGI.escape(fetch(:git_http_password)) end.to_s elsif fetch(:git_http_username) URI.parse(repo_url).tap do |repo_uri| repo_uri.user = fetch(:git_http_username) end.to_s else repo_url end end |
#set_defaults ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/capistrano/dockerbuild.rb', line 6 def set_defaults set_if_empty :docker_tag, -> { fetch(:application) + ":" + fetch(:branch) } set :docker_tag_with_arch, ->(host) do arch_suffix = host.properties.arch ? "-#{host.properties.arch}" : "" fetch(:docker_tag) + arch_suffix end set_if_empty :docker_build_cmd, ->(host) do [:docker, :build, "-t", fetch(:docker_tag_with_arch).call(host), "."] end set_if_empty :docker_latest_tag, false set_if_empty :keep_docker_image_count, 10 set_if_empty :git_gc_prune_date, "3.days.ago" set_if_empty :docker_build_no_worktree, false set_if_empty :update_git_submodule, false end |
#tmp_home(host) ⇒ Object
50 51 52 53 |
# File 'lib/capistrano/dockerbuild.rb', line 50 def tmp_home(host) @tmp_host ||= {} @tmp_host[host.properties.arch] ||= "/tmp/capistrano-dockerbuild-#{SecureRandom.hex(8)}" end |