dockly 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ [![Gem Version](https://badge.fury.io/rb/dockly.png)](http://badge.fury.io/rb/dockly)
2
+ [![Build Status](https://travis-ci.org/swipely/dockly.png?branch=refactor_setup)](https://travis-ci.org/swipely/dockly)
3
+ [![Dependency Status](https://gemnasium.com/swipely/dockly.png)](https://gemnasium.com/swipely/dockly)
4
+
1
5
  Dockly
2
6
  =======
3
7
 
@@ -21,11 +25,11 @@ docker :test_docker do
21
25
  end
22
26
  ```
23
27
 
24
- Each object has an enumeration of valid attributes. The following code sets the `repo` attribute in a `docker` called `test_docker`:
28
+ Each object has an enumeration of valid attributes. The following code sets the `repository` attribute in a `docker` called `test_docker`:
25
29
 
26
30
  ```ruby
27
31
  docker :test_docker do
28
- repo 'an-awesome-repo'
32
+ repository 'an-awesome-name'
29
33
  end
30
34
  ```
31
35
 
@@ -33,7 +37,7 @@ Finally, each object has zero or more valid references to other DSL objects. The
33
37
 
34
38
  ```ruby
35
39
  docker :my_docker do
36
- repo 'my-repo'
40
+ repository 'my-name'
37
41
  end
38
42
 
39
43
  deb :my_deb do
@@ -46,11 +50,40 @@ Below is an alternative syntax that accomplishes the same thing:
46
50
  ```ruby
47
51
  deb :my_deb do
48
52
  docker do
49
- repo 'my-repo'
53
+ repository 'my-name'
50
54
  end
51
55
  end
52
56
  ```
53
57
 
58
+ `build_cache`
59
+ -------------
60
+
61
+ The `build_cache` DSL is used to prevent rebuilding assets every build and used cached assets.
62
+
63
+ - `s3_bucket`
64
+ - required: `true`
65
+ - description: the bucket name to download and upload build caches to
66
+ - `s3_object_prefix`
67
+ - required: `true`
68
+ - description: the name prepended to the package; allows for namespacing your caches
69
+ - `hash_command`
70
+ - required: `true`
71
+ - description: command run inside of the Docker image to determine if the build cache is up to date (eg. `md5sum ... | awk '{ print $1 }'`)
72
+ - `build_command`
73
+ - required: `true`
74
+ - description: command run inside of the Docker image when the build cache is out of date
75
+ - `output_dir`
76
+ - required: `true`
77
+ - description: where the cache is located in the Docker image filesystem
78
+ - `tmp_dir`
79
+ - required: `true`
80
+ - default: `/tmp`
81
+ - description: where the build cache files are stored locally; this should be able to be removed easily since they all exist in S3 as well
82
+ - `use_latest`
83
+ - required: `false`
84
+ - default: `false`
85
+ - description: when using S3, will insert the S3 object tagged as latest in your "s3://s3_bucket/s3_object_prefix" before running the build command to quicken build times
86
+
54
87
  `docker`
55
88
  --------
56
89
 
@@ -58,7 +91,6 @@ The `docker` DSL is used to define Docker containers. It has the following attri
58
91
 
59
92
  - `import`
60
93
  - required: `true`
61
- - default: `nil`
62
94
  - description: the location (url or S3 path) of the base image to start building from
63
95
  - `git_archive`:
64
96
  - required: `false`
@@ -66,15 +98,15 @@ The `docker` DSL is used to define Docker containers. It has the following attri
66
98
  - description: the relative file path of git repo that should be added to the container
67
99
  - `build`
68
100
  - required: `true`
69
- - default: `nil`
70
101
  - description: aditional Dockerfile commands that you'd like to pass to `docker build`
71
- - `repo`
102
+ - `repository`
72
103
  - required: `true`
73
104
  - default: `'dockly'`
74
105
  - description: the repository of the created image
106
+ - `name`
107
+ - alias for: `repository`
75
108
  - `tag`
76
109
  - required: `true`
77
- - default: `nil`
78
110
  - description: the tag of the created image
79
111
  - `build_dir`
80
112
  - required: `true`
@@ -93,6 +125,13 @@ The `docker` DSL is used to define Docker containers. It has the following attri
93
125
  - default: `[]`
94
126
  - description: a listing of references to build caches to run
95
127
 
128
+ In addition to the above attributes, `docker` has the following references:
129
+
130
+ - `build_cache`
131
+ - required: `false`
132
+ - class: `Dockly::BuildCache`
133
+ - description: a caching system to stop rebuilding/compiling the same files every time
134
+
96
135
  `foreman`
97
136
  ---------
98
137
 
@@ -133,7 +172,6 @@ The `deb` DSL is used to define Debian packages. It has the following attributes
133
172
 
134
173
  - `package_name`
135
174
  - required: `true`
136
- - default: `nil`
137
175
  - description: the name of the created package
138
176
  - `version`
139
177
  - required: `true`
@@ -185,7 +223,6 @@ deb :dockly_package do
185
223
 
186
224
  docker do
187
225
  name :dockly_docker
188
- tag 'dockly_docker'
189
226
  import 's3://dockly-bucket-name/base-image.tar.gz'
190
227
  git_archive '/app'
191
228
  timeout 120
@@ -10,10 +10,10 @@ class Dockly::Docker
10
10
  include Dockly::Util::Logger::Mixin
11
11
 
12
12
  logger_prefix '[dockly docker]'
13
- dsl_attribute :import, :git_archive, :build, :repo, :tag, :build_dir, :package_dir,
13
+ dsl_attribute :name, :import, :git_archive, :build, :tag, :build_dir, :package_dir,
14
14
  :timeout, :cleanup_images, :build_caches
15
15
 
16
- default_value :repo, 'dockly'
16
+ default_value :tag, nil
17
17
  default_value :build_dir, 'build/docker'
18
18
  default_value :package_dir, '/opt/docker'
19
19
  default_value :build_caches, []
@@ -38,7 +38,7 @@ class Dockly::Docker
38
38
  end
39
39
 
40
40
  def export_filename
41
- "#{repo}-#{tag}-image.tgz"
41
+ "#{name}-image.tgz"
42
42
  end
43
43
 
44
44
  def run_build_caches(image)
@@ -66,7 +66,7 @@ class Dockly::Docker
66
66
  end
67
67
 
68
68
  def make_git_archive
69
- ensure_present! :tag, :git_archive
69
+ ensure_present! :git_archive
70
70
  info "initializing"
71
71
 
72
72
  prefix = git_archive
@@ -110,16 +110,16 @@ class Dockly::Docker
110
110
  end
111
111
 
112
112
  def build_image(image)
113
- ensure_present! :repo, :tag, :build
113
+ ensure_present! :name, :build
114
114
  info "starting build from #{image.id}"
115
115
  out_image = ::Docker::Image.build("from #{image.id}\n#{build}")
116
116
  info "built the image: #{out_image.id}"
117
- out_image.tag(:repo => repo, :tag => tag)
117
+ out_image.tag(:repo => name, :tag => tag)
118
118
  out_image
119
119
  end
120
120
 
121
121
  def export_image(image)
122
- ensure_present! :repo, :tag, :build_dir
122
+ ensure_present! :name, :build_dir
123
123
  container = ::Docker::Container.create('Image' => image.id, 'Cmd' => %w[true])
124
124
  info "created the container: #{container.id}"
125
125
  Zlib::GzipWriter.open(tar_path) do |file|
@@ -131,7 +131,7 @@ class Dockly::Docker
131
131
  end
132
132
 
133
133
  def fetch_import
134
- ensure_present! :tag, :import
134
+ ensure_present! :import
135
135
  path = "/tmp/dockly-docker-import.#{name}.#{File.basename(import)}"
136
136
 
137
137
  if File.exist?(path)
@@ -162,6 +162,10 @@ class Dockly::Docker
162
162
  build_caches << Dockly::BuildCache.new(&block)
163
163
  end
164
164
 
165
+ def repository(value = nil)
166
+ name(value)
167
+ end
168
+
165
169
  private
166
170
  def connection
167
171
  Dockly::AWS.s3
@@ -1,3 +1,3 @@
1
1
  module Dockly
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -48,11 +48,10 @@ describe Dockly::Deb do
48
48
  context 'when it has a docker', :docker do
49
49
  before do
50
50
  subject.docker do
51
- name 'my-docker-for-deb'
51
+ name 'deb_test'
52
52
  import 'https://s3.amazonaws.com/swipely-pub/docker-export-ubuntu-latest.tgz'
53
53
  git_archive '.'
54
54
  build 'touch /deb_worked'
55
- tag 'deb_test'
56
55
  build_dir 'build/docker'
57
56
  end
58
57
  end
@@ -149,7 +149,7 @@ describe Dockly::Docker do
149
149
  end
150
150
 
151
151
  describe '#generate!', :docker do
152
- let(:docker_file) { 'build/docker/dockly_test-generate-image.tgz' }
152
+ let(:docker_file) { 'build/docker/dockly_test-image.tgz' }
153
153
  before { FileUtils.rm_rf(docker_file) }
154
154
 
155
155
  context 'without cleaning up' do
@@ -158,8 +158,7 @@ describe Dockly::Docker do
158
158
  import 'https://s3.amazonaws.com/swipely-pub/docker-export-ubuntu-latest.tgz'
159
159
  git_archive '.'
160
160
  build "run touch /it_worked"
161
- repo 'dockly_test'
162
- tag 'generate'
161
+ repository 'dockly_test'
163
162
  build_dir 'build/docker'
164
163
  cleanup_images false
165
164
  end
@@ -188,8 +187,7 @@ describe Dockly::Docker do
188
187
  import 'https://s3.amazonaws.com/swipely-pub/docker-export-ubuntu-latest.tgz'
189
188
  git_archive '.'
190
189
  build "run touch /it_worked"
191
- repo 'dockly_test'
192
- tag 'generate'
190
+ repository 'dockly_test'
193
191
  build_dir 'build/docker'
194
192
  cleanup_images true
195
193
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dockly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-07 00:00:00.000000000 Z
12
+ date: 2013-11-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: clamp