dockersitter 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bbf8d43dbdf2221bbab4224b15d05252b8bc955e
4
- data.tar.gz: b5596adf47c474f88c727f92908626680af49233
3
+ metadata.gz: 0d646c9d7f08f2815560d95a646601eb2301456c
4
+ data.tar.gz: fc5c05e4a5d88c75a0b0382cc9998af711921e90
5
5
  SHA512:
6
- metadata.gz: df14044e28ecc1c421e62b36afde6287c1df3cdf9201b652064b46d5a2941c14e28376c9f243d4a6bcd7afabff45077b4c13f9aab46ea80457e5ba4aa5fc3e31
7
- data.tar.gz: 8a034266932073b381cf2d3d3c9393e949960a2d4d7600e22a45766a39281e81ec9a7440a16bd811b4a2420dc971dba961b34ded282f43b777767d5c04566dbd
6
+ metadata.gz: 6b34336aa58dea1b12d07a3996df6e04eb3804994a706cbd20690ef775c5d67f9b3589f7ce6b51ccb1f9375697d55f1c0e9caa1a9e10621900b35edfbd2879e9
7
+ data.tar.gz: 4dca11d8663e2384aacf72aeea88dd7ba6bc222df0bae6d5ef1f72f99f7c8f42dc2a6c04be634bca1031fc45d192c6269be6e4518894bf8d71b21ee64ee37415
@@ -6,6 +6,7 @@ require 'commands/generate_backup_scripts'
6
6
  require 'commands/backup_app.rb'
7
7
  require 'commands/restore_app.rb'
8
8
  require 'commands/start.rb'
9
+ require 'commands/increment.rb'
9
10
  require 'util'
10
11
  require 'fileutils'
11
12
 
@@ -20,6 +21,6 @@ module CommandRouter
20
21
  register BackupApp,'backup','backup','creates a backup of the given app.'
21
22
  register RestoreApp, 'restore','restore','restores an app.'
22
23
  register Start, 'start','start','starts one or multiple apps. If no apps are given, all apps will be started.'
23
-
24
+ register Increment, 'increment','increment','increments the version of an image.'
24
25
  end
25
26
  end
@@ -11,35 +11,35 @@ class Create < Thor
11
11
  File.expand_path('../templates',__dir__)
12
12
  end
13
13
 
14
- class_option :image,
14
+ option :base,
15
15
  :type => :string,
16
16
  :desc => "the image which the app is based on.",
17
- :alias => 'i',
17
+ :aliases => 'b',
18
18
  :default => "ubuntu:14.04"
19
19
 
20
20
  class_option :env,
21
21
  :type => :array,
22
22
  :desc => 'additional environment variables',
23
- :alias => 'e',
23
+ :aliases => 'e',
24
24
  :default => []
25
25
 
26
26
  class_option :packages,
27
27
  :type => :array,
28
28
  :desc => 'additional packages to install',
29
- :alias => 'p',
29
+ :aliases => 'p',
30
30
  :default => []
31
31
 
32
- class_option :volumes,
33
- :type => :array,
34
- :desc => 'the volumes your data-container will mount',
35
- :alias => 'v',
36
- :default => ["/var"]
37
-
32
+
38
33
  desc "app APP_NAME", "create a new app."
39
34
  option :dockerfile,
40
35
  :type => :boolean,
41
36
  :desc => 'create a dockerfile for the app',
42
37
  :aliases => 'd'
38
+ option :volumes,
39
+ :type => :array,
40
+ :desc => 'the volumes your data-container will mount',
41
+ :aliases => 'v',
42
+ :default => ["/var"]
43
43
  def app(app_name)
44
44
  @app_name = app_name
45
45
  @user_email = extract_email
@@ -66,18 +66,21 @@ class Create < Thor
66
66
  def image(image_name)
67
67
  @user_email = extract_email
68
68
  @user_name = extract_name
69
- image_path = "#{base_images_dir}/#{image_name}"
69
+ image_path = "#{base_images_dir}/#{image_name}/v1.0"
70
70
  empty_directory "#{image_path}/administration/installation"
71
71
  template "Dockerfile.erb","#{image_path}/Dockerfile"
72
72
  unless options[:packages].empty?
73
73
  options[:packages].each do |package|
