Class: Docker
- Inherits:
-
Object
- Object
- Docker
- Defined in:
- lib/docker.rb
Constant Summary collapse
- MATERIAL_NAME =
ENV['MATERIAL_NAME'] || 'BITBUCKET'
- SUDO =
!!ENV["GO_REVISION_#{MATERIAL_NAME}"]
- BASEPATH =
Dir.pwd
- GIT_COMMIT =
ENV['GO_REVISION_BITBUCKET'] || `git rev-parse HEAD`.strip
- FIG_YML_PATH =
"#{BASEPATH}/fig.yml"- FIG_GEN_PATH =
"#{BASEPATH}/fig_gen.yml"
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
16 17 18 |
# File 'lib/docker.rb', line 16 def build build_docker_image_with_tag end |
.debug ⇒ Object
20 21 22 23 |
# File 'lib/docker.rb', line 20 def debug generate_fig_yaml debug_app end |
.deploy ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/docker.rb', line 33 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 deploy_stages.each do |deploy_stage| schedule_pipeline(project_name, deploy_stage, git_image_name) end end |
.deploy_stages ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/docker.rb', line 46 def deploy_stages candidates = Dir['deploy-to*'] if candidates.size == 1 script = candidates.first if File.executable?(script) branch = ENV['GIT_BRANCH'] || `git symbolic-ref --short -q HEAD`.strip return `./#{script} #{branch}`.strip.split(',') else error!( RuntimeError.new( %(Deploy-to script: "#{script}" must be executable! (e.g. chmod +x #{script})) ), "determining stage to deploy to" ) end else error!( RuntimeError.new( "There must be a deploy-to* script " + "(e.g. deploy-to.{rb|sh|js}): #{candidates.size} found" ), "determining stage to deploy to" ) end end |
.purge ⇒ Object
25 26 27 |
# File 'lib/docker.rb', line 25 def purge run_with_output("docker rm $(docker ps -a -q) && docker rmi $(docker images -q)") end |
.push ⇒ Object
29 30 31 |
# File 'lib/docker.rb', line 29 def push run_with_output("docker push #{git_image_name.tr(':',' ')}") end |
.run ⇒ Object
73 74 75 76 |
# File 'lib/docker.rb', line 73 def run generate_fig_yaml run_app end |
.test ⇒ Object
78 79 80 81 |
# File 'lib/docker.rb', line 78 def test generate_fig_yaml run_tests end |
.version ⇒ Object Also known as: v
83 84 85 |
# File 'lib/docker.rb', line 83 def version puts "v#{VERSION}" end |