lib/dockly/deb.rb in dockly-1.3.5 vs lib/dockly/deb.rb in dockly-1.4.0
- old
+ new
@@ -90,11 +90,11 @@
add_files(@dir_package)
debug "converting to deb"
@deb_package = @dir_package.convert(FPM::Package::Deb)
- @deb_package.scripts[:before_install] = pre_install
+ @deb_package.scripts[:before_install] = compile_pre_install
@deb_package.scripts[:after_install] = post_install
@deb_package.scripts[:before_remove] = pre_uninstall
@deb_package.scripts[:after_remove] = post_uninstall
@deb_package.name = package_name
@@ -118,10 +118,11 @@
def add_docker(package)
return if docker.nil?
info "adding docker image"
docker.generate!
+ return unless docker.registry.nil?
package.attributes[:prefix] = docker.package_dir
Dir.chdir(File.dirname(docker.tar_path)) do
package.input(File.basename(docker.tar_path))
end
package.attributes[:prefix] = nil
@@ -134,8 +135,21 @@
package.attributes[:prefix] = file[:destination]
Dir.chdir(File.dirname(file[:source])) do
package.input(File.basename(file[:source]))
end
package.attributes[:prefix] = nil
+ end
+ end
+
+ def compile_pre_install
+ registry = !docker.nil? && docker.registry
+ if registry
+ [
+ pre_install,
+ "docker login -e '#{registry.email}' -p '$DOCKER_REGISTRY_PASSWORD' -u '#{registry.username}'",
+ "docker pull #{docker.repo}"
+ ].join("\n")
+ else
+ pre_install
end
end
end