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_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
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/dg/docker.rb', line 43 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_stages ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/dg/docker.rb', line 59 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=$GIT_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
72 73 74 75 |
# File 'lib/dg/docker.rb', line 72 def run generate_fig_yaml run_app end |
.test ⇒ Object
77 78 79 80 |
# File 'lib/dg/docker.rb', line 77 def test generate_fig_yaml run_tests end |
.version ⇒ Object Also known as: v
82 83 84 |
# File 'lib/dg/docker.rb', line 82 def version puts "v#{DG::VERSION}" end |