Module: Shipwright::ElasticBeanstalk
- Extended by:
- ElasticBeanstalk
- Included in:
- ElasticBeanstalk
- Defined in:
- lib/shipwright/elastic_beanstalk.rb
Constant Summary collapse
- EB_CONFIG =
".elasticbeanstalk/config.yml"- EB_EXTENSIONS =
'.ebextensions'- DOCKERRUN =
'Dockerrun.aws.json'
Instance Method Summary collapse
- #application ⇒ Object
- #artifact_path ⇒ Object
- #generate_artifact ⇒ Object
- #update_dockerrun ⇒ Object
- #update_ebconfig ⇒ Object
- #version ⇒ Object
Instance Method Details
#application ⇒ Object
56 57 58 |
# File 'lib/shipwright/elastic_beanstalk.rb', line 56 def application Builder.application end |
#artifact_path ⇒ Object
48 49 50 |
# File 'lib/shipwright/elastic_beanstalk.rb', line 48 def artifact_path File.join Dir.pwd, 'builds', "#{application}-#{version}.zip" end |
#generate_artifact ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/shipwright/elastic_beanstalk.rb', line 27 def generate_artifact FileUtils.mkdir_p File.dirname(artifact_path) FileUtils.rm artifact_path, force: true Zip::File.open(artifact_path, Zip::File::CREATE) do |zip| zip.add DOCKERRUN, DOCKERRUN ebexts = Dir.glob(File.join EB_EXTENSIONS, '*') if ebexts.any? zip.mkdir EB_EXTENSIONS ebexts.each { |ext| zip.add ext, ext } end end end |
#update_dockerrun ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/shipwright/elastic_beanstalk.rb', line 15 def update_dockerrun dockerrun = JSON.parse(File.read DOCKERRUN) dockerrun['containerDefinitions'].each do |container| bits = container['image'].to_s.split(':').tap(&:pop) container['image'] = bits.push(version).join(':') end File.open(DOCKERRUN, 'wb') { |file| file.write JSON.pretty_generate(dockerrun) } end |
#update_ebconfig ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/shipwright/elastic_beanstalk.rb', line 40 def update_ebconfig config = YAML.load_file EB_CONFIG config['deploy'] ||= {} config['deploy']['artifact'] = artifact_path File.open(EB_CONFIG, 'wb') { |f| f.write config.to_yaml[4..-1] } # skip ---\n rescue Errno::ENOENT end |