containerci 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: c1025350f5ade0b3f3633886d3b40ccc106e318b
4
- data.tar.gz: eed3c83efed695dc720bc0f992fe93b43835a275
3
+ metadata.gz: a41aa50a9da170e65dfb6e703f7d709cec774672
4
+ data.tar.gz: 0dada086c62e9cd1ce58a78f53f4a6257632e2e8
5
5
  SHA512:
6
- metadata.gz: aec05edaee588f68c76697744ff9b27e908d2dec5a1ccac6a67094903e4446a16c3182e1db21f3901f886ea1b06adb32886e98937d80696996b9a1e56d2e8175
7
- data.tar.gz: dfcef96634ded8ea6ace7a9c85873b49303f060d51c39204d46e904d86c5190013ed35a07d56b7e2e479482cd50c8c6f15b63dc12504e61cb2a5e5415023b00d
6
+ metadata.gz: 2967a89191b721f449047f906f0be39021103b8524c8911f206ddf34bfc524ebffab7fbde71ca9cd3931ce4929438820af71df7fbd7f6176e2b03e5405b3e13b
7
+ data.tar.gz: a8c0890daa5b8d5d588711dfa49b7fd96a687f4e0535d4de77df5ff97980f5571a2f54ec004aaf25b086928427867f10ee03cbac50a73dc4df2d95520f1a58cc
data/ChangeLog.md ADDED
@@ -0,0 +1,3 @@
1
+ ## Changes since ContainerCI 0.1.0
2
+
3
+ ### Add additional auditing of git checkouts
data/README.md CHANGED
@@ -1,16 +1,19 @@
1
1
  # ContainerCI
2
2
 
3
- This is a toolkit for creating automated builds for Docker containers.
3
+ This is a toolkit for creating automated builds for Docker containers via the magic of Rakefiles.
4
4
 
5
- It currently supports a limited workflow for a container in CircleCI
6
- (i.e., something I needed to do twice), but contributions are welcome!
5
+ It will pull from a given tag from the project which you are containerizing, use Docker and your Dockerfile to build, run tests that you define, and push to DockerHub.
6
+
7
+ With the below sample circle.yml, you can use CircleCI to automate this process and build your container whenever your source project changes and passes its tests.
8
+
9
+ ContainerCI currently supports a pretty limited workflow for a container in CircleCI (i.e., something I needed to do twice), but contributions are welcome!
7
10
 
8
11
  ## Installation
9
12
 
10
13
  Add this line to your application's Gemfile:
11
14
 
12
15
  ```ruby
13
- gem 'container-ci'
16
+ gem 'containerci'
14
17
  ```
15
18
 
16
19
  And then execute:
@@ -19,14 +22,84 @@ And then execute:
19
22
 
20
23
  Or install it yourself as:
21
24
 
22
- $ gem install container-ci
25
+ $ gem install containerci
23
26
 
24
27
  ## Usage
25
28
 
26
- Add this line to your applicatoin's Rakefile:
29
+ 1) Add this line to your application's Rakefile:
30
+
31
+ ```ruby
32
+ require 'containerci'
33
+
34
+ ContainerCI::ExportGithubProjectIntoContainer.new
35
+ ```
36
+
37
+ 2) Create a circle.yml file that looks like this:
38
+
39
+
40
+ ```yaml
41
+ machine:
42
+ services:
43
+ - docker
44
+ post:
45
+ - 'echo "{ \"https://index.docker.io/v1/\": { \"auth\": \"$DOCKERHUB_TOKEN\", \"email\": \"$DOCKERHUB_EMAIL\" }}" > ~/.dockercfg'
46
+ dependencies:
47
+ cache_directories:
48
+ - "sinatra-vld"
49
+ - "~/docker"
50
+ - "~/docker-machine"
51
+ post:
52
+ - bundle exec rake dependencies
53
+ test:
54
+ override:
55
+ - bundle exec rake test quality
56
+ deployment:
57
+ staging:
58
+ branch: master
59
+ commands:
60
+ - bundle exec rake after_test_success
61
+ ```
62
+
63
+ 3) Define tasks for :deploy (or change/remove the deployment section of the below
64
+ circleci.yml file).
65
+
66
+ 4) Define a task for :test to test your container before it is tagged and
67
+ pushed to Docker Hub.
68
+
69
+ 5) Verify it works.
70
+
71
+ 6) Set up a trigger to build your container project when the source project succesfully builds (see below).
72
+
73
+ ## Setting up CircleCI automated build triggers
74
+
75
+ When your source project succesfully builds and passes tests, you're going to want to rebuild the container with the resulting files. Add this to your source project (not the one you're using this gem with!):
76
+
77
+ ```yaml
78
+ deployment:
79
+ staging:
80
+ branch: master
81
+ commands:
82
+ - bundle exec rake after_test_success
83
+ ```
84
+
85
+ Now add these tasks to your Rakefile:
27
86
 
