rocker-docket 0.0.1 → 0.0.2

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: c674906c6147e5e60e609cbd97472cc6aa3c14a3
4
- data.tar.gz: e7776eabe1d9ee930cac12baf40f8d74f567b6ac
3
+ metadata.gz: a958dca255506b4a3308b658c3be7305bd2c9188
4
+ data.tar.gz: 55ce171c83214bc3bc4c2fea2f9c893667ff9372
5
5
  SHA512:
6
- metadata.gz: a05822775171c2910db40079a2432182733c39e6a49034ddd48c00c7a50239360a4fb9781dcabec448a8f86cb7f8e200b973ce4fe8efa139a66de44c0fe2301b
7
- data.tar.gz: 3820afda15505f60cc97458ad411f75ef756a23fe0e8002695687457fd3bb4dfdffdefc5d6a58732d555db90fcfb00a1b9ea5178ce9509dce4d2daf37eb78099
6
+ metadata.gz: 660254a3aa01b9f6e13231b92b555d4c8b2f6a3a7e3f5abc3d40bc09e2d9270ec359c324f68d91f717c69668d93fb995ab0a89b3f48393f08833b341d115b2de
7
+ data.tar.gz: 3895472a9f574158ed58c351f3393bec1a82421fbc4b2d69344278587e05df809512700d06f595ea1d579aae06b85097219f19b804242a83de551fa82240a80e
data/README.md CHANGED
@@ -1,15 +1,29 @@
1
1
  # Rocker-Docket
2
- Run Rocket under Docker.
3
2
 
