docker-eb-deploy 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b1f6c7538ec409559c07ded5f2d50e5967dc4b67
4
+ data.tar.gz: 7cce2f4868b50aaeea5c584414a99f5fed7f4eea
5
+ SHA512:
6
+ metadata.gz: b7ed7e087d50a658a9ff496d299ca8ddb3d8d7a61371906349b113ec1ddf837914a7bffce5d3a0eff99fc0be01a0ac8c14dc08c11d4b2e2a36c565fd330343cf
7
+ data.tar.gz: 37995af9d42c15b83816fba69100807837fc4501603fd6695f5c305c965d4cbc5864121d6dd18b152c462b5883dbace8b9b69befb92a81095ddc7fb8273ef15c
@@ -0,0 +1,4 @@
1
+ /.bundle
2
+ /Gemfile.lock
3
+ /vendor
4
+ /*.gem
@@ -0,0 +1 @@
1
+ 2.2.3
@@ -0,0 +1,27 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people
4
+ who contribute through reporting issues, posting feature requests, updating
5
+ documentation, submitting pull requests or patches, and other activities.
6
+
7
+ We are committed to making participation in this project a harassment-free
8
+ experience for everyone, regardless of level of experience, gender, gender
9
+ identity and expression, sexual orientation, disability, personal appearance,
10
+ body size, race, ethnicity, age, or religion.
11
+
12
+ Examples of unacceptable behavior by participants include the use of sexual
13
+ language or imagery, derogatory comments or personal attacks, trolling, public
14
+ or private harassment, insults, or other unprofessional conduct.
15
+
16
+ Project maintainers have the right and responsibility to remove, edit, or reject
17
+ comments, commits, code, wiki edits, issues, and other contributions that are
18
+ not aligned to this Code of Conduct. Project maintainers who do not follow the
19
+ Code of Conduct may be removed from the project team.
20
+
21
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
22
+ reported by opening an issue or contacting one or more of the project
23
+ maintainers.
24
+
25
+ This Code of Conduct is adapted from the [Contributor
26
+ Covenant](http://contributor-covenant.org), version 1.0.0, available at
27
+ [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in deploy.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Sealink Travel Group Limited
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,46 @@
1
+ # docker-eb-deploy
2
+
3
+ docker-eb-deploy is a gem for facilitating Elastic Beanstalk deployment of
4
+ Docker images built automatically by Docker Hub or another third party service.
5
+
6
+ Currently it allows you to create a release and trigger the build automation in
7
+ Docker Hub.
8
+
9
+ 1. Update the version in `public/version.txt`
10
+
11
+ 1. Update the version tag of the image name in `Dockerrun.aws.json`
12
+
13
+ 1. Push to the updated branch and the tag as the version to origin
14
+
15
+ ## Installation
16
+
17
+ For multiple application usage, install the gem directly (in the global gem
18
+ space if you're using rbenv or rvm):
19
+
20
+ ```shell
21
+ gem install docker-eb-deploy
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ Execute `docker-release` in your project directory
27
+ that contains the Dockerrun.aws.json file.
28
+
29
+ ## Development
30
+
31
+ Bundler is recommended for managing the development dependencies.
32
+
33
+ Rspec tests are located in the `spec` directory. Just run `rspec` in the root
34
+ directory of the project to run all the bundled specs.
35
+
36
+ ## Contributing
37
+
38
+ Bug reports and pull requests are welcome on GitHub at
39
+ https://github.com/sealink/docker-deploy. This project is intended to be a safe,
40
+ welcoming space for collaboration, and contributors are expected to adhere to
41
+ the [Contributor Covenant](contributor-covenant.org) code of conduct.
42
+
43
+ ## License
44
+
45
+ The gem is available as open source under the terms of the [MIT
46
+ License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+
4
+ THIS_FILE = Pathname.new(__FILE__).realpath
5
+ lib = THIS_FILE.dirname.parent + 'lib'
6
+
7
+ if lib.directory?
8
+ lib_path = lib.to_s
9
+ $LOAD_PATH.unshift lib_path if !$LOAD_PATH.include? lib_path
10
+ end
11
+
12
+ require 'docker/release/runner'
13
+
14
+ tag = ARGV[0]
15
+ # Demand correct invocation, one argument only for tag, clean git, changelog
16
+ if tag.nil?
17
+ abort "USAGE:
18
+ #{File.basename($0)} [TAG]
19
+ TAG: tag to deploy or create on current commit
20
+ Incorrect number of arguments given."
21
+ end
22
+ deployment = Docker::Release::Runner.new(tag)
23
+ deployment.run
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'docker/deploy/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'docker-eb-deploy'
9
+ spec.version = Docker::Deploy::VERSION
10
+ spec.authors = [ 'Alvin Yim' ]
11
+ spec.email = [ 'alvin.yim@sealink.com.au' ]
12
+
13
+ spec.summary = 'Tag the Git repo for Docker Hub to build the image'
14
+ spec.description = 'Tag the Git repo for Docker Hub to build the image for Elastic Beanstalk'
15
+ spec.homepage = 'https://github.com/sealink/docker-eb-deploy'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match %r{^(test|spec|features)/} }
19
+
20
+ spec.bindir = 'bin'
21
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename f }
22
+ spec.require_paths = [ 'lib' ]
23
+
24
+ spec.add_dependency 'deploy_aws', '0.1.0'
25
+
26
+ spec.add_development_dependency 'rspec', '~> 3.4'
27
+ end
@@ -0,0 +1,5 @@
1
+ module Docker
2
+ module Deploy
3
+ VERSION = '0.1.1'
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Docker
2
+ module Dockerrun
3
+ FILE_NAME = 'Dockerrun.aws.json'
4
+ end
5
+ end
@@ -0,0 +1,72 @@
1
+ require 'docker/dockerrun'
2
+ require 'json'
3
+
4
+ module Docker
5
+ module Dockerrun
6
+ class Tag
7
+ def initialize(new_tag)
8
+ @new_tag = new_tag
9
+ end
10
+
11
+ def call
12
+ open
13
+ read
14
+ overwrite_with_new_tag
15
+ close
16
+ end
17
+
18
+ private
19
+
20
+ attr_reader :file, :original_json
21
+
22
+ def open
23
+ @file ||= File.open(FILE_NAME, 'r+')
24
+ end
25
+
26
+ def read
27
+ @original_json ||= file.read
28
+ end
29
+
30
+ def original_hash
31
+ @original_hash ||= JSON.parse(original_json)
32
+ end
33
+
34
+ def original_image_value
35
+ original_hash.fetch 'Image', { }
36
+ end
37
+
38
+ def original_name_value
39
+ original_image_value.fetch 'Name', ''
40
+ end
41
+
42
+ def name_without_tag
43
+ original_name_value.sub /:.*/, ''
44
+ end
45
+
46
+ def updated_name
47
+ "#{name_without_tag}:#{@new_tag}"
48
+ end
49
+
50
+ def updated_image_value
51
+ original_image_value.merge 'Name' => updated_name
52
+ end
53
+
54
+ def updated_hash
55
+ original_hash.merge 'Image' => updated_image_value
56
+ end
57
+
58
+ def updated_json
59
+ JSON.pretty_generate updated_hash
60
+ end
61
+
62
+ def overwrite_with_new_tag
63
+ file.rewind
64
+ file.write updated_json
65
+ end
66
+
67
+ def close
68
+ file.close
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,33 @@
1
+ require 'singleton'
2
+ require 'json'
3
+ require 'docker/dockerrun'
4
+ require 'docker/dockerrun/tag'
5
+
6
+ module Docker
7
+ module Dockerrun
8
+ class Validate
9
+ include Singleton
10
+
11
+ def call
12
+ existence
13
+ parsability
14
+ end
15
+
16
+ private
17
+
18
+ def existence
19
+ abort "./#{FILE_NAME} not found!" unless File.exist? FILE_NAME
20
+ end
21
+
22
+ def parsability
23
+ JSON.parse File.read(FILE_NAME)
24
+ rescue JSON::ParserError => error
25
+ abort "#{FILE_NAME} is not parsable: #{error.message}"
26
+ end
27
+
28
+ def abort(message)
29
+ Kernel.abort message
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,41 @@
1
+ require 'deploy'
2
+ require 'docker/repository'
3
+ require 'docker/dockerrun/validate'
4
+
5
+ module Docker
6
+ module Release
7
+ class Runner < ::Deploy::Runner
8
+ def run
9
+ trap_int
10
+ precheck!
11
+ validate!
12
+ perform!
13
+ end
14
+
15
+ private
16
+
17
+ def precheck!
18
+ check_for_unstaged_changes!
19
+ check_for_changelog!
20
+ end
21
+
22
+ def validate!
23
+ Dockerrun::Validate.instance.call
24
+ end
25
+
26
+ def perform!
27
+ synchronize_repo!
28
+ log 'The new release has been pushed.'
29
+ end
30
+
31
+ def synchronize_repo!
32
+ log 'Preparing the tagged version for release.'
33
+ repo.prepare! @tag
34
+ end
35
+
36
+ def repo
37
+ @repo ||= Docker::Repository.new
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,29 @@
1
+ require 'deploy/repository'
2
+ require 'docker/dockerrun/tag'
3
+ require 'docker/dockerrun'
4
+
5
+ module Docker
6
+ class Repository < ::Deploy::Repository
7
+ private
8
+
9
+ def tag_dockerrun!
10
+ Dockerrun::Tag.new(@tag).call
11
+ end
12
+
13
+ def version!
14
+ super
15
+ tag_dockerrun!
16
+ end
17
+
18
+ def commit!
19
+ puts "Committing version.txt and #{Dockerrun::FILE_NAME}..."
20
+ unless system("git add public/version.txt #{Dockerrun::FILE_NAME}") && system("git commit -m \"#{commit_message}\" ")
21
+ fail 'Failed to commit.'
22
+ end
23
+ end
24
+
25
+ def commit_message
26
+ @commit_message ||= "#{last_commit_message} - release"
27
+ end
28
+ end
29
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: docker-eb-deploy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Alvin Yim
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: deploy_aws
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.4'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.4'
41
+ description: Tag the Git repo for Docker Hub to build the image for Elastic Beanstalk
42
+ email:
43
+ - alvin.yim@sealink.com.au
44
+ executables:
45
+ - docker-release
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - ".ruby-version"
51
+ - CODE_OF_CONDUCT.md
52
+ - Gemfile
53
+ - LICENSE.txt
54
+ - README.md
55
+ - bin/docker-release
56
+ - docker-eb-deploy.gemspec
57
+ - lib/docker/deploy/version.rb
58
+ - lib/docker/dockerrun.rb
59
+ - lib/docker/dockerrun/tag.rb
60
+ - lib/docker/dockerrun/validate.rb
61
+ - lib/docker/release/runner.rb
62
+ - lib/docker/repository.rb
63
+ homepage: https://github.com/sealink/docker-eb-deploy
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.4.5.1
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Tag the Git repo for Docker Hub to build the image
87
+ test_files: []