28
87
  ```ruby
29
- require 'container-ci'
88
+ # this is run by CircleCI
89
+ task after_test_success: [:tag, :trigger_next_builds]
90
+
91
+ task :tag do
92
+ sh 'git tag -f tests_passed'
93
+ sh 'git push -f origin tests_passed'
94
+ end
95
+
96
+ GITHUB_USER = 'you'
97
+ DOWNSTREAM_GITHUB_PROJECT = 'your-container-project'
98
+
99
+ task :trigger_next_builds do
100
+ sh "curl -v -X POST https://circleci.com/api/v1/project/#{GITHUB_USER}/" \
101
+ "#{DOWNSTREAM_GITHUB_PROJECT}/tree/master?circle-token=$CIRCLE_TOKEN"
102
+ end
30
103
  ```
31
104
 
32
105
  ## Development
@@ -44,7 +117,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
44
117
 
45
118
  ## Contributing
46
119
 
47
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/container-ci. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
120
+ Bug reports and pull requests are welcome on GitHub at https://github.com/apiology/containerci. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
48
121
 
49
122
 
50
123
  ## License
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
2
  require 'rspec/core/rake_task'
3
3
  require 'quality/rake/task'
4
4
 
data/containerci.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'containerci/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "containerci"
8
- spec.version = Containerci::VERSION
8
+ spec.version = ContainerCI::VERSION
9
9
  spec.authors = ["Vince Broz"]
10
10
  spec.email = ["vince@broz.cc"]
11
11
 
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "result": {
3
- "covered_percent": 100.0
3
+ "covered_percent": 23.64
4
4
  }
5
5
  }
data/lib/containerci.rb CHANGED
@@ -1,5 +1,8 @@
1
- require "containerci/version"
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+ require 'containerci/version'
2
4
 
5
+ # Rakefile toolkit for creating automated builds for Docker containers.
3
6
  module ContainerCI
4
7
  #
5
8
  # Exports a github project into a container--set up so that CI systems
@@ -31,16 +34,16 @@ module ContainerCI
31
34
  end
32
35
 
33
36
  def define
34
- # XXX: Document circleci.yml
35
37
  @dsl.define_task(:update_github_project) do
36
38
  puts "pulling #{GITHUB_PROJECT}..."
37
- if Dir.exist? GITHUB_PROJECT
38
- sh "cd #{GITHUB_PROJECT} && git pull origin tests_passed"
39
- else
39
+ unless Dir.exist? GITHUB_PROJECT
40
40
  sh 'git clone https://$GITHUB_OAUTH:x-oauth-basic@' \
41
41
  "github.com/#{USER}/#{GITHUB_PROJECT}.git"
42
42
  end
43
+ sh "cd #{GITHUB_PROJECT} && git pull origin tests_passed"
44
+ sh "cd #{GITHUB_PROJECT} && git show-ref --tags"
43
45
  sh "cd #{GITHUB_PROJECT} && git checkout tests_passed"
