Class: DG::Docker
- Inherits:
-
Object
- Object
- DG::Docker
- Defined in:
- lib/dg/docker.rb
Constant Summary collapse
- SUDO =
!!ENV['USE_SUDO']
- BASEPATH =
Dir.pwd
- FIG_YML_PATH =
"#{BASEPATH}/fig.yml"
- FIG_GEN_PATH =
"#{BASEPATH}/fig_gen.yml"
- CACHE_FILES =
%w( bower.json Gemfile Gemfile.lock package.json )
Class Method Summary collapse
- .build ⇒ Object
- .debug ⇒ Object
- .deploy ⇒ Object
- .deploy_check ⇒ Object
- .deploy_stages ⇒ Object
- .purge ⇒ Object
- .push ⇒ Object
- .run ⇒ Object
- .test ⇒ Object
- .version ⇒ Object (also: v)
Class Method Details
.build ⇒ Object
24 25 26 27 |
# File 'lib/dg/docker.rb', line 24 def build reset_mtimes build_docker_image_with_tag end |
.debug ⇒ Object
29 30 31 32 |
# File 'lib/dg/docker.rb', line 29 def debug generate_fig_yaml debug_app end |
.deploy ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/dg/docker.rb', line 59 def deploy required_envs = %w(GO_HOST GO_USER GO_PWD) unless required_envs.reduce{ |acc, e| acc && ENV[e] } error!( RuntimeError.new("Environment variables {#{required_envs.join(', ')}} must be set"), 'triggering pipeline' ) end puts "Triggering deploys for: #{deploy_stages.inspect}" deploy_stages.each do |deploy_stage| schedule_pipeline(project_name, deploy_stage, git_image_name) end end |
.deploy_check ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/dg/docker.rb', line 43 def deploy_check required_envs = %w(GO_HOST GO_USER GO_PWD) unless required_envs.reduce{ |acc, e| acc && ENV[e] } error!( RuntimeError.new("Environment variables {#{required_envs.join(', ')}} must be set"), 'checking if pipeline exists' ) end puts "Checking existance of pipeline docker-#{project_name}-{#{deploy_stages.join('|')}}" deploy_stages.each do |deploy_stage| pipeline_check(project_name, deploy_stage) end end |
.deploy_stages ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/dg/docker.rb', line 75 def deploy_stages @@deploy_stages_cached ||= begin generate_fig_yaml branch = ENV['GIT_BRANCH'] || `git symbolic-ref --short -q HEAD`.strip run_with_output( %(docker run --entrypoint=ruby -e GIT_BRANCH=#{branch} #{git_image_name} /u/app/deploy-to.rb), capture = true ).strip.split(',') end end |
.purge ⇒ Object
34 35 36 |
# File 'lib/dg/docker.rb', line 34 def purge run_with_output("docker rm $(docker ps -a -q) && docker rmi $(docker images -q)") end |
.push ⇒ Object
38 39 40 41 |
# File 'lib/dg/docker.rb', line 38 def push run_with_output("docker push #{git_image_name}") run_with_output("docker push #{latest_image_name}") end |
.run ⇒ Object
88 89 90 91 |
# File 'lib/dg/docker.rb', line 88 def run generate_fig_yaml run_app end |
.test ⇒ Object
93 94 95 96 |
# File 'lib/dg/docker.rb', line 93 def test generate_fig_yaml run_tests end |