docker-runner 0.1.0 → 1.0.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 +4 -4
- data/README.md +17 -10
- data/bin/docker-runner +2 -2
- data/bin/include/docker-runner.sh +25 -2
- data/bin/include/functions.sh +54 -11
- data/docker-runner.gemspec +3 -0
- data/lib/docker/runner.rb +1 -1
- data/lib/docker/runner/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9ba1c187306ebe03331ed95d0b46aa17d46054d
|
4
|
+
data.tar.gz: 4c0011e49704208b423735b85eaeedbe6451bdf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c815fb8d8d3190bc764d80410387c779532520982018f0f70b97fc5dc1c9c30e419d57f53b7c07450a8479da9145c9e1b40d8e80b8ee489bcb02be9100d5d3dd
|
7
|
+
data.tar.gz: 551667a63fb0aea99c70fc55f95846cb2c49a93164b802b4d6cbc384fb0cac662181c506bfa5c8742c6330db325bbb7ca2315cbcbdc5a3b0da45eeb720f91e7c
|
data/README.md
CHANGED
@@ -9,16 +9,23 @@ A Rails Like Docker Runner Cli
|
|
9
9
|
|
10
10
|
## Commands List
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
~~~
|
13
|
+
$ docker-runner
|
14
|
+
Usage:
|
15
|
+
- docker-runner new [project_name] 新建一个镜像
|
16
|
+
- docker-runner setup 执行环境初始化
|
17
|
+
- docker-runner reset 重置执行环境
|
18
|
+
- docker-runner config 查看当前执行环境
|
19
|
+
- docker-runner build 构建镜像
|
20
|
+
- docker-runner push 推送镜像到远程仓库
|
21
|
+
- docker-runner login 登录镜像远程仓库
|
22
|
+
- docker-runner logout 退出镜像远程仓库
|
23
|
+
- docker-runner console 开启镜像控制台
|
24
|
+
- docker-runner update 更新镜像模板
|
25
|
+
- docker-runner version 查看当前版本
|
26
|
+
|
27
|
+
docker-runner v0.1.0 (c) 2016 @caishuo
|
28
|
+
~~~
|
22
29
|
|
23
30
|
## 使用说明
|
24
31
|
|
data/bin/docker-runner
CHANGED
@@ -5,8 +5,8 @@ require 'docker/runner'
|
|
5
5
|
bin_dir = File.expand_path(File.dirname(__FILE__))
|
6
6
|
shell_script_path = File.join(bin_dir, 'include', 'docker-runner.sh')
|
7
7
|
|
8
|
-
if ARGV[0] == 'version'
|
8
|
+
if ARGV[0] == 'version' or ARGV[0] == '-v'
|
9
9
|
puts Docker::Runner::ABOUT
|
10
10
|
else
|
11
|
-
|
11
|
+
`VERSION='#{Docker::Runner::ABOUT}' #{shell_script_path} #{ARGV * ' '} >&2`
|
12
12
|
end
|
@@ -9,6 +9,9 @@ case "$1" in
|
|
9
9
|
setup)
|
10
10
|
do_setup
|
11
11
|
;;
|
12
|
+
reset)
|
13
|
+
do_reset
|
14
|
+
;;
|
12
15
|
config)
|
13
16
|
do_config
|
14
17
|
;;
|
@@ -27,14 +30,34 @@ case "$1" in
|
|
27
30
|
do_logout
|
28
31
|
;;
|
29
32
|
console)
|
30
|
-
docker_opts=${@%
|
33
|
+
docker_opts=${@%console}
|
31
34
|
do_console
|
32
35
|
;;
|
36
|
+
clean)
|
37
|
+
do_clean
|
38
|
+
;;
|
33
39
|
update)
|
34
40
|
do_update
|
35
41
|
;;
|
36
42
|
*)
|
37
|
-
echo
|
43
|
+
echo -e "\
|
44
|
+
Usage:\n\
|
45
|
+
- docker-runner new [project_name] 新建一个镜像\n\
|
46
|
+
- docker-runner setup 执行环境初始化\n\
|
47
|
+
- docker-runner reset 重置执行环境\n\
|
48
|
+
- docker-runner config 查看当前执行环境\n\
|
49
|
+
- docker-runner build 构建镜像\n\
|
50
|
+
- docker-runner push 推送镜像到远程仓库\n\
|
51
|
+
- docker-runner login 登录镜像远程仓库\n\
|
52
|
+
- docker-runner logout 退出镜像远程仓库\n\
|
53
|
+
- docker-runner console 开启镜像控制台\n\
|
54
|
+
- docker-runner clean Docker环境清理\n\
|
55
|
+
- docker-runner update 更新镜像模板\n\
|
56
|
+
- docker-runner version 查看当前版本\n\
|
57
|
+
" >&2
|
58
|
+
if [ '$VERSION' != '' ]; then
|
59
|
+
echo $VERSION >&2
|
60
|
+
fi
|
38
61
|
exit 3
|
39
62
|
;;
|
40
63
|
esac
|
data/bin/include/functions.sh
CHANGED
@@ -70,31 +70,45 @@ print_env() {
|
|
70
70
|
}
|
71
71
|
|
72
72
|
print_global_env() {
|
73
|
-
if
|
73
|
+
if require_global_env; then
|
74
74
|
echo "全局变量:"
|
75
75
|
cat $HOME/.docker-runner
|
76
|
-
else
|
77
|
-
echo "找不到全局 ~/.docker-runner 文件, 请执行 docker-runner init"
|
78
76
|
fi
|
79
77
|
}
|
80
78
|
|
81
79
|
print_project_env() {
|
82
|
-
if
|
80
|
+
if require_project_env; then
|
83
81
|
echo "项目变量:"
|
84
82
|
cat .docker-runner
|
85
|
-
else
|
86
|
-
echo "当前目录找不到 .docker-runner 文件"
|
87
83
|
fi
|
88
84
|
}
|
89
85
|
|
90
86
|
# 重置全局变量
|
91
|
-
|
87
|
+
reset_global_env() {
|
92
88
|
ask_global_env
|
93
89
|
set_default_global_env
|
94
90
|
save_global_env
|
95
91
|
print_global_env
|
96
92
|
}
|
97
93
|
|
94
|
+
require_global_env() {
|
95
|
+
if [ -r "$HOME/.docker-runner" ]; then
|
96
|
+
return 1
|
97
|
+
else
|
98
|
+
echo "**请先执行docker-runner setup, 进行环境初始化"
|
99
|
+
exit 11
|
100
|
+
fi
|
101
|
+
}
|
102
|
+
|
103
|
+
require_project_env() {
|
104
|
+
if require_global_env && [ -r ".docker-runner" ]; then
|
105
|
+
return 1
|
106
|
+
else
|
107
|
+
echo "**当前目录不是镜像项目, 请切换至镜像项目"
|
108
|
+
exit 12
|
109
|
+
fi
|
110
|
+
}
|
111
|
+
|
98
112
|
#------------------------------------------------------------------------------
|
99
113
|
# 2. 环境变量默认值处理:
|
100
114
|
#------------------------------------------------------------------------------
|
@@ -275,6 +289,11 @@ valid_variables() {
|
|
275
289
|
}
|
276
290
|
|
277
291
|
set_image_name() {
|
292
|
+
if ! require_project_env; then
|
293
|
+
echo '**当前目录不是镜像项目, 请切换至镜像项目'
|
294
|
+
exit 3
|
295
|
+
fi
|
296
|
+
|
278
297
|
if [ $username = $OFFICIAL_USER ]; then
|
279
298
|
img="$docker_host/$image:${version:-latest}"
|
280
299
|
else
|
@@ -283,7 +302,7 @@ set_image_name() {
|
|
283
302
|
}
|
284
303
|
|
285
304
|
build_image() {
|
286
|
-
set_image_name
|
305
|
+
set_image_name && \
|
287
306
|
(docker build $docker_opts -t $img .) && \
|
288
307
|
echo $img was built successfully
|
289
308
|
}
|
@@ -299,6 +318,7 @@ push_image() {
|
|
299
318
|
#------------------------------------------------------------------------------
|
300
319
|
|
301
320
|
docker_login() {
|
321
|
+
echo "正在登录$docker_host:"
|
302
322
|
read -p "用户名($(default_username)): " username
|
303
323
|
echo "docker login -u ${username:=$(default_username)} -e $email $docker_host"
|
304
324
|
docker login -u ${username:=$(default_username)} -e $email $docker_host
|
@@ -309,10 +329,16 @@ docker_logout() {
|
|
309
329
|
}
|
310
330
|
|
311
331
|
docker_console() {
|
312
|
-
set_image_name
|
332
|
+
set_image_name && \
|
313
333
|
docker run -i -t --rm --name ${NAME:-tmp} $docker_opts $img /bin/sh
|
314
334
|
}
|
315
335
|
|
336
|
+
docker_clean() {
|
337
|
+
echo '[开始清理container]' && docker rm `docker ps -a | grep Exited | awk '{print $1 }'`
|
338
|
+
echo '[开始清理image]' && docker rmi $(docker images | grep "^<none>" | awk "{print $3}")
|
339
|
+
echo '[开始清理volume]' && docker volume rm $(docker volume ls -qf dangling=true)
|
340
|
+
}
|
341
|
+
|
316
342
|
#------------------------------------------------------------------------------
|
317
343
|
# Public API
|
318
344
|
#------------------------------------------------------------------------------
|
@@ -329,11 +355,24 @@ do_new_project() {
|
|
329
355
|
}
|
330
356
|
|
331
357
|
do_setup() {
|
332
|
-
|
333
|
-
echo ''
|
358
|
+
reset_global_env
|
334
359
|
do_login
|
335
360
|
}
|
336
361
|
|
362
|
+
do_reset() {
|
363
|
+
echo "该操作将删除已有配置"
|
364
|
+
read -p "确认是否进行: (Y/n) " is_reset_env
|
365
|
+
if ([ "$is_reset_env" = '' ] || [ "$is_reset_env" = 'Y' ] || [ "$is_reset_env" = 'y' ]); then
|
366
|
+
rm -f "$HOME/.docker-runner"
|
367
|
+
unset gitlab_token
|
368
|
+
echo "清理成功, 开始重置..."
|
369
|
+
do_setup
|
370
|
+
echo "重置成功"
|
371
|
+
else
|
372
|
+
echo 停止执行环境重置
|
373
|
+
fi
|
374
|
+
}
|
375
|
+
|
337
376
|
do_config() {
|
338
377
|
print_env
|
339
378
|
}
|
@@ -360,6 +399,10 @@ do_console() {
|
|
360
399
|
docker_console
|
361
400
|
}
|
362
401
|
|
402
|
+
do_clean() {
|
403
|
+
docker_clean
|
404
|
+
}
|
405
|
+
|
363
406
|
do_update() {
|
364
407
|
update_template
|
365
408
|
}
|
data/docker-runner.gemspec
CHANGED
@@ -19,6 +19,9 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = ['docker-runner']
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
+
spec.post_install_message = "\033[41;37m [Important] run \`docker-runner setup\`, before using \033[0m "
|
23
|
+
# spec.post_install_message = `docker-runner`
|
24
|
+
|
22
25
|
spec.add_dependency 'gitlab'
|
23
26
|
|
24
27
|
spec.add_development_dependency "bundler", "~> 1.11"
|
data/lib/docker/runner.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docker-runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "王长明"
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gitlab
|
@@ -76,7 +76,8 @@ homepage: https://gitlab.caishuo.com/docker/docker-runner
|
|
76
76
|
licenses:
|
77
77
|
- MIT
|
78
78
|
metadata: {}
|
79
|
-
post_install_message:
|
79
|
+
post_install_message: "\e[41;37m [Important] run `docker-runner setup`, before using
|
80
|
+
\e[0m "
|
80
81
|
rdoc_options: []
|
81
82
|
require_paths:
|
82
83
|
- lib
|