docker_alias 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +92 -0
- data/Rakefile +2 -0
- data/docker_alias.gemspec +25 -0
- data/lib/docker_alias/configuration.rb +35 -0
- data/lib/docker_alias/container.rb +20 -0
- data/lib/docker_alias/db.rb +15 -0
- data/lib/docker_alias/tasks/docker_alias.rake +50 -0
- data/lib/docker_alias/version.rb +3 -0
- data/lib/docker_alias.rb +54 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ce68d55cd8bb425658546e7ae3d736d970ab0261
|
4
|
+
data.tar.gz: 9678d9752c16525f8bc30cf1f90bde2c97f36a8c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4a897ebcd7485dff153341862c926f75e5a4329f698da29e405112b5a19650906cc3c5e8fe1bb94d38855affd86ed5aa614ef190cc59a03a6569435708ff805d
|
7
|
+
data.tar.gz: c598fa5e849a192a188029b7898713858b40e9ae29162e1302f7f143fa252bdb5e1a0c19f36f7d1251e9ec7b8f9f7c90b13064ac93381b88a6292ee8a93219e9
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 seapy
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# DockerAlias
|
2
|
+
|
3
|
+
`docker` 명령어를 출력해서 쉽게 사용하게 하는 rake task 젬
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'docker_alias'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install docker_alias
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```shell
|
22
|
+
bin/rake dockera:build
|
23
|
+
bin/rake dockera:push
|
24
|
+
|
25
|
+
bin/rake dockera:con:start
|
26
|
+
bin/rake dockera:con:stop
|
27
|
+
bin/rake dockera:con:rm
|
28
|
+
bin/rake dockera:con:bash
|
29
|
+
|
30
|
+
bin/rake dockera:db:create
|
31
|
+
bin/rake dockera:db:setup
|
32
|
+
bin/rake dockera:db:migrate
|
33
|
+
```
|
34
|
+
|
35
|
+
## Configuration
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
# config/initializers/docker_alias.rb
|
39
|
+
DockerAlias.configure do |config|
|
40
|
+
config.repo = 'seapy/docker_alias'
|
41
|
+
config.tag = 'latest'
|
42
|
+
config.cache_buster_key = 'CACHE_BUSTER_'
|
43
|
+
config.options = [
|
44
|
+
'--link mysql:mysql',
|
45
|
+
'--link redis:redis',
|
46
|
+
'--rm'
|
47
|
+
]
|
48
|
+
config.enviroments = {
|
49
|
+
'SECRET_KEY_BASE' => ENV['RORLA_SECRET_KEY_BASE'],
|
50
|
+
'TEST_KEY' => 'yo'
|
51
|
+
}
|
52
|
+
config.port_maps = [
|
53
|
+
'80:80',
|
54
|
+
'3306:3306',
|
55
|
+
]
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
59
|
+
### `cache_buster_key`
|
60
|
+
|
61
|
+
if provided `cache_buster_key`, DockerAlias replace string from your `Dockerfile`.
|
62
|
+
|
63
|
+
if your Dockerfile like this
|
64
|
+
|
65
|
+
```shell
|
66
|
+
RUN echo "CACHE_BUSTER_0"
|
67
|
+
```
|
68
|
+
|
69
|
+
and cache_buster_key is set `CACHE_BUSTER_`
|
70
|
+
`Dockerfile` changed like this, when you docker build
|
71
|
+
|
72
|
+
```shell
|
73
|
+
RUN echo "CACHE_BUSTER_1404132922"
|
74
|
+
```
|
75
|
+
|
76
|
+
`1404132922` is build timestamp.
|
77
|
+
|
78
|
+
you must append number after `cache_buster_key`
|
79
|
+
|
80
|
+
```shell
|
81
|
+
RUN echo "CACHE_BUSTER_23" # it's ok
|
82
|
+
RUN echo "CACHE_BUSTER_jasd" # not ok
|
83
|
+
RUN echo "CACHE_BUSTER_" # not ok
|
84
|
+
```
|
85
|
+
|
86
|
+
## Contributing
|
87
|
+
|
88
|
+
1. Fork it ( https://github.com/seapy/docker_alias/fork )
|
89
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
90
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
91
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
92
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'docker_alias/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "docker_alias"
|
8
|
+
spec.version = DockerAlias::VERSION
|
9
|
+
spec.authors = ["seapy"]
|
10
|
+
spec.email = ["iamseapy@gmail.com"]
|
11
|
+
spec.summary = %q{도커 명령어를 출력}
|
12
|
+
spec.description = %q{도커 명령어에서 자주 사용하는 옵션을 포함하고 환경변수등도 포함해서 붙여넣기 하면 사용할 수 있도록 한다. docker-api 사용하는것들보다는 직접 명령어를 통해서 도커를 실행해본다는 의도.}
|
13
|
+
spec.homepage = "https://github.com/seapy/docker_alias"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "railties", ">= 3.0"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module DockerAlias
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :repo, :tag, :cache_buster_key
|
4
|
+
attr_writer :options, :enviroments, :port_maps
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@repo = ''
|
8
|
+
@tag = 'latest'
|
9
|
+
@cache_buster_key = 'CACHE_BUSTER_'
|
10
|
+
@options = []
|
11
|
+
@enviroments = {}
|
12
|
+
@port_maps = []
|
13
|
+
end
|
14
|
+
|
15
|
+
def build_name
|
16
|
+
"#{@repo}:#{@tag}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def options
|
20
|
+
@options.join(" ")
|
21
|
+
end
|
22
|
+
|
23
|
+
def port_maps
|
24
|
+
@port_maps.map{ |x| "-p #{x}" }.join(" ")
|
25
|
+
end
|
26
|
+
|
27
|
+
def enviroments
|
28
|
+
envs = []
|
29
|
+
@enviroments.each do |key, value|
|
30
|
+
envs << "-e #{key}=#{value}"
|
31
|
+
end
|
32
|
+
envs.join(" ")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module DockerAlias
|
2
|
+
class Container
|
3
|
+
def self.start
|
4
|
+
build_name = DockerAlias.build_name
|
5
|
+
puts "docker run --name #{build_name} #{DockerAlias.options} -d #{build_name}"
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.stop
|
9
|
+
puts "docker stop --name #{DockerAlias.build_name}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.rm
|
13
|
+
puts "docker rm --name #{DockerAlias.build_name}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.bash
|
17
|
+
puts "#{DockerAlias.console} /bin/bash"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module DockerAlias
|
2
|
+
class Db
|
3
|
+
def self.create
|
4
|
+
puts "#{DockerAlias.console} bundle exec rake db:create"
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.setup
|
8
|
+
puts "#{DockerAlias.console} bundle exec rake db:setup"
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.migrate
|
12
|
+
puts "#{DockerAlias.console} bundle exec rake db:migrate"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
namespace :dockera do
|
2
|
+
desc "도커 이미지 빌드"
|
3
|
+
task :build do
|
4
|
+
DockerAlias.build
|
5
|
+
end
|
6
|
+
|
7
|
+
desc "도커 이미지 업로드"
|
8
|
+
task :push do
|
9
|
+
DockerAlias.push
|
10
|
+
end
|
11
|
+
|
12
|
+
namespace :con do
|
13
|
+
desc "도커 컨테이너 실행"
|
14
|
+
task :start do
|
15
|
+
DockerAlias::Container.start
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "도커 컨테이너 중지"
|
19
|
+
task :stop do
|
20
|
+
DockerAlias::Container.stop
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "도커 컨테이너 삭제"
|
24
|
+
task :rm do
|
25
|
+
DockerAlias::Container.rm
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "도커 컨테이너 bash 실행"
|
29
|
+
task :bash do
|
30
|
+
DockerAlias::Container.bash
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
namespace :db do
|
35
|
+
desc "도커 DB 생성"
|
36
|
+
task :create do
|
37
|
+
DockerAlias::Db.create
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "도커 DB 초기 설정. 마이그레이션 및 시드 데이터 추가"
|
41
|
+
task :setup do
|
42
|
+
DockerAlias::Db.setup
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "도커 DB 마이그레이트"
|
46
|
+
task :migrate do
|
47
|
+
DockerAlias::Db.migrate
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/docker_alias.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require "docker_alias/version"
|
2
|
+
require "docker_alias/configuration"
|
3
|
+
require "docker_alias/container"
|
4
|
+
require "docker_alias/db"
|
5
|
+
|
6
|
+
module DockerAlias
|
7
|
+
class << self
|
8
|
+
attr_writer :configuration
|
9
|
+
end
|
10
|
+
|
11
|
+
# Railtie to hook into Rails.
|
12
|
+
class Railtie < Rails::Railtie
|
13
|
+
rake_tasks do
|
14
|
+
load "docker_alias/tasks/docker_alias.rake"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.configuration
|
19
|
+
@configuration ||= Configuration.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.configure
|
23
|
+
yield(configuration)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.build
|
27
|
+
# 도커의 캐쉬가 명령어 기반이라서 해당 부분의 문자열을 바꿔주어 그 이후부터 캐쉬 이용하지 않도록함. https://github.com/dotcloud/docker/issues/1996
|
28
|
+
cache_key = configuration.cache_buster_key
|
29
|
+
cache_buster_cmd = "sed -i '' s/#{cache_key}[0-9]*/#{cache_key}#{Time.now.to_i}/g Dockerfile"
|
30
|
+
system(cache_buster_cmd)
|
31
|
+
system("docker build --force-rm -t #{configuration.build_name} .")
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.push
|
35
|
+
system("docker push #{configuration.build_name}")
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.console
|
39
|
+
"docker run -i -t --rm #{options} #{build_name}"
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def self.build_name
|
44
|
+
DockerAlias.configuration.build_name
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.options
|
48
|
+
options = []
|
49
|
+
options << DockerAlias.configuration.options
|
50
|
+
options << DockerAlias.configuration.enviroments
|
51
|
+
options << DockerAlias.configuration.port_maps
|
52
|
+
options.reject{ |x| x.nil? || x.empty? || x.length == 0 }.join(" ")
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: docker_alias
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- seapy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: railties
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: "도커 명령어에서 자주 사용하는 옵션을 포함하고 환경변수등도 포함해서 붙여넣기 하면 사용할 수 있도록 한다. docker-api
|
56
|
+
사용하는것들보다는 직접 명령어를 통해서 도커를 실행해본다는 의도."
|
57
|
+
email:
|
58
|
+
- iamseapy@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- docker_alias.gemspec
|
69
|
+
- lib/docker_alias.rb
|
70
|
+
- lib/docker_alias/configuration.rb
|
71
|
+
- lib/docker_alias/container.rb
|
72
|
+
- lib/docker_alias/db.rb
|
73
|
+
- lib/docker_alias/tasks/docker_alias.rake
|
74
|
+
- lib/docker_alias/version.rb
|
75
|
+
homepage: https://github.com/seapy/docker_alias
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.2.2
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: "도커 명령어를 출력"
|
99
|
+
test_files: []
|
100
|
+
has_rdoc:
|