46
+ sh "cd #{GITHUB_PROJECT} && git rev-parse HEAD"
44
47
  puts 'done'
45
48
  end
46
49
 
@@ -54,9 +57,6 @@ module ContainerCI
54
57
  puts 'done'
55
58
  end
56
59
 
57
- # XXX: Why do we have to pull all images here, just to figure out what
58
- # the latest version is? Wish we could just pull latest.
59
-
60
60
  @dsl.define_task(:raw_docker_pull) do
61
61
  puts 'Pulling from dockerhub...'
62
62
  sh 'false; ' \
@@ -90,7 +90,9 @@ module ContainerCI
90
90
  [:restore_cache, :raw_docker_pull, :save_new_cache])
91
91
 
92
92
  @dsl.define_task(dependencies:
93
- [:update_github_project, :docker_pull, :get_docker_machine])
93
+ [:update_github_project,
94
+ :docker_pull,
95
+ :get_docker_machine])
94
96
 
95
97
  @dsl.define_task(:print_next_version) do
96
98
  puts "next version is #{next_version}"
@@ -110,37 +112,17 @@ module ContainerCI
110
112
  :docker_build_next_version,
111
113
  :docker_tag])
112
114
 
113
- @dsl.define_task(test:
114
- [:build,
115
- # :start_container, :verify_listening_on_port, :stop_container
116
- ])
115
+ @dsl.define_task(test: [:build])
117
116
 
118
117
  @dsl.define_task(:docker_push) do
119
118
  sh "docker push #{USER}/#{PROJECT_NAME}"
120
119
  sh "docker push #{USER}/#{PROJECT_NAME}:#{current_version}"
121
120
  end
122
121
 
123
- @dsl.define_task(:manual_deploy) do
124
- sh "in-sinatra-vld-prod docker pull #{USER}/#{PROJECT_NAME}:latest"
125
- sh 'in-sinatra-vld-prod docker ps'
126
- sh 'in-sinatra-vld-prod docker kill `in-sinatra-vld-prod docker ps -l -q`'
127
- sh 'in-sinatra-vld-prod docker run -d -P -p 0.0.0.0:4567:4567 ' \
128
- "-v /root/private:/root/private #{USER}/#{PROJECT_NAME}"
129
- sh 'in-sinatra-vld-prod docker ' \
130
- 'exec -it `in-sinatra-vld-prod docker ps -l -q` /bin/dropbox ' \
131
- 'status'
132
- puts "After connected, hit Control-C and run 'rake wait_for_dropbox'"
133
- sh 'in-sinatra-vld-prod docker exec -it ' \
134
- '`in-sinatra-vld-prod docker ps -l -q` ' \
135
- 'tail -f /var/log/dropbox/dropbox.log'
136
- end
137
-
138
122
  @dsl.define_task(after_test_success:
139
123
  [:docker_push,
140
- #:deploy_to_prod
124
+ :deploy
141
125
  ])
142
126
  end
143
- # XXX: As configured in CircleCI, this runs regardless of whether test passed
144
-
145
127
  end
146
128
  end
@@ -1,3 +1,4 @@
1
- module Containerci
2
- VERSION = "0.1.0"
1
+ # Rakefile toolkit for creating automated builds for Docker containers.
2
+ module ContainerCI
3
+ VERSION = '0.2.0'
3
4
  end
@@ -1 +1 @@
1
- 81
1
+ 188
@@ -1 +1 @@
1
- 0
1
+ 1
@@ -1 +1 @@
1
- 4
1
+ 2
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: containerci
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
  - Vince Broz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-09 00:00:00.000000000 Z
11
+ date: 2015-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -65,6 +65,7 @@ files:
65
65
  - ".ruby-version"
66
66
  - ".travis.yml"
67
67
  - CODE_OF_CONDUCT.md
68
+ - ChangeLog.md
68
69
  - Gemfile
69
70
  - Gemfile.lock
70
71
  - LICENSE.txt