dockerfile2bash 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e862d14257ad0bcc0e3c62d885848188059fc7bc
4
- data.tar.gz: 14c32b9f4300e0f88eade205b2f770f9792043b7
3
+ metadata.gz: 5c10341f38cbf916362d40e80de112f43b12a709
4
+ data.tar.gz: daf9f2c0866e96a1835b3f8252c74e3875bbc898
5
5
  SHA512:
6
- metadata.gz: c36dff075fd538e1d3000a6a5da840160baf37ba8c2781394a29331a27ab7ba98282ec8ebb24e94916ecea85c73ebf5ad0a863751ca38e465571fb09be93ba94
7
- data.tar.gz: 14fedadd931e4a8448e5b71e59b21c88ddc0e2bce10074f8047a7182e9d12533336e960f613e5b9dc3a885a398e5ed66add85426c4c7dc9728bb33048ddc197b
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 example generated scripts: [examples](./examples).
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.0)
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 --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
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
@@ -1,7 +1,7 @@
1
1
  require 'json'
2
2
 
3
3
  class Dockerfile2bash
4
- VERSION = '0.1.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", "env", "expose", "copy", "add"
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 \"#{env_str}\" >> ~/.bashrc" << "\n"
73
+ bash << "echo \'#{env_str}\' >> ~/.bashrc" << "\n"
55
74
  end
56
75
  end
57
76
  bash
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dockerfile2bash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - B1nj0y