luban 0.12.2 → 0.12.3

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: 0c7460f351021d4c9a37aeef66df70d3cc966a7f
4
- data.tar.gz: 1d097ba20fd8491657825d1cc53f8f9db5ba0dc5
3
+ metadata.gz: 4a2c52afba7ac1fc8e47eed104a2318e486b66a6
4
+ data.tar.gz: 59f6cc14a8d580e5559e42d53fd4ee66b5efb5ef
5
5
  SHA512:
6
- metadata.gz: 6d2371d009d05e2beaa52527becc015abcaee904e9b58e7a1c94c2d15e70b3e1bf210bdca80949e0257abde9dbe9276639c29359e19c95daa3c8124b70566f36
7
- data.tar.gz: 32f3a5145815112420ab69db4134bdf2361bcedb2b6d26a3f3bf7bb23f5711a91ef1761c1684884b7b0c82362d8d400a5c197b8cce5e55123c56fea9b5601ed7
6
+ metadata.gz: 1ef8f2405f5422b2febace4dbc866c35f39789d98613ae526dffdb304c67a021cde884f38ddcb29689cc1af6793825fca04c4e9498e5e89f3dea4a05c81fdee6
7
+ data.tar.gz: 3f01d09888adc71fb2a628e1ac664bf3084b553ad73bd7e364d7ef56fa88ed925a088f737701b2674637c4ffc33e926e086ede94e7fcb348d95ea68198e7c8c4
data/CHANGELOG.md CHANGED
@@ -1,12 +1,21 @@
1
1
  # Change log
2
2
 
3
- ## Version 0.12.2 (Feb 13, 2017)
3
+ ## Version 0.12.3 (Feb 15, 2017)
4
+
5
+ Minor enhancements:
6
+ * Added labels in docker image to show info about installed packages
7
+ * Added new parameter, #luban_uid, to specify user id for luban user
8
+ * This is mainly to address the permission issues on docker volumes
9
+ * Refactored luban_user and luban_uid as build arguments
10
+ * Used environment variable TZ to correctly control the timezone for a docker container
4
11
 
5
12
  Bug fixes:
6
13
  * Correctly composed revisions for build sources
7
14
  * Fixed a typo in the template of Dockerfile.erb
8
15
  * Checked the result of bundle install/package in Repository before proceeding to the rest steps
9
16
  * Checked the result of bundle install in Publisher before proceeding to the rest steps
17
+ * Removed redundant add commands in Dockerfile.erb
18
+ * Added proper prefix of build sources in dockerization
10
19
 
11
20
  ## Version 0.12.1 (Feb 09, 2017)
12
21
 
@@ -141,14 +141,14 @@ module Luban
141
141
 
142
142
  def init_build_sources
143
143
  sources = { packages: packages_path }
144
- releases = get_releases(releases_path)
145
- if (v = releases.delete(:vendor))
146
- sources[:vendor] = v
144
+ releases = get_releases(releases_path, type: 'app')
145
+ if releases.has_key?(:"app.vendor")
146
+ sources[:"app.vendor"] = releases.delete(:"app.vendor")
147
147
  end
148
148
  sources.merge!(releases)
149
149
  profile_path = releases_path.dirname.join('profile')
150
- profile = directory?(profile_path) ? get_releases(profile_path) : {}
151
- sources[stage.to_sym] = app_path
150
+ profile = directory?(profile_path) ? get_releases(profile_path, type: 'profile') : {}
151
+ sources["env.#{stage}".to_sym] = app_path
152
152
  sources.merge!(profile)
153
153
  sources.inject({}) do |srcs, (name, path)|
154
154
  md5 = md5_for_dir(path)
@@ -187,10 +187,22 @@ module Luban
187
187
  def compose_file; build[:path].join("docker-compose.yml"); end
188
188
  def compose_env_file; build[:path].join(".env"); end
189
189
 
190
- def get_releases(path)
190
+ def get_releases(path, type:)
191
191
  capture(:ls, '-xtd', path.join('*')).split.
192
192
  collect { |p| File.basename(p) }.
193
- inject({}) { |r, t| r[t.to_sym] = path.join(t); r }
193
+ inject({}) { |r, t| r["#{type}.#{t}".to_sym] = path.join(t); r }
194
+ end
195
+
196
+ def get_packages
197
+ packages.inject({}) do |pkgs, (name, package)|
198
+ pkgs[name] = package.class.required_packages_for(package.current_version).inject(
199
+ { versions: package.installable_versions.join(', '),
200
+ current_version: package.current_version }) do |pkg, (type, deps)|
201
+ deps.each { |d| pkg["#{type}.#{d.name}".to_sym] = d.version }
202
+ pkg
203
+ end
204
+ pkgs
205
+ end
194
206
  end
