dockersitter 0.6.0 → 0.7.0
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/lib/commands/create.rb +16 -20
- data/lib/commands/init.rb +23 -3
- data/lib/docker_mgr/version.rb +1 -1
- data/lib/templates/Dockerfile.erb +4 -1
- data/lib/templates/admin/installation_scripts/install_curl.sh +3 -0
- data/lib/templates/admin/trust.sh +12 -0
- data/lib/util.rb +19 -14
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce908ad9ece66790ea14cee9c0521058e856de75
|
4
|
+
data.tar.gz: 6725a7bbf1c16a1fbb877e06ff42a1bc3eb862e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f7d05560345c1a52464c36720b96476932407f96381f0f31f395880f617b8cbba819c977cb95c6ff98f9816e26fb6abc65e7ec023418706d4d4d757ade9f529
|
7
|
+
data.tar.gz: 290b08eef9ff70812e5eb03133e742f44520e4afd99840a46851c8941581297c2bacfc8fcff518b5acd656c752f99bee5123d86b8ebb00dcef32c1d50b2f3de4
|
data/lib/commands/create.rb
CHANGED
@@ -15,7 +15,7 @@ class Create < Thor
|
|
15
15
|
:type => :string,
|
16
16
|
:desc => "the image which the app is based on.",
|
17
17
|
:aliases => 'b',
|
18
|
-
:default => "
|
18
|
+
:default => "base:1.0"
|
19
19
|
|
20
20
|
class_option :env,
|
21
21
|
:type => :array,
|
@@ -31,27 +31,19 @@ class Create < Thor
|
|
31
31
|
|
32
32
|
|
33
33
|
desc "app APP_NAME", "create a new app."
|
34
|
-
option :dockerfile,
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
:aliases => 'v',
|
42
|
-
:default => ["/var"]
|
43
|
-
option :cert,
|
44
|
-
:desc => "creates a ssl certificate for this app",
|
45
|
-
:aliases => 'c'
|
46
|
-
option :subdomain,
|
47
|
-
:desc => "the subdomain for this app",
|
48
|
-
:type => :string
|
49
|
-
|
34
|
+
option :dockerfile,:type => :boolean,
|
35
|
+
:desc => 'create a dockerfile for the app',:aliases => 'd'
|
36
|
+
option :volumes,:type => :array,
|
37
|
+
:desc => 'the volumes your data-container will mount',:aliases => 'v',
|
38
|
+
:default => ["/var"]
|
39
|
+
option :cert,:desc => "creates a ssl certificate for this app",:aliases =>'c'
|
40
|
+
option :subdomain,:desc => "the subdomain for this app",:type => :string
|
50
41
|
def app(app_name)
|
51
42
|
subdomain = options.fetch(subdomain,app_name.gsub(/\s/,"-").downcase)
|
52
43
|
@domain = "#{subdomain}.#{config[:host]}"
|
53
44
|
@app_name = app_name
|
54
45
|
@user_email,@user_name = config.values_at(:email,:name)
|
46
|
+
@base = options[:base]
|
55
47
|
app_path = "#{apps_dir}/#{@app_name}"
|
56
48
|
template "docker-compose.yml.erb","#{app_path}/docker-compose.yml"
|
57
49
|
empty_directory "#{app_path}/administration/installation"
|
@@ -70,19 +62,20 @@ class Create < Thor
|
|
70
62
|
|
71
63
|
end
|
72
64
|
append_to_file "#{routine_dir}/backup_routine", "docker_mgr backup_app #{app_name}"
|
73
|
-
create_file "#{vhost_dir}/#{
|
65
|
+
create_file "#{vhost_dir}/#{@domain}"
|
74
66
|
if options[:cert]
|
75
67
|
FileUtils.cd "#{admin_dir}/ca" do
|
76
68
|
puts "#{admin_dir}/ca/sign.sh"
|
77
69
|
puts `./sign.sh #{@domain}`
|
78
70
|
end
|
71
|
+
chmod "#{proxy_dir}/certs/#{@domain}.key",0600
|
79
72
|
end
|
80
73
|
end
|
81
74
|
|
82
75
|
desc "image IMAGE_NAME","creates a new image."
|
83
76
|
def image(image_name)
|
84
|
-
@user_email =
|
85
|
-
@
|
77
|
+
@user_email,@user_name = config.values_at(:email,:name)
|
78
|
+
@base = options[:base]
|
86
79
|
image_path = "#{base_images_dir}/#{image_name}/v1.0"
|
87
80
|
empty_directory "#{image_path}/administration/installation"
|
88
81
|
template "Dockerfile.erb","#{image_path}/Dockerfile"
|
@@ -94,6 +87,9 @@ class Create < Thor
|
|
94
87
|
|
95
88
|
FileUtils.cp("#{install_dir}/scriptrunner.sh",
|
96
89
|
"#{image_path}/administration/scriptrunner.sh")
|
90
|
+
FileUtils.cp("#{admin_dir}/trust.sh",
|
91
|
+
"#{image_path}/administration/trust.sh")
|
92
|
+
empty_directory("#{image_path}/administration/certificates")
|
97
93
|
end
|
98
94
|
@image_name = image_name
|
99
95
|
@version = "1.0"
|
data/lib/commands/init.rb
CHANGED
@@ -5,7 +5,7 @@ require 'util'
|
|
5
5
|
class Init < Thor::Group
|
6
6
|
include Thor::Actions
|
7
7
|
include DockerMgr::Util
|
8
|
-
|
8
|
+
|
9
9
|
def self.source_root
|
10
10
|
File.expand_path('../templates',__dir__)
|
11
11
|
end
|
@@ -27,9 +27,29 @@ class Init < Thor::Group
|
|
27
27
|
chmod 'docker/admin/ca/sign.sh',0755
|
28
28
|
puts `git init docker`
|
29
29
|
FileUtils.cd 'docker' do
|
30
|
-
puts FileUtils.pwd
|
31
30
|
generate_ca_installer
|
31
|
+
image_name = 'base'
|
32
|
+
@user_email,@user_name = config.values_at(:email,:name)
|
33
|
+
image_path = "#{base_images_dir}/#{image_name}/v1.0"
|
34
|
+
empty_directory "#{image_path}/administration/installation"
|
35
|
+
@base = "ubuntu:14.04"
|
36
|
+
template "Dockerfile.erb","#{image_path}/Dockerfile"
|
37
|
+
%w(curl git).each do |package|
|
38
|
+
FileUtils.cp("#{install_dir}/install_#{package}.sh",
|
39
|
+
"#{image_path}/administration/installation/install_#{package}.sh")
|
40
|
+
end
|
41
|
+
|
42
|
+
FileUtils.cp("#{install_dir}/scriptrunner.sh",
|
43
|
+
"#{image_path}/administration/scriptrunner.sh")
|
44
|
+
FileUtils.cp("#{admin_dir}/trust.sh","#{image_path}/administration/trust.sh")
|
45
|
+
FileUtils.mkdir("#{image_path}/administration/certificates")
|
46
|
+
FileUtils.cp("#{admin_dir}/ca/rootCA.crt","#{image_path}/administration/certificates/rootCA.crt")
|
47
|
+
@image_name = image_name
|
48
|
+
@version = "1.0"
|
49
|
+
template "build.erb", "#{image_path}/build.sh"
|
50
|
+
FileUtils.chmod 0755, "#{image_path}/build.sh"
|
32
51
|
end
|
33
|
-
end
|
34
52
|
|
53
|
+
|
54
|
+
end
|
35
55
|
end
|
data/lib/docker_mgr/version.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
-
FROM
|
1
|
+
FROM <%=@base%>
|
2
2
|
MAINTAINER <%=@user_name%> <<%=@user_email%>>
|
3
3
|
ADD administration/installation /tmp/installation_scripts
|
4
4
|
ADD administration/scriptrunner.sh /tmp/scriptrunner.sh
|
5
5
|
RUN chmod +x /tmp/scriptrunner.sh && /bin/bash /tmp/scriptrunner.sh /tmp/installation_scripts
|
6
|
+
ADD administration/certificates /tmp/certificates
|
7
|
+
ADD administration/trust.sh /tmp/trust.sh
|
8
|
+
RUN chmod +x /tmp/trust.sh && /bin/bash /tmp/trust.sh /tmp/certificates
|
6
9
|
RUN rm -rf /tmp/*
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
distribution=$(find /etc/*-release -type f | xargs cat | grep 'ID' | head -n1 | awk -F'=' '{gsub(/"/,"",$2); print tolower($2)}')
|
4
|
+
case $distribution in
|
5
|
+
debian|ubuntu|linuxmint*|elementary*)
|
6
|
+
sudo mkdir -p /usr/local/share/ca-certificates
|
7
|
+
sudo cp $1/* /usr/local/share/ca-certificates/
|
8
|
+
sudo update-ca-certificates;;
|
9
|
+
fedora|centos)
|
10
|
+
sudo cp $1 /etc/pki/ca-trust/source/anchors/*
|
11
|
+
sudo update-ca-trust;;
|
12
|
+
esac
|
data/lib/util.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'fileutils'
|
3
|
+
require 'pathname'
|
3
4
|
|
4
5
|
module DockerMgr
|
5
6
|
|
@@ -7,17 +8,21 @@ module DockerMgr
|
|
7
8
|
|
8
9
|
def root_dir
|
9
10
|
return @root_dir if @root_dir
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
search_dir = Dir.pwd
|
12
|
+
while search_dir && !root_dir_condition(search_dir)
|
13
|
+
parent = File.dirname(search_dir)
|
14
|
+
# project_root wird entweder der Root-pfad oder false. Wenn es false
|
15
|
+
# wird, bricht die Schleife ab. Vgl. Rails
|
16
|
+
search_dir = (parent != search_dir) && parent
|
17
|
+
end
|
18
|
+
project_root = search_dir if root_dir_condition(search_dir)
|
19
|
+
raise 'you are not within a presentation-project.' unless project_root
|
20
|
+
@root_dir = Pathname.new(File.realpath project_root)
|
18
21
|
end
|
19
22
|
|
20
|
-
|
23
|
+
def root_dir_condition(search_dir)
|
24
|
+
search_dir.is_a?(String) && search_dir.end_with?("/docker") && (Dir.entries(search_dir) && %w{admin backup apps}).length == 3
|
25
|
+
end
|
21
26
|
|
22
27
|
def backup_dir
|
23
28
|
"#{root_dir}/backup"
|
@@ -53,7 +58,7 @@ module DockerMgr
|
|
53
58
|
end
|
54
59
|
|
55
60
|
|
56
|
-
|
61
|
+
|
57
62
|
def cert_dir
|
58
63
|
"#{proxy_dir}/ca_certs"
|
59
64
|
end
|
@@ -85,18 +90,18 @@ module DockerMgr
|
|
85
90
|
|
86
91
|
def service_hooks_for(app_name,type)
|
87
92
|
Dir.entries("#{apps_dir}/#{app_name}/administration/hooks/#{type}.d")
|
88
|
-
|
93
|
+
.select {| entry | !entry.start_with?(".") && entry != "before_all" && entry != "after_all" }
|
89
94
|
end
|
90
95
|
|
91
96
|
def services(app_name)
|
92
97
|
YAML.load(File.read("#{apps_dir}/#{app_name}/docker-compose.yml"))
|
93
|
-
|
94
|
-
|
98
|
+
.each_key
|
99
|
+
.select {|k| !k.end_with?("data")}
|
95
100
|
end
|
96
101
|
|
97
102
|
def data_services(app_name)
|
98
103
|
YAML.load(File.read("#{apps_dir}/#{app_name}/docker-compose.yml")).each_key
|
99
|
-
|
104
|
+
.select {|k| k.end_with?("data")}
|
100
105
|
end
|
101
106
|
|
102
107
|
def volumes(app_name,service_name)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dockersitter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rene Richter
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- lib/templates/admin/ca/sign.sh
|
137
137
|
- lib/templates/admin/examples/postgres_backup
|
138
138
|
- lib/templates/admin/examples/postgres_restore
|
139
|
+
- lib/templates/admin/installation_scripts/install_curl.sh
|
139
140
|
- lib/templates/admin/installation_scripts/install_derby.sh
|
140
141
|
- lib/templates/admin/installation_scripts/install_git.sh
|
141
142
|
- lib/templates/admin/installation_scripts/install_glassfish.sh
|
@@ -144,6 +145,7 @@ files:
|
|
144
145
|
- lib/templates/admin/installation_scripts/install_rust.sh
|
145
146
|
- lib/templates/admin/installation_scripts/scriptrunner.sh
|
146
147
|
- lib/templates/admin/routines/backup_routine
|
148
|
+
- lib/templates/admin/trust.sh
|
147
149
|
- lib/templates/after_all.erb
|
148
150
|
- lib/templates/after_all_restore.erb
|
149
151
|
- lib/templates/backup.erb
|