74
- FileUtils.ln("#{install_dir}/install_#{package}.sh",
74
+ FileUtils.cp("#{install_dir}/install_#{package}.sh",
75
75
  "#{image_path}/administration/installation/install_#{package}.sh")
76
76
  end
77
77
 
78
- FileUtils.ln("#{install_dir}/scriptrunner.sh",
78
+ FileUtils.cp("#{install_dir}/scriptrunner.sh",
79
79
  "#{image_path}/administration/scriptrunner.sh")
80
80
  end
81
-
81
+ @image_name = image_name
82
+ @version = "1.0"
83
+ template "build.erb", "#{image_path}/build.sh"
84
+ FileUtils.chmod 0755, "#{image_path}/build.sh"
82
85
  end
83
86
  end
@@ -0,0 +1,38 @@
1
+ require 'thor/group'
2
+ require 'fileutils'
3
+
4
+ class Increment < Thor::Group
5
+ include Thor::Actions
6
+ include DockerMgr::Util
7
+
8
+ def self.source_root
9
+ File.expand_path('../templates',__dir__)
10
+ end
11
+
12
+
13
+ class_option :minor,:aliases => 'm'
14
+ argument :image_name,:type => :string
15
+
16
+ def increment
17
+ last_version_dir = Dir.entries("#{base_images_dir}/#{@image_name}")
18
+ .select {|e| e != "." && e != ".."}
19
+ .max {|a,b| a[1..-1].to_f <=> b[1..-1].to_f}
20
+ last_number = last_version_dir[1..-1].to_f
21
+
22
+ new_number = options[:minor] ? last_number + 0.1 : last_number.to_i + 1.0
23
+ new_number_format = '%.1f' % new_number
24
+ empty_directory "#{base_images_dir}/#{@image_name}/v#{new_number_format}"
25
+ FileUtils.cp_r "#{base_images_dir}/#{@image_name}/#{last_version_dir}/.",
26
+ "#{base_images_dir}/#{@image_name}/v#{new_number_format}"
27
+
28
+ if File.exist? "#{base_images_dir}/#{@image_name}/v#{new_number_format}/build.sh"
29
+ FileUtils.rm "#{base_images_dir}/#{@image_name}/v#{new_number_format}/build.sh"
30
+ end
31
+ @version = new_number_format
32
+ template 'build.erb',"#{base_images_dir}/#{@image_name}/v#{new_number_format}/build.sh"
33
+ FileUtils.chmod 0755, "#{base_images_dir}/#{@image_name}/v#{new_number_format}/build.sh"
34
+
35
+
36
+ end
37
+
38
+ end
@@ -1,4 +1,4 @@
1
1
  module DockerMgr
2
2
  # docker_mgr version
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
@@ -1,4 +1,4 @@
1
- FROM <%=options[:image]%>
1
+ FROM <%=options[: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
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ sudo docker build -t <%="#{@image_name}:#{@version}"%> .
@@ -1,5 +1,5 @@
1
1
  app:
2
- <%if options[:image]%>image: <%=options[:image]%> <%else%>build: .<%end%>
2
+ <%if options[:base]%>image: <%=options[:base]%> <%else%>build: .<%end%>
3
3
  volumes_from:
4
4
  - appdata
5
5
  environment:
@@ -7,7 +7,7 @@ app:
7
7
  <%options[:env].each do | var |%><%=var.gsub('=',': ')%>
8
8
  <%end%>
9
9
  appdata:
10
- <%if options[:image]%>image: <%=options[:image]%> <%else%>build: .<%end%>
10
+ <%if options[:base]%>image: <%=options[:base]%> <%else%>build: .<%end%>
11
11
  volumes:
12
12
  <%options[:volumes].each do |volume|-%>
13
13
  - <%=volume%>
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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rene Richter
@@ -123,6 +123,7 @@ files:
123
123
  - lib/commands/create.rb
124
124
  - lib/commands/delete.rb
125
125
  - lib/commands/generate_backup_scripts.rb
126
+ - lib/commands/increment.rb
126
127
  - lib/commands/init.rb
127
128
  - lib/commands/restore_app.rb
128
129
  - lib/commands/start.rb
@@ -144,6 +145,7 @@ files:
144
145
  - lib/templates/backup.erb
145
146
  - lib/templates/before_all.erb
146
147
  - lib/templates/before_all_restore.erb
148
+ - lib/templates/build.erb
147
149
  - lib/templates/docker-compose.yml.erb
148
150
  - lib/templates/restore.erb
149
151
  - lib/util.rb