4
- # Usage
5
- Basic usage:
3
+ Run [Rocket](https://github.com/coreos/rocket) under [Docker](https://github.com/docker/docker).
4
+
5
+ This gives you access to the rkt executable without having to install rkt on your system.
6
+ You do, however, have to have docker installed.
7
+
8
+ # Installation
9
+
10
+ Install the gem:
6
11
  ```bash
7
- docker pull sheax0r/rocker-docket
8
- docker run rocker-docket help
12
+ gem install rocker-docket
9
13
  ```
10
14
 
11
- This really isn't very useful unless you mount some host volumes (or data containers or what-have-you)
12
- to store your rocket ACIs on; otherwise they will just disappear when the container stops.
15
+ Once installed, you can:
16
+ * Build the image : ```rocker-docket build```
17
+ * Update to the latest version of rocket: ```rocker-docket update```.
13
18
 
14
- I'll include some scripts to help with this in the near future.
19
+ Updating will also build. If you have never run build before, it will get the
20
+ latest version of rocket.
21
+
22
+ # Usage
23
+ Use it just like you would use the rkt CLI, after you have built the image.
24
+ ```bash
25
+ rkt help
26
+ ```
15
27
 
28
+ By default, the host directory /var/lib/rkt will be mounted in the container, for rkt
29
+ operations. You can override this by setting ```ROCKET_DIR```.
data/bin/rkt CHANGED
@@ -6,4 +6,4 @@ end
6
6
 
7
7
  fail "#{rocket_dir} does not exist" unless File.exists? rocket_dir
8
8
 
9
- exec "docker run -v #{rocket_dir}:/var/lib/rkt -t sheax0r/rocker-docket #{ARGV.join(' ')}"
9
+ exec "docker run -v #{rocket_dir}:/var/lib/rkt -t rocker-docket #{ARGV.join(' ')}"
data/bin/rocker-docket CHANGED
@@ -1,12 +1,21 @@
1
1
  #!/usr/bin/env ruby
2
+ $: << File.join(File.dirname(__FILE__), '..', 'lib')
3
+ require 'rocker/docket'
4
+ FileUtils.mkdir_p Rocker::Docket.dir
5
+
6
+
2
7
  case ARGV[0]
3
8
  when 'build'
4
- Dir.chdir File.join(File.dirname(__FILE__), '..')
5
- exec "docker build -t sheax0r/rocker-docket ."
6
- when 'pull'
7
- exec "docker pull sheax0r/rocker-docket"
9
+ Rocker::Docket.build
10
+ when 'update'
11
+ tag = Rocker::Docket.update
12
+ if tag
13
+ puts "Updated to #{tag}."
14
+ else
15
+ puts "Already on latest version."
16
+ end
8
17
  else
9
- puts "Usage: rocker-docket [build|pull]"
18
+ puts "Usage: rocker-docket [build|update]"
10
19
  exit 1
11
20
  end
12
21
 
@@ -1,6 +1,6 @@
1
1
  FROM centos
2
2
  RUN yum install -y tar
3
- RUN curl -L https://github.com/coreos/rocket/releases/download/v0.1.0/rocket-v0.1.0.tar.gz | tar xz
3
+ RUN curl -L <%=rocket_url%> | tar xz
4
4
  RUN ln -s /rocket-v0.1.0 /rocket
5
5
  WORKDIR /rocket
6
6
  ENTRYPOINT ["./rkt"]
data/lib/rocker/docket.rb CHANGED
@@ -1,7 +1,58 @@
1
1
  require "rocker/docket/version"
2
+ require 'erb'
3
+ require 'json'
4
+ require 'open-uri'
2
5
 
3
6
  module Rocker
4
7
  module Docket
5
- # Your code goes here...
8
+ class << self
9
+ def build
10
+ update unless File.exists? dockerfile
11
+ write(dockerfile, ERB.new(File.read(template)).result(binding))
12
+ exec "docker build -t rocker-docket #{dir}"
13
+ end
14
+
15
+ def template
16
+ "#{File.join(File.dirname(__FILE__), 'Dockerfile.erb')}"
17
+ end
18
+
19
+ def update
20
+ release = JSON.parse(releases_string)[0]
21
+ assets_url = release['assets_url']
22
+ tag = release['tag_name']
23
+ download_url = JSON.parse(open(assets_url){|f| f.read }).detect{ |a| a['name'] =~ /rocket.*.tar.gz/ }['browser_download_url']
24
+ if download_url == rocket_url
25
+ nil
26
+ else
27
+ write(rocket_url_file, download_url)
28
+ tag
29
+ end
30
+ end
31
+
32
+ def releases_string
33
+ open("https://api.github.com/repos/coreos/rocket/releases"){ |f| f.read }
34
+ end
35
+
36
+ def dockerfile
37
+ "#{dir}/Dockerfile"
38
+ end
39
+
40
+ def rocket_url
41
+ File.read rocket_url_file if File.exists? rocket_url_file
42
+ end
43
+
44
+ def rocket_url_file
45
+ "#{dir}/rocket_url"
46
+ end
47
+
48
+ def dir
49
+ "#{ENV['HOME']}/.rocker-docket"
50
+ end
51
+
52
+ private
53
+ def write(file, string)
54
+ File.open(file, 'w'){ |f| f.write(string) }
55
+ end
56
+ end
6
57
  end
7
58
  end
@@ -1,5 +1,5 @@
1
1
  module Rocker
2
2
  module Docket
3
- VERSION = "0.0.1"
3
+ VERSION = '0.0.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocker-docket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Shea
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-03 00:00:00.000000000 Z
11
+ date: 2014-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -48,13 +48,13 @@ extensions: []
48
48
  extra_rdoc_files: []
49
49
  files:
50
50
  - ".gitignore"
51
- - Dockerfile
52
51
  - Gemfile
53
52
  - LICENSE.txt
54
53
  - README.md
55
54
  - Rakefile
56
55
  - bin/rkt
57
56
  - bin/rocker-docket
57
+ - lib/rocker/Dockerfile.erb
58
58
  - lib/rocker/docket.rb
59
59
  - lib/rocker/docket/version.rb
60
60
  - rocker-docket.gemspec