195
207
 
196
208
  def dockerize_application!
@@ -1,16 +1,13 @@
1
1
  FROM <%= base_image %>
2
2
  MAINTAINER <%= author['name'] %> <%= author['email'].inspect %>
3
3
 
4
- RUN adduser -ms /bin/bash <%= luban_user %> && \
5
- mkdir <%= luban_root_path %> && \
6
- chown -R <%= luban_user %>:<%= luban_user %> <%= luban_root_path %>
7
-
8
- <% build[:archives].each_value do |archive| -%>
9
- ADD <%= archive[:path].basename %> /
10
- <% end -%>
4
+ ARG luban_uid
5
+ ARG luban_user
11
6
 
12
- RUN ln -sf /usr/share/zoneinfo/<%= timezone %> /etc/localtime && \
13
- echo "source <%= envrc_file %>" >> /home/<%= luban_user %>/.bashrc
7
+ RUN adduser -ms /bin/bash -u $luban_uid $luban_user && \
8
+ mkdir <%= luban_root_path %> && \
9
+ chown -R $luban_user:$luban_user <%= luban_root_path %> && \
10
+ echo "source <%= envrc_file %>" >> /home/$luban_user/.bashrc
14
11
 
15
12
  <% build[:archives].each_value do |archive| -%>
16
13
  ADD <%= archive[:path].basename %> /
@@ -20,14 +17,20 @@ LABEL luban.project="<%= project %>" \
20
17
  luban.application="<%= project %>" \
21
18
  luban.stage="<%= stage %>" \
22
19
  <%- build[:sources].each_pair do |name, source| -%>
23
- luban.<%= name %>_tag="<%= source[:tag] %>" \
20
+ luban.<%= name %>.source_tag="<%= source[:tag] %>" \
24
21
  <%- end -%>
25
22
  luban.build_tag="<%= build_tag %>" \
26
23
  luban.bulid_rev="<%= build[:revision] %>" \
27
- luban.luban_user="<%= luban_user %>" \
24
+ <%- get_packages.each_pair do |name, package| -%>
25
+ <%- package.each_pair do |k, v| -%>
26
+ luban.packages.<%= name %>.<%= k %>="<%= v %>" \
27
+ <%- end -%>
28
+ <%- end -%>
29
+ luban.luban_uid="$luban_uid" \
30
+ luban.luban_user="$luban_user" \
28
31
  luban.luban_root_path="<%= luban_root_path %>"
29
32
 
30
- USER <%= luban_user %>
31
- WORKDIR /home/<%= luban_user %>
33
+ USER $luban_user
34
+ WORKDIR /home/$luban_user
32
35
 
33
36
  CMD ["/bin/bash"]
@@ -1 +1,3 @@
1
- COMPOSE_PROJECT_NAME="<%= project %>"
1
+ LUBAN_UID=<%= luban_uid %>
2
+ LUBAN_USER=<%= luban_user %>
3
+ COMPOSE_PROJECT_NAME=<%= project %>
@@ -2,8 +2,14 @@ version: "3"
2
2
 
3
3
  services:
4
4
  <%= application %>:
5
- build: ./context
5
+ build:
6
+ context: ./context
7
+ args:
8
+ luban_uid: $LUBAN_UID
9
+ luban_user: $LUBAN_USER
6
10
  image: <%= build[:image_tag] %>
11
+ environment:
12
+ TZ: <%= timezone %>
7
13
  entrypoint: /bin/bash
8
14
  stdin_open: true
9
15
  tty: true
@@ -27,7 +27,11 @@ module Luban
27
27
  end
28
28
 
29
29
  def current_user
30
- ENV['USER'] || `whoami`.chomp
30
+ ENV['USER'] || `whoami 2>/dev/null`.chomp
31
+ end
32
+
33
+ def current_uid
34
+ `id -u #{current_user} 2>/dev/null`.chomp
31
35
  end
32
36
 
33
37
  parameter :luban_roles, default: %i(app)
@@ -118,7 +122,8 @@ module Luban
118
122
  module Docker
119
123
  extend Base
120
124
 
121
- parameter :luban_user, default: 'luban'
125
+ parameter :luban_uid, default: ->{ current_uid }
126
+ parameter :luban_user, default: ->{ current_user }
122
127
  parameter :build_tag, default: '0.0.0'
123
128
  parameter :base_image, default: 'centos:7'
124
129
  parameter :timezone, default: 'UTC'
@@ -1,5 +1,5 @@
1
1
  module Luban
2
2
  module Deployment
3
- VERSION = "0.12.2"
3
+ VERSION = "0.12.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luban
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.2
4
+ version: 0.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rubyist Lei
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-12 00:00:00.000000000 Z
11
+ date: 2017-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: luban-cli