Hitcher 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cspec +12 -1
- data/lib/hitcher/dsl.rb +2 -2
- data/lib/hitcher/providers/docker/command_builder.rb +4 -1
- data/lib/hitcher/providers/docker/dsl.rb +39 -4
- data/lib/hitcher/providers/docker/template.rb +2 -1
- data/lib/hitcher/providers/docker/templates/Dockerfile.erb +1 -3
- data/lib/hitcher/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4275c06412c3d90bac03253c5b1bbe1db7c9f93b50633ae958399d0b2d90cae
|
4
|
+
data.tar.gz: 96b478a0675d06a473512e2b8b2c8012b1fa02024f7c5cdcf060b0b3b00c63da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48c14ba0c31c7d4ba4d0147fb3e97f8f5033e339062421ffa0d0b6f7a3dad3909a59208e435a5b3d7c3626c0faf3f48d5dc4dc42caa04fd9d814a35ad51ddc2b
|
7
|
+
data.tar.gz: ddec925b0c46c179ceddbb4fe1dae9eff2bcf70c404b7b6d31f2714beb85935b894ccb7649d5c3a4310f1973338e405666fea0d2a4016cc474b1d04c19a63573
|
data/cspec
CHANGED
@@ -10,7 +10,17 @@ tty true
|
|
10
10
|
|
11
11
|
dockerfile do_plain
|
12
12
|
FROM ruby-2_7_1
|
13
|
-
|
13
|
+
|
14
|
+
RUN apt-get update && apt-get install -y yarn #sudo && chmod u+s /usr/bin/sudo
|
15
|
+
RUN groupadd -g $GID $USER && useradd -m $USER --uid=$UID --gid=$GID && passwd -d -u $USER && usermod -aG sudo $USER
|
16
|
+
|
17
|
+
RUN cp /root/.bash_profile /home/$USER/.bash_profile && chown $USER:$USER /home/$USER/.bash_profile
|
18
|
+
RUN cp /root/.bashrc /home/$USER/.bashrc && chown $USER:$USER /home/$USER/.bashrc
|
19
|
+
RUN cp /root/.profile /home/$USER/.profile && chown $USER:$USER /home/$USER/.profile
|
20
|
+
|
21
|
+
#USER $UID:$GID
|
22
|
+
#WORKDIR /home/$USER
|
23
|
+
|
14
24
|
CMD ["/bin/bash","--login"]
|
15
25
|
#CMD ["/usr/share/rvm/rubies/ruby-2.7.1/bin/irb"]
|
16
26
|
end
|
@@ -25,3 +35,4 @@ mount do_plain
|
|
25
35
|
../lib/acts_as_tree:/opt/dev-deps/acts_as_tree
|
26
36
|
end
|
27
37
|
|
38
|
+
|
data/lib/hitcher/dsl.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
require_relative '../../global'
|
3
3
|
require 'toolrack'
|
4
|
-
|
4
|
+
require 'etc'
|
5
5
|
require 'ptools'
|
6
6
|
|
7
7
|
module Hitcher
|
@@ -94,6 +94,9 @@ module Hitcher
|
|
94
94
|
cmd << process_mount(opts)
|
95
95
|
cmd << process_port(opts)
|
96
96
|
|
97
|
+
#userInfo = Etc.getpwnam(Etc.getlogin)
|
98
|
+
#cmd << "--user #{userInfo.uid}:#{userInfo.gid}"
|
99
|
+
|
97
100
|
cmd << image
|
98
101
|
|
99
102
|
if not_empty?(opts[:command])
|
@@ -1,5 +1,7 @@
|
|
1
1
|
|
2
2
|
require "toolrack"
|
3
|
+
require 'etc'
|
4
|
+
|
3
5
|
require_relative 'template'
|
4
6
|
require_relative 'command_builder'
|
5
7
|
require_relative 'command_runner'
|
@@ -47,8 +49,8 @@ module Hitcher
|
|
47
49
|
# handle host:docker ==> /home/xxx/dev:/opt/dev
|
48
50
|
ee = e.split(":")
|
49
51
|
m = Mount.new
|
50
|
-
m.host = translate(ee[0])
|
51
|
-
m.docker = ee[1]
|
52
|
+
m.host = translate(ee[0].strip)
|
53
|
+
m.docker = ee[1].strip
|
52
54
|
res << m
|
53
55
|
end
|
54
56
|
end
|
@@ -87,6 +89,8 @@ module Hitcher
|
|
87
89
|
# class Dockerfile
|
88
90
|
#
|
89
91
|
class Dockerfile
|
92
|
+
include Antrapol::ToolRack::ConditionUtils
|
93
|
+
|
90
94
|
attr_reader :cont
|
91
95
|
def parse(blc)
|
92
96
|
@cont = []
|
@@ -101,15 +105,45 @@ module Hitcher
|
|
101
105
|
end
|
102
106
|
|
103
107
|
elsif e.strip != "end"
|
104
|
-
@cont << e
|
108
|
+
@cont << translate(e.strip)
|
105
109
|
end
|
106
110
|
end
|
107
111
|
end
|
112
|
+
|
108
113
|
end
|
109
114
|
|
110
115
|
def is_empty?
|
111
116
|
@cont.nil? or @cont.empty?
|
112
117
|
end
|
118
|
+
|
119
|
+
private
|
120
|
+
def translate(line)
|
121
|
+
|
122
|
+
if not line.strip.empty?
|
123
|
+
if line =~ /\$USER/
|
124
|
+
line = line.gsub("$USER", user_info.name)
|
125
|
+
end
|
126
|
+
|
127
|
+
if line =~ /\$UID/
|
128
|
+
line = line.gsub("$UID", "#{user_info.uid}")
|
129
|
+
end
|
130
|
+
|
131
|
+
if line =~ /\$GID/
|
132
|
+
line = line.gsub("$GID", "#{user_info.gid}")
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
line
|
137
|
+
end
|
138
|
+
|
139
|
+
def user_info
|
140
|
+
if @userInfo.nil?
|
141
|
+
login = Etc.getlogin
|
142
|
+
@userInfo = Etc.getpwnam(login)
|
143
|
+
end
|
144
|
+
@userInfo
|
145
|
+
end
|
146
|
+
|
113
147
|
end # class Dockerfile
|
114
148
|
|
115
149
|
##
|
@@ -196,13 +230,14 @@ module Hitcher
|
|
196
230
|
|
197
231
|
te = Hitcher::Docker::TemplateEngine.new
|
198
232
|
|
199
|
-
if depth == :dockerfile or depth == :all and not @
|
233
|
+
if (depth == :dockerfile or depth == :all) and not @df.nil?
|
200
234
|
te.build_template(:dockerfile, { image: @image, dockerfile: @df.cont })
|
201
235
|
@logger.debug "Dockerfile generated"
|
202
236
|
end
|
203
237
|
|
204
238
|
if depth == :build_container or depth == :all
|
205
239
|
te.build_template(:build_container, { image_name: @image })
|
240
|
+
@logger.debug "build_container generated"
|
206
241
|
end
|
207
242
|
|
208
243
|
if depth == :run_script or depth == :all
|
@@ -15,7 +15,8 @@ module Hitcher
|
|
15
15
|
case temp
|
16
16
|
when :dockerfile
|
17
17
|
path = File.join(File.dirname(__FILE__),"templates","Dockerfile.erb")
|
18
|
-
|
18
|
+
ccont = val[:dockerfile].join("\n")
|
19
|
+
bind_template(path, File.join(dest_root,"Dockerfile"), { dockerfile_content: ccont } )
|
19
20
|
else
|
20
21
|
if Antrapol::ToolRack::RuntimeUtils.on_windows?
|
21
22
|
raise Hitcher::Error, "Not ready yet"
|
data/lib/hitcher/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Hitcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Liaw
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|