luban 0.12.8 → 0.12.9
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/CHANGELOG.md +20 -0
- data/lib/luban/deployment/cli/application/base.rb +31 -4
- data/lib/luban/deployment/cli/application/configurator.rb +6 -0
- data/lib/luban/deployment/cli/application/docker/dockerable.rb +10 -0
- data/lib/luban/deployment/cli/application/docker/dockerizer.rb +28 -9
- data/lib/luban/deployment/cli/application/docker/templates/Dockerfile.erb +10 -4
- data/lib/luban/deployment/cli/application/docker/templates/docker-compose.yml.erb +4 -3
- data/lib/luban/deployment/cli/application/publisher.rb +8 -4
- data/lib/luban/deployment/cli/application/repository.rb +8 -6
- data/lib/luban/deployment/cli/package/base.rb +1 -1
- data/lib/luban/deployment/cli/package/installer/install.rb +6 -1
- data/lib/luban/deployment/cli/project.rb +2 -3
- data/lib/luban/deployment/cli/service/configurator.rb +16 -0
- data/lib/luban/deployment/cli/service/controller.rb +1 -0
- data/lib/luban/deployment/helpers/utils.rb +7 -0
- data/lib/luban/deployment/packages/git.rb +1 -1
- data/lib/luban/deployment/parameters.rb +7 -2
- data/lib/luban/deployment/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6dd440bc4925ab701d0ed20efac1bbbbfb47619d
|
|
4
|
+
data.tar.gz: 3a652f09e27d0af7700cbe8a20a24e036fa7c6ee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3ae27fdfc42619731ab379001e709c7961b67cce5e30c9d22c539f37c4057404e435cfa260d39e662487959e3bfd96c596aca9355640473e8fb10b3c90155724
|
|
7
|
+
data.tar.gz: b1eb78d08394460907d60d39bc74fd651142655acbbd7aa7d00577ad97acd299aedd710a9556c33351b63f1eb117899055b32c066bb6f7001c5a8dc64f3d82e2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Change log
|
|
2
2
|
|
|
3
|
+
## Version 0.12.9 (Mar 23, 2017)
|
|
4
|
+
|
|
5
|
+
Minor enhancements:
|
|
6
|
+
* Used Etc.getpwnam to retrieve current user id
|
|
7
|
+
* Speeded up bundle install gems with bundle jobs (default: 4)
|
|
8
|
+
* Added docker config parameters, #docker_workdir, #docker_entrypoint, #docker_command
|
|
9
|
+
* Applied the new docker config parameters in Dockerfile template
|
|
10
|
+
* Also, setup PATH properly instead of using environment resource file in Dockerfile template
|
|
11
|
+
* Added environment variables in docker-compose template
|
|
12
|
+
* Added util method, #cleanup_files, to manage retention of file copies like releases
|
|
13
|
+
* Upgraded dependency of Git on Curl to version 7.53.1
|
|
14
|
+
* Ensured environment dockerization occur if any dockerized components are changed
|
|
15
|
+
* Cleaned up dockerized archives properly
|
|
16
|
+
* Only install packages that are currently used during dockerization
|
|
17
|
+
* Only deploy releases that are currently used during dockerization
|
|
18
|
+
|
|
19
|
+
Bug fixes:
|
|
20
|
+
* Skipped uninstalling a given package if any other packages depends on it
|
|
21
|
+
* Skipped binstubs updates in package installation if the package is a dependence of another package
|
|
22
|
+
|
|
3
23
|
## Version 0.12.8 (Feb 23, 2017)
|
|
4
24
|
|
|
5
25
|
Bug fixes:
|
|
@@ -59,18 +59,45 @@ module Luban
|
|
|
59
59
|
def deployable?; true; end
|
|
60
60
|
def controllable?; has_source? or has_services?; end
|
|
61
61
|
|
|
62
|
-
def use_package?(package_name, package_version
|
|
63
|
-
package_name = package_name.to_sym
|
|
62
|
+
def use_package?(package_name, package_version)
|
|
64
63
|
packages.has_key?(package_name) and
|
|
65
|
-
packages[package_name].has_version?(package_version)
|
|
66
|
-
|
|
64
|
+
packages[package_name].has_version?(package_version)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def depend_on_package?(package_name, package_version)
|
|
68
|
+
!dependent_packages_for(package_name, package_version).empty?
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def dependent_packages_for(package_name, package_version)
|
|
72
|
+
packages.inject([]) do |dependent_pkgs, (pkg_name, pkg)|
|
|
73
|
+
if pkg.package_options.any? do |version, _|
|
|
74
|
+
pkg.class.required_packages_for(version).any? do |_, deps|
|
|
75
|
+
deps.any? { |dep| dep.name == package_name.to_s and dep.version == package_version }
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
dependent_pkgs << "#{display_name}.#{pkg_name}"
|
|
79
|
+
end
|
|
80
|
+
dependent_pkgs
|
|
81
|
+
end
|
|
67
82
|
end
|
|
68
83
|
|
|
69
84
|
def other_package_users_for(package_name, package_version, servers: [])
|
|
85
|
+
dependent_packages_for(package_name, package_version) |
|
|
70
86
|
find_project.package_users_for(package_name, package_version,
|
|
71
87
|
exclude: [name], servers: servers)
|
|
72
88
|
end
|
|
73
89
|
|
|
90
|
+
def package_users_for(package_name, package_version, servers: [])
|
|
91
|
+
package_users = []
|
|
92
|
+
if config.servers.any? { |s| servers.include?(s) }
|
|
93
|
+
if use_package?(package_name, package_version)
|
|
94
|
+
package_users << "#{display_name}.#{package_name}"
|
|
95
|
+
end
|
|
96
|
+
package_users |= dependent_packages_for(package_name, package_version)
|
|
97
|
+
end
|
|
98
|
+
package_users
|
|
99
|
+
end
|
|
100
|
+
|
|
74
101
|
def package(name, version:, **opts)
|
|
75
102
|
yield opts if block_given?
|
|
76
103
|
name = name.to_sym
|
|
@@ -28,6 +28,16 @@ module Luban
|
|
|
28
28
|
@default_docker_template_path ||= base_templates_path(__FILE__)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
+
def package(name, version:, **opts)
|
|
32
|
+
opts.merge!(deprecated: true) unless opts[:current]
|
|
33
|
+
super
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def release(version, **opts)
|
|
37
|
+
opts.merge!(deprecated: true) unless opts[:current]
|
|
38
|
+
super
|
|
39
|
+
end
|
|
40
|
+
|
|
31
41
|
protected
|
|
32
42
|
|
|
33
43
|
%i(setup! install_all! uninstall_all! destroy!
|
|
@@ -140,16 +140,21 @@ module Luban
|
|
|
140
140
|
end
|
|
141
141
|
|
|
142
142
|
def init_build_sources
|
|
143
|
+
# Init packages
|
|
143
144
|
sources = { packages: packages_path }
|
|
145
|
+
# Init releases
|
|
144
146
|
releases = get_releases(releases_path, type: 'app')
|
|
145
147
|
if releases.has_key?(:"app.bundler")
|
|
146
148
|
sources[:"app.bundler"] = releases.delete(:"app.bundler")
|
|
147
149
|
end
|
|
148
150
|
sources.merge!(releases)
|
|
151
|
+
# Init profile
|
|
149
152
|
profile_path = releases_path.dirname.join('profile')
|
|
150
153
|
profile = directory?(profile_path) ? get_releases(profile_path, type: 'profile') : {}
|
|
151
|
-
sources["env.#{stage}".to_sym] = app_path
|
|
152
154
|
sources.merge!(profile)
|
|
155
|
+
# Init environment
|
|
156
|
+
sources["env.#{stage}".to_sym] = app_path
|
|
157
|
+
|
|
153
158
|
sources.inject({}) do |srcs, (name, path)|
|
|
154
159
|
md5 = md5_for_dir(path)
|
|
155
160
|
srcs[name] = { path: path, md5: md5, tag: md5[0, revision_size] }
|
|
@@ -215,15 +220,29 @@ module Luban
|
|
|
215
220
|
end
|
|
216
221
|
|
|
217
222
|
def package_application!
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
:skipped
|
|
223
|
-
else
|
|
224
|
-
execute(:tar, "-cJf", archive[:path], source[:path]) ? :succeeded : :failed
|
|
225
|
-
end
|
|
223
|
+
changed = false
|
|
224
|
+
env_archive = "env.#{stage}".to_sym
|
|
225
|
+
build[:archives].each_key do |name|
|
|
226
|
+
changed = true if name != env_archive and package_archive!(name) == :succeeded
|
|
226
227
|
end
|
|
228
|
+
package_archive!(env_archive, force: changed)
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
def package_archive!(name, force: false)
|
|
232
|
+
source = build[:sources][name]
|
|
233
|
+
archive = build[:archives][name]
|
|
234
|
+
archive[:status] =
|
|
235
|
+
if !force and file?(archive[:path]) and archive[:path].basename.to_s =~ /#{source[:tag]}/
|
|
236
|
+
:skipped
|
|
237
|
+
else
|
|
238
|
+
execute(:tar, "-cJf", archive[:path], source[:path]) ? :succeeded : :failed
|
|
239
|
+
end.tap do |status|
|
|
240
|
+
cleanup_archive!(name) unless status == :failed
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
def cleanup_archive!(name)
|
|
245
|
+
cleanup_files(archive_file_path("#{name.to_s.gsub(/-\h+$/, '')}-*"))
|
|
227
246
|
end
|
|
228
247
|
|
|
229
248
|
def render_dockerfile
|
|
@@ -14,7 +14,6 @@ RUN yum -y install \
|
|
|
14
14
|
|
|
15
15
|
# Create luban user with the given uid
|
|
16
16
|
RUN adduser -ms /bin/bash -u $luban_uid $luban_user && \
|
|
17
|
-
echo "source <%= envrc_file %>" >> /home/$luban_user/.bashrc && \
|
|
18
17
|
mkdir -p $luban_root_path && \
|
|
19
18
|
chown -R $luban_user:$luban_user $luban_root_path
|
|
20
19
|
|
|
@@ -25,7 +24,7 @@ ADD <%= build[:archives].collect { |_, a| a[:path].basename }.join(" \\\n ")
|
|
|
25
24
|
|
|
26
25
|
# Populate image labels
|
|
27
26
|
LABEL luban.project="<%= project %>" \
|
|
28
|
-
luban.application="<%=
|
|
27
|
+
luban.application="<%= application %>" \
|
|
29
28
|
luban.stage="<%= stage %>" \
|
|
30
29
|
<%- build[:sources].each_pair do |name, source| -%>
|
|
31
30
|
luban.<%= name %>.source_tag="<%= source[:tag] %>" \
|
|
@@ -42,6 +41,13 @@ LABEL luban.project="<%= project %>" \
|
|
|
42
41
|
luban.luban_root_path="$luban_root_path"
|
|
43
42
|
|
|
44
43
|
USER $luban_user
|
|
45
|
-
WORKDIR
|
|
44
|
+
WORKDIR <%= docker_workdir %>
|
|
46
45
|
|
|
47
|
-
|
|
46
|
+
ENV PATH=<%= app_bin_path %>:$PATH
|
|
47
|
+
|
|
48
|
+
<% unless docker_entrypoint.empty? -%>
|
|
49
|
+
ENTRYPOINT <%= docker_entrypoint.inspect %>
|
|
50
|
+
<% end -%>
|
|
51
|
+
<% unless docker_command.empty? -%>
|
|
52
|
+
CMD <%= docker_command.inspect %>
|
|
53
|
+
<% end -%>
|
|
@@ -11,6 +11,7 @@ services:
|
|
|
11
11
|
image: <%= build[:image_tag] %>
|
|
12
12
|
environment:
|
|
13
13
|
TZ: <%= timezone %>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
<%- env_vars.each_pair do |name, value| -%>
|
|
15
|
+
<%= name.upcase %>: <%= value %>
|
|
16
|
+
<%- end -%>
|
|
17
|
+
command: <%= docker_command %>
|
|
@@ -4,6 +4,8 @@ module Luban
|
|
|
4
4
|
class Publisher < Worker
|
|
5
5
|
include Luban::Deployment::Helpers::LinkedPaths
|
|
6
6
|
|
|
7
|
+
DefaultBundleJobs = Luban::Deployment::Application::Repository::DefaultBundleJobs
|
|
8
|
+
|
|
7
9
|
def release_type; task.opts.release_pack[:type]; end
|
|
8
10
|
def release_version; task.opts.release_pack[:version]; end
|
|
9
11
|
def release_tag; task.opts.release_pack[:tag]; end
|
|
@@ -49,6 +51,10 @@ module Luban
|
|
|
49
51
|
@bundle_flags ||= %w(--deployment --quiet)
|
|
50
52
|
end
|
|
51
53
|
|
|
54
|
+
def bundle_jobs
|
|
55
|
+
@bundle_jobs ||= DefaultBundleJobs
|
|
56
|
+
end
|
|
57
|
+
|
|
52
58
|
def bundle_linked_dirs
|
|
53
59
|
@bundle_linked_dirs ||= %w(.bundle vendor/cache vendor/bundle)
|
|
54
60
|
end
|
|
@@ -142,10 +148,7 @@ module Luban
|
|
|
142
148
|
end
|
|
143
149
|
|
|
144
150
|
def cleanup_releases(keep_releases = 1)
|
|
145
|
-
|
|
146
|
-
if files.count > keep_releases
|
|
147
|
-
files.last(files.count - keep_releases).each { |f| rmdir(f) }
|
|
148
|
-
end
|
|
151
|
+
cleanup_files(releases_path.join("#{release_version}-*"), keep_copies: keep_releases)
|
|
149
152
|
end
|
|
150
153
|
|
|
151
154
|
def cleanup_app_releases; cleanup_releases(5); end
|
|
@@ -189,6 +192,7 @@ module Luban
|
|
|
189
192
|
options << "--without #{bundle_without.join(' ')}"
|
|
190
193
|
end
|
|
191
194
|
options << bundle_flags.join(' ')
|
|
195
|
+
options << "--jobs #{bundle_jobs}"
|
|
192
196
|
if (output = capture(bundle_executable, :install, *options)).empty?
|
|
193
197
|
info "Successfully deployed bundled gems"
|
|
194
198
|
else
|
|
@@ -5,6 +5,7 @@ module Luban
|
|
|
5
5
|
using Luban::CLI::CoreRefinements
|
|
6
6
|
include Luban::Deployment::Worker::Paths::Local
|
|
7
7
|
|
|
8
|
+
DefaultBundleJobs = 4
|
|
8
9
|
DefaultRevisionSize = 12
|
|
9
10
|
|
|
10
11
|
attr_reader :type
|
|
@@ -76,6 +77,10 @@ module Luban
|
|
|
76
77
|
@bundle_without ||= %w(development test)
|
|
77
78
|
end
|
|
78
79
|
|
|
80
|
+
def bundle_jobs
|
|
81
|
+
@bundle_jobs ||= DefaultBundleJobs
|
|
82
|
+
end
|
|
83
|
+
|
|
79
84
|
# Description on abstract methods:
|
|
80
85
|
# available?: check if the remote repository is available
|
|
81
86
|
# cloned?: check if the remote repository is cloned locally
|
|
@@ -167,11 +172,8 @@ module Luban
|
|
|
167
172
|
end
|
|
168
173
|
|
|
169
174
|
def cleanup_releases(keep_releases = 1)
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
if files.count > keep_releases
|
|
173
|
-
files.last(files.count - keep_releases).each { |f| rm(f) }
|
|
174
|
-
end
|
|
175
|
+
cleanup_files(releases_path.join("#{release_prefix}-#{version}-*.#{release_package_extname}"),
|
|
176
|
+
keep_copies: keep_releases)
|
|
175
177
|
end
|
|
176
178
|
|
|
177
179
|
def release_with_gemfile?(gemfile_path)
|
|
@@ -202,7 +204,7 @@ module Luban
|
|
|
202
204
|
unless bundle_without.include?(stage.to_s)
|
|
203
205
|
options << "--without #{bundle_without.join(' ')}"
|
|
204
206
|
end
|
|
205
|
-
options << "--quiet"
|
|
207
|
+
options << "--jobs #{bundle_jobs} --quiet"
|
|
206
208
|
if (output = capture(bundle_cmd, :install, *options)).empty?
|
|
207
209
|
info "Successfully bundled gems in Gemfile"
|
|
208
210
|
else
|
|
@@ -149,7 +149,7 @@ module Luban
|
|
|
149
149
|
if apps.empty? or opts[:force]
|
|
150
150
|
uninstall!(args: args, opts: opts)
|
|
151
151
|
else
|
|
152
|
-
puts "Skipped
|
|
152
|
+
puts " Skipped! #{name}-#{opts[:version]} is being used by #{apps.join(', ')}. " +
|
|
153
153
|
"use -f to force uninstalling if necessary."
|
|
154
154
|
end
|
|
155
155
|
end
|
|
@@ -88,7 +88,11 @@ module Luban
|
|
|
88
88
|
update_result "#{package_full_name} is uninstalled. "
|
|
89
89
|
end
|
|
90
90
|
else
|
|
91
|
-
message =
|
|
91
|
+
message = if deprecated?
|
|
92
|
+
"#{package_full_name} has been deprecated."
|
|
93
|
+
else
|
|
94
|
+
"#{package_full_name} is NOT installed."
|
|
95
|
+
end
|
|
92
96
|
if directory?(install_path) or directory?(build_path)
|
|
93
97
|
if force?
|
|
94
98
|
uninstall!
|
|
@@ -137,6 +141,7 @@ module Luban
|
|
|
137
141
|
end
|
|
138
142
|
|
|
139
143
|
def update_binstubs
|
|
144
|
+
return if child?
|
|
140
145
|
if current?
|
|
141
146
|
if installed?
|
|
142
147
|
update_binstubs!
|
|
@@ -14,9 +14,8 @@ module Luban
|
|
|
14
14
|
|
|
15
15
|
def package_users_for(package_name, package_version, exclude: [], servers: [])
|
|
16
16
|
apps.values.inject([]) do |package_users, app|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
package_users << app.display_name
|
|
17
|
+
unless exclude.include?(app.name)
|
|
18
|
+
package_users |= app.package_users_for(package_name, package_version, servers: servers)
|
|
20
19
|
end
|
|
21
20
|
package_users
|
|
22
21
|
end
|
|
@@ -56,6 +56,22 @@ module Luban
|
|
|
56
56
|
|
|
57
57
|
protected
|
|
58
58
|
|
|
59
|
+
def init
|
|
60
|
+
super
|
|
61
|
+
if dockerized?
|
|
62
|
+
init_docker_workdir
|
|
63
|
+
init_docker_entrypoint
|
|
64
|
+
init_docker_command
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def init_docker_workdir
|
|
69
|
+
docker_workdir app_path
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def init_docker_entrypoint; end
|
|
73
|
+
def init_docker_command; end
|
|
74
|
+
|
|
59
75
|
def upload_profile_templates(templates, dirs: Pathname.new(''), depth: 2)
|
|
60
76
|
indent = ' ' * depth
|
|
61
77
|
templates.each do |src_path|
|
|
@@ -104,6 +104,13 @@ module Luban
|
|
|
104
104
|
capture(:find, "#{dir} -type f ! -name '*.md5' 2>/dev/null | LC_ALL=C sort -u | xargs cat | $(type -p md5sum md5 | head -1)")[/^\h+/]
|
|
105
105
|
end
|
|
106
106
|
|
|
107
|
+
def cleanup_files(path, keep_copies: 1)
|
|
108
|
+
files = capture(:ls, '-xtd', path).split(" ")
|
|
109
|
+
if files.count > keep_copies
|
|
110
|
+
files.last(files.count - keep_copies).each { |f| execute(:rm, '-fr', f) }
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
107
114
|
def sudo(*args)
|
|
108
115
|
execute(:sudo, *args)
|
|
109
116
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'etc'
|
|
2
|
+
|
|
1
3
|
module Luban
|
|
2
4
|
module Deployment
|
|
3
5
|
module Parameters
|
|
@@ -31,7 +33,7 @@ module Luban
|
|
|
31
33
|
end
|
|
32
34
|
|
|
33
35
|
def current_uid
|
|
34
|
-
|
|
36
|
+
Etc.getpwnam(current_user).uid
|
|
35
37
|
end
|
|
36
38
|
|
|
37
39
|
parameter :luban_roles, default: %i(app)
|
|
@@ -44,7 +46,7 @@ module Luban
|
|
|
44
46
|
parameter :work_dir
|
|
45
47
|
parameter :apps_path
|
|
46
48
|
parameter :project
|
|
47
|
-
parameter :user, default: ->
|
|
49
|
+
parameter :user, default: ->{ current_user }
|
|
48
50
|
parameter :author
|
|
49
51
|
parameter :config_finder, default: ->{ Hash.new }
|
|
50
52
|
|
|
@@ -128,6 +130,9 @@ module Luban
|
|
|
128
130
|
parameter :base_image, default: 'centos:7'
|
|
129
131
|
parameter :timezone, default: 'UTC'
|
|
130
132
|
parameter :base_packages, default: ->{ Array.new }
|
|
133
|
+
parameter :docker_workdir, default: '/home/$luban_user'
|
|
134
|
+
parameter :docker_entrypoint, default: ->{ Array.new }
|
|
135
|
+
parameter :docker_command, default: ->{ ["/bin/bash"] }
|
|
131
136
|
parameter :docker_tls_verify, default: false
|
|
132
137
|
parameter :docker_cert_path
|
|
133
138
|
parameter :docker_tcp_port
|
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.
|
|
4
|
+
version: 0.12.9
|
|
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-
|
|
11
|
+
date: 2017-03-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: luban-cli
|