dockerfile2bash 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/examples/ngx_mruby-install.sh +3 -3
- data/lib/dockerfile2bash.rb +22 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c10341f38cbf916362d40e80de112f43b12a709
|
4
|
+
data.tar.gz: daf9f2c0866e96a1835b3f8252c74e3875bbc898
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2946deadf412b6aaaf03d4f1d57655c3711dbbc17c625a98980b67079a4c7be6b44e9395f103bd6f6c3a53fbf27d2febc12e7deff3d775228addbcc979183ba
|
7
|
+
data.tar.gz: b8032f7962094bf0f9939c17deb1560bc674a45e3d3a713a3f275b4a74db8c946f12d2ec6518f9c655986a2f2b43064379dea95af40f99748994e72a867db9c6
|
data/README.md
CHANGED
@@ -40,7 +40,7 @@ df2sh /path/to/your/Dockerfile [output_bash_filename]
|
|
40
40
|
|
41
41
|
`out.sh` will be used as output filename in current directory if the `output_bash_filename` is omitted.
|
42
42
|
|
43
|
-
And here some
|
43
|
+
And here're some examples of generated scripts: [examples](./examples).
|
44
44
|
|
45
45
|
## Development
|
46
46
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/bin/bash
|
2
2
|
|
3
|
-
# The script is generated from a Dockerfile via Dockerfile2bash(v0.1.
|
3
|
+
# The script is generated from a Dockerfile via Dockerfile2bash(v0.1.1)
|
4
4
|
# By B1nj0y <idegorepl@gmail.com>
|
5
5
|
|
6
6
|
# The original Dockerfile is from a base image: <ubuntu:14.04>
|
@@ -21,6 +21,6 @@ apt-get -y install make
|
|
21
21
|
apt-get -y install libpcre3 libpcre3-dev
|
22
22
|
apt-get -y install libmysqlclient-dev
|
23
23
|
cd /usr/local/src/ && git clone https://github.com/matsumotory/ngx_mruby.git
|
24
|
-
export NGINX_CONFIG_OPT_ENV
|
25
|
-
echo
|
24
|
+
export NGINX_CONFIG_OPT_ENV="--with-http_stub_status_module --with-http_ssl_module --prefix=/usr/local/nginx --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module"
|
25
|
+
echo 'export NGINX_CONFIG_OPT_ENV="--with-http_stub_status_module --with-http_ssl_module --prefix=/usr/local/nginx --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module"' >> ~/.bashrc
|
26
26
|
cd /usr/local/src/ngx_mruby && sh build.sh && make install
|
data/lib/dockerfile2bash.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'json'
|
2
2
|
|
3
3
|
class Dockerfile2bash
|
4
|
-
VERSION = '0.1.
|
4
|
+
VERSION = '0.1.2'
|
5
5
|
attr_reader :commands
|
6
6
|
FIELDS = %w(from user run add copy arg env expose cmd onbuild)
|
7
7
|
|
@@ -23,7 +23,7 @@ class Dockerfile2bash
|
|
23
23
|
next if segments.length < 2 or !FIELDS.include?(segments[0].downcase)
|
24
24
|
|
25
25
|
case segments[0].downcase!
|
26
|
-
when "from", "user", "run", "
|
26
|
+
when "from", "user", "run", "expose", "copy", "add"
|
27
27
|
@commands << { segments[0] => segments[1] }
|
28
28
|
when "cmd"
|
29
29
|
@commands << { "cmd" => (JSON.parse(segments[1]) || []).join(" ") }
|
@@ -32,6 +32,25 @@ class Dockerfile2bash
|
|
32
32
|
if args.length == 2
|
33
33
|
@commands << { "arg" => args }
|
34
34
|
end
|
35
|
+
when "env"
|
36
|
+
envs = segments[1].split
|
37
|
+
pattern = %r/^[a-zA-Z].[a-zA-Z0-9]+?=.+$/
|
38
|
+
case envs.length
|
39
|
+
when 1
|
40
|
+
@commands << { "env" => segments[1] }
|
41
|
+
when 2
|
42
|
+
if envs.all? { |e| e =~ pattern }
|
43
|
+
@commands << { "env" => segments[1] }
|
44
|
+
else
|
45
|
+
@commands << { "env" => envs.join("=") }
|
46
|
+
end
|
47
|
+
else
|
48
|
+
if envs.all? { |e| e =~ pattern }
|
49
|
+
@commands << { "env" => segments[1] }
|
50
|
+
else
|
51
|
+
@commands << { "env" => [envs[0], "\"#{envs[1..-1].join(" ")}\""].join("=") }
|
52
|
+
end
|
53
|
+
end
|
35
54
|
end
|
36
55
|
end
|
37
56
|
@commands
|
@@ -51,7 +70,7 @@ class Dockerfile2bash
|
|
51
70
|
when "env"
|
52
71
|
env_str = "export " << cmd["env"]
|
53
72
|
bash << env_str << "\n"
|
54
|
-
bash << "echo \
|
73
|
+
bash << "echo \'#{env_str}\' >> ~/.bashrc" << "\n"
|
55
74
|
end
|
56
75
|
end
|
57
76
|
bash
|