bgb 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/README.md +36 -0
- data/Rakefile +6 -0
- data/bgb.gemspec +27 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/bgb +5 -0
- data/lib/bgb/version.rb +3 -0
- data/lib/bgb.rb +87 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 79670c892f618fe782d6bc4042c8e2c56a1e3fc4
|
4
|
+
data.tar.gz: 1df922d863be88463b3a28f224ec4a35b3a3cdcb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b6405fb98f0c2662bf720254f4effa356b8abfd3a67a61aa2004817d0ee7d799097ae90697a772faab0ae5cf5b345880c3234789e057c4843b2d9a274c0ef414
|
7
|
+
data.tar.gz: dcac616838e76d7315975d0503e29e9afb783503284f31ef7a5d280858632afc911c63d5c3ee0a84e72a8043548b06bec3483c22d71442b330ba397bcba5d910
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Bgb
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/bgb`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'bgb'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install bgb
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/bgb.
|
36
|
+
|
data/Rakefile
ADDED
data/bgb.gemspec
ADDED
@@ -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
|
+
require 'bgb/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bgb"
|
8
|
+
spec.version = Bgb::VERSION
|
9
|
+
spec.authors = ["Kazuhisa Yamamoto"]
|
10
|
+
spec.email = ["ak.hisashi@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{The tool for building and pushing the Docker image.}
|
13
|
+
spec.description = %q{The tool for building and pushing the Docker image.}
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
+
|
26
|
+
spec.add_dependency "thor"
|
27
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "bgb"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/exe/bgb
ADDED
data/lib/bgb/version.rb
ADDED
data/lib/bgb.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
require "bgb/version"
|
2
|
+
require 'thor'
|
3
|
+
require 'yaml'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module Bgb
|
7
|
+
class CLI < Thor
|
8
|
+
desc "build", "build image."
|
9
|
+
option :file, aliases: :f, desc: "File path of build.yml"
|
10
|
+
def build
|
11
|
+
file_path = options[:file]
|
12
|
+
@setting = build_setting(file_path)
|
13
|
+
|
14
|
+
Dir.mktmpdir do |build_path|
|
15
|
+
login
|
16
|
+
git_pull(build_path)
|
17
|
+
docker_build(build_path)
|
18
|
+
tagging
|
19
|
+
push
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "images", "Docker images."
|
24
|
+
option :file, aliases: :f, desc: "File path of build.yml"
|
25
|
+
def images
|
26
|
+
file_path = options[:file]
|
27
|
+
@setting = build_setting(file_path)
|
28
|
+
login
|
29
|
+
docker_images
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
def build_setting(file_path)
|
34
|
+
file_path = "build.yml" if file_path.nil?
|
35
|
+
YAML.load_file(file_path)
|
36
|
+
end
|
37
|
+
|
38
|
+
def setting
|
39
|
+
@setting
|
40
|
+
end
|
41
|
+
|
42
|
+
# ECRにログイン
|
43
|
+
def login
|
44
|
+
system("`aws ecr get-login --region ap-northeast-1`")
|
45
|
+
end
|
46
|
+
|
47
|
+
# ワークディレクトリにdocker_bondgateをpull
|
48
|
+
def git_pull(build_path)
|
49
|
+
cmd = "git clone https://#{setting['docker_repos']['user']}:#{setting['docker_repos']['token']}@#{setting['docker_repos']['uri']} #{build_path}"
|
50
|
+
system(cmd)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Dockerビルド
|
54
|
+
def docker_build(build_path)
|
55
|
+
cmd = "docker build -t #{setting['ecs']['docker_image']}:#{setting['ecs']['docker_tag']} " +
|
56
|
+
"--build-arg GIT_BRANCH=#{setting['build_ops']['git_branch']} " +
|
57
|
+
"--build-arg GITHUB_TOKEN=#{setting['build_ops']['github_token']} "
|
58
|
+
cmd += "--build-arg PROJECT=#{setting['build_ops']['project']} " if setting['build_ops']['project']
|
59
|
+
cmd += "--build-arg INHERITED=#{setting['build_ops']['inherited']} " if setting['build_ops']['inherited']
|
60
|
+
cmd += "--build-arg UNICORN_WORKER=#{setting['build_ops']['unicorn_worker']} " if setting['build_ops']['unicorn_worker']
|
61
|
+
cmd += "--build-arg MAX_REQUEST_MIN=#{setting['build_ops']['max_request_min']} " if setting['build_ops']['max_request_min']
|
62
|
+
cmd += "--build-arg MAX_REQUEST_MAX=#{setting['build_ops']['max_request_max']} " if setting['build_ops']['max_request_max']
|
63
|
+
cmd += "#{build_path}"
|
64
|
+
system(cmd)
|
65
|
+
end
|
66
|
+
|
67
|
+
# タグ付け
|
68
|
+
def tagging
|
69
|
+
cmd = "docker tag #{setting['ecs']['docker_image']}:#{setting['ecs']['docker_tag']} #{setting['ecs']['ecr']}/#{setting['ecs']['docker_image']}:#{setting['ecs']['docker_tag']}"
|
70
|
+
system(cmd)
|
71
|
+
end
|
72
|
+
|
73
|
+
# プッシュ
|
74
|
+
def push
|
75
|
+
cmd = "docker push #{setting['ecs']['ecr']}/#{setting['ecs']['docker_image']}:#{setting['ecs']['docker_tag']}"
|
76
|
+
system(cmd)
|
77
|
+
end
|
78
|
+
|
79
|
+
# イメージの一覧を取得
|
80
|
+
def docker_images
|
81
|
+
result = JSON.parse(`aws ecr describe-images --repository-name #{setting['ecs']['docker_image']} --region ap-northeast-1`)
|
82
|
+
result["imageDetails"].each do |row|
|
83
|
+
puts "#{row['imageTags']}:#{Time.at(row['imagePushedAt'])}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bgb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kazuhisa Yamamoto
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-06-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: The tool for building and pushing the Docker image.
|
70
|
+
email:
|
71
|
+
- ak.hisashi@gmail.com
|
72
|
+
executables:
|
73
|
+
- bgb
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".travis.yml"
|
80
|
+
- Gemfile
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bgb.gemspec
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
86
|
+
- exe/bgb
|
87
|
+
- lib/bgb.rb
|
88
|
+
- lib/bgb/version.rb
|
89
|
+
homepage:
|
90
|
+
licenses: []
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.5.2
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: The tool for building and pushing the Docker image.
|
112
|
+
test_files: []
|