bricky 0.0.4 → 0.0.5

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTI1OTMxMjE2MWNlZDY3MjM3MmVjNzg3NzU1NDRjNDA2MjZhNmYyNQ==
4
+ ZjM2MWMyMDM5OWQ1NjgxNTE3ODI5M2MyNGI4NzE1MDIzMTU1YzRlYg==
5
5
  data.tar.gz: !binary |-
6
- N2YxNTE0ZTk2MmQ5ZjE0ZGVjN2I2ZmFiZjk2NDI1MmI5OWQwNGUwNw==
6
+ Njk1MDA2M2ZjYzllZDVmNTdmZjZmMzJhMTY1MjhiMDhmZmY3YjM3OQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODE1ZTNmMWRlMzM1MGM2YjkwYjE3MzI0OGU0OTBjY2RiYTgzYzIxMzMwNDhl
10
- YTc4OWFlZjAwMTQ3MzU4OWNlNjNmNTdkZTk5ZTVjZmNmYjE4MWYyMDYyOWRj
11
- N2M1M2JkZjkyYjQ4ZjlhZTA2M2Q5Yzg3YTNmYTRiYWFiMjU0OTk=
9
+ MGFmNzIwMDYyNDAxNzY0Njk5MmY0MWU2ZmRmYTRmMTYzYTkwZDNkMzEyYjkz
10
+ YTNjODdkMTAyNmYzYWRiMzIwZDIzNTIwYzdhNWE1NGUwMGJlNDJmMjQ5YzE1
11
+ YzBjMGZiZGM3MmRiZTc5ZjE0MjFkMWFhNDVlYmQ1OTQ2OGJiZDI=
12
12
  data.tar.gz: !binary |-
13
- OTczZjFiMWIyOWI0ZmRhODA2M2RhMjlkZWRkZjgwN2U3MTRmYThhODhkNjNm
14
- ODZhYWQ2NDk5ZmM1YzdkMjdhZDQ1YWNjNzZlNzQ3MTE3MTU0MjUzZDkyMWFj
15
- ZGQ3MWUyMTllMmNhODNjNjMzOWMyY2IzMGY0ODZhYWQ4N2ZjNjM=
13
+ NTYyN2E0NGUzN2QyNzA0ZDNiNDc4MzBhZTUzZDY2MmJkYzU1Y2U5YjBjODQz
14
+ MzVmOGU1ZTg5NzkyOTI3ODNmNDc0MjEwYzlmNGNlMjAxMGMxZGI4Y2Q3N2Nj
15
+ YzQxZmU2MjUzN2NhM2UxMDVlZDI3MWVkNTQ1MjJiY2E2YzY2NTU=
@@ -1,16 +1,15 @@
1
- #!/bin/bash -l
1
+ #!/bin/bash -le
2
2
 
3
- info() {
4
- message=$1;
5
- echo -e "\n\n\033[32m${message}\033[0m";
6
- }
3
+ . $BRICKS_HOME/suexec
7
4
 
8
5
  execute() {
6
+ . $BRICKS_HOME/builder
7
+
9
8
  info 'Vendor project with Bundler'
10
- pushd /opt/build/source
9
+ pushd /opt/workspace/source
11
10
  gem install bundler --conservative --no-ri --no-rdoc
12
11
  bundle install --deployment --without=development:test
13
12
  popd
14
13
  }
15
14
 
16
- execute
15
+ suexec execute
@@ -1,22 +1,22 @@
1
- #!/bin/bash -l
1
+ #!/bin/bash -e
2
2
 
3
- info() {
4
- message=$1;
5
- echo -e "\n\n\033[32m${message}\033[0m";
6
- }
3
+ . $BRICKS_HOME/suexec
4
+ chown -R builder. /builded
7
5
 
8
6
  execute() {
7
+ . $BRICKS_HOME/builder
8
+
9
9
  info 'Starting buildpackage'
10
- pushd /opt/build/source
10
+ pushd /opt/workspace/source
11
11
  dpkg-buildpackage -b -rfakeroot
12
12
  popd
13
13
 
14
14
  info 'Moving deb files to volume'
15
- rm -R /builded/*
16
- mv /opt/build/*.deb /builded/
15
+ rm -Rf /builded/*
16
+ mv /opt/workspace/*.deb /builded/
17
17
 
18
18
  info 'Recreating local debian packages index'
19
19
  dpkg-scanpackages /builded/ | gzip > /builded/Packages.gz
20
20
  }
21
21
 
22
- execute
22
+ suexec execute
@@ -0,0 +1,6 @@
1
+ #!/bin/bash -le
2
+
3
+ info() {
4
+ message=$1;
5
+ echo -e "\n\n\033[32m${message}\033[0m";
6
+ }
@@ -0,0 +1,7 @@
1
+ #!/bin/bash -le
2
+
3
+ suexec() {
4
+ name=$1
5
+ export -f $name
6
+ su builder -c "bash -c $name"
7
+ }
@@ -1,14 +1,11 @@
1
- #!/bin/bash -l
1
+ #!/bin/bash -le
2
2
 
3
- info() {
4
- message=$1;
5
- echo -e "\n\n\033[32m${message}\033[0m";
6
- }
3
+ . $BRICKS_HOME/builder
7
4
 
8
5
  execute() {
9
- info 'Copying files'
10
- rsync -a --stats /bricks/mounts/volumes/ /opt/build
6
+ info 'Building workspace'
7
+ rsync -a --stats /bricks/mounts/volumes/ /opt/workspace
8
+ chown -R builder. /opt/workspace
11
9
  }
12
10
 
13
-
14
11
  execute
@@ -0,0 +1,3 @@
1
+ FROM <%= self.image %>
2
+ RUN useradd -u <%= self.uid %> builder
3
+ RUN mkdir -p /opt/workspace && chown -R builder. /opt
@@ -4,7 +4,6 @@ bricky:
4
4
  bricks:
5
5
  mounts:
6
6
  source: .
7
- bricky: ../bricky
8
7
  bundle:
9
8
  cache: true
10
9
  debian:
@@ -0,0 +1,19 @@
1
+ module Bricky
2
+ module Bricks
3
+ class Base
4
+ attr_accessor :config
5
+
6
+ def initialize(config)
7
+ self.config = config
8
+ end
9
+
10
+ def entrypoint
11
+ end
12
+
13
+ private
14
+ def bricks_path
15
+ Bricky.config.bricks_path
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,6 +1,8 @@
1
+ require "fileutils"
2
+
1
3
  module Bricky
2
4
  module Bricks
3
- class Bundle < Helper
5
+ class Bundle < Base
4
6
  def arguments
5
7
  scripts_path = "#{bricks_path}/bundle"
6
8
  results = ["-v #{scripts_path}:/bricks/bundle"]
@@ -14,8 +16,17 @@ module Bricky
14
16
 
15
17
  private
16
18
  def cached
17
- digest = Digest::MD5.file('Gemfile').hexdigest
18
- ["-v /tmp/bricky/cache/#{digest}:/opt/build/source/vendor/bundle"]
19
+ ["-v #{local_path}:/opt/workspace/source/vendor/bundle"]
20
+ end
21
+
22
+ def local_path
23
+ path = "/tmp/bricky/cache/#{digest}"
24
+ FileUtils::mkdir_p(path)
25
+ path
26
+ end
27
+
28
+ def digest
29
+ Digest::MD5.file('Gemfile').hexdigest
19
30
  end
20
31
  end
21
32
  end
@@ -1,6 +1,6 @@
1
1
  module Bricky
2
2
  module Bricks
3
- class Debian < Helper
3
+ class Debian < Base
4
4
  def arguments
5
5
  builded_path = File.expand_path(config["build"])
6
6
  scripts_path = "#{bricks_path}/debian"
@@ -1,16 +1,10 @@
1
1
  module Bricky
2
2
  module Bricks
3
- class Helper
4
- attr_accessor :config
5
-
6
- def initialize(config)
7
- self.config = config
3
+ class Helper < Base
4
+ def arguments
5
+ ["-v #{bricks_path}/helper:/bricks/helper",
6
+ "-e BRICKS_HOME=/bricks/helper"]
8
7
  end
9
-
10
- private
11
- def bricks_path
12
- File.expand_path("../../../../etc/bricks", __FILE__)
13
- end
14
8
  end
15
9
  end
16
10
  end
@@ -1,6 +1,6 @@
1
1
  module Bricky
2
2
  module Bricks
3
- class Mounts < Helper
3
+ class Mounts < Base
4
4
  def arguments
5
5
  scripts_path = "#{bricks_path}/mounts"
6
6
  command = "-v #{scripts_path}:/bricks/mounts"
data/lib/bricky/bricks.rb CHANGED
@@ -1,6 +1,6 @@
1
- require "byebug"
2
- require "bricky/bricks/helper"
1
+ require "bricky/bricks/base"
3
2
 
3
+ require "bricky/bricks/helper"
4
4
  require "bricky/bricks/ruby"
5
5
  require "bricky/bricks/bundle"
6
6
  require "bricky/bricks/debian"
@@ -13,7 +13,7 @@ module Bricky
13
13
  def resolve
14
14
  Bricky.config.bricks.collect do |name, config|
15
15
  resolve_and_initialize(name, config)
16
- end.uniq
16
+ end.uniq << Bricky::Bricks::Helper.new({})
17
17
  end
18
18
 
19
19
  def resolve_and_initialize(name, config)
@@ -1,3 +1,6 @@
1
+ require "etc"
2
+ require "fileutils"
3
+
1
4
  module Bricky
2
5
  module Commands
3
6
  module Bootstrap
@@ -10,12 +13,16 @@ module Bricky
10
13
 
11
14
  private
12
15
  def build(image)
13
- code = command(image.name, image.path)
14
- puts "Processing #{name} image: ".colorize(:blue) + code
15
-
16
- unless system(code)
17
- puts "~~~~~~~~~~~ Problems building image ~~~~~~~~~~~".colorize(:white).on_red
18
- return false
16
+ base = command(image.name, image.path)
17
+ hack = command(image.name, create_hack_image(image))
18
+
19
+ [base, hack].each do |code|
20
+ puts "Processing #{name} image: ".colorize(:blue) + code
21
+
22
+ unless system(code)
23
+ puts "~~~~~~~~~~~ Problems building image ~~~~~~~~~~~".colorize(:white).on_red
24
+ return false
25
+ end
19
26
  end
20
27
 
21
28
  true
@@ -26,7 +33,26 @@ module Bricky
26
33
  end
27
34
 
28
35
  def images
29
- ["builder", "runtime"].collect {|image| Bricky::Image.new(image) }
36
+ ["builder"].collect {|image| Bricky::Image.new(image) }
37
+ end
38
+
39
+ def create_hack_image(image)
40
+ hack_path = FileUtils::mkdir_p("/tmp/bricky/containers/#{Bricky.config.name}").first
41
+ File.open("#{hack_path}/Dockerfile", "w") { |file| file.write(parse_hack_template(image)) }
42
+ hack_path
43
+ end
44
+
45
+ def parse_hack_template(image)
46
+ template = "#{Bricky.config.hacker_path}/id_container/Dockerfile"
47
+ parser = ERB.new(open(template).read)
48
+ variables = OpenStruct.new({ "image" => image.name, uid: Etc.getpwuid.uid })
49
+
50
+ # :(
51
+ def variables.get_binding
52
+ binding
53
+ end
54
+
55
+ parser.result(variables.get_binding)
30
56
  end
31
57
  end
32
58
  end
@@ -13,9 +13,9 @@ module Bricky
13
13
  private
14
14
  def build(image)
15
15
  code = command(image)
16
- puts "Execute build: ".colorize(:blue) + code
16
+ puts format(code)
17
17
 
18
- unless system(code.gsub(/\n/, ""))
18
+ unless system(code)
19
19
  puts "~~~~~~~~~~~ Problems building image ~~~~~~~~~~~".colorize(:white).on_red
20
20
  return false
21
21
  end
@@ -26,10 +26,14 @@ module Bricky
26
26
  def command(image)
27
27
  bricks = Bricky::Bricks.resolve
28
28
  arguments = bricks.collect(&:arguments).uniq.join(" ")
29
- entrypoints = bricks.collect(&:entrypoint).uniq.join(";")
29
+ entrypoints = bricks.collect(&:entrypoint).compact.uniq.join(" && ")
30
30
 
31
31
  "docker run #{arguments} -i -t #{image.name} /bin/bash -l -c '#{entrypoints}'"
32
32
  end
33
+
34
+ def format(command)
35
+ command.split("-v ").join("\n\t -v ").split("-i ").join("\n\t -i ")
36
+ end
33
37
  end
34
38
  end
35
39
  end
data/lib/bricky/config.rb CHANGED
@@ -14,8 +14,12 @@ module Bricky
14
14
  self.bricks = config["bricks"]
15
15
  end
16
16
 
17
- def full_scripts_path
18
- File.expand_path("#{base_path}/bricky/containers/scripts", __FILE__)
17
+ def bricks_path
18
+ File.expand_path("#{base_path}/etc/bricks", __FILE__)
19
+ end
20
+
21
+ def hacker_path
22
+ File.expand_path("#{base_path}/etc/hacker", __FILE__)
19
23
  end
20
24
 
21
25
  private
@@ -1,3 +1,3 @@
1
1
  module Bricky
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bricky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - andrerocker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-05 00:00:00.000000000 Z
11
+ date: 2015-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -91,13 +91,16 @@ files:
91
91
  - bin/bricky
92
92
  - etc/bricks/bundle/builder
93
93
  - etc/bricks/debian/builder
94
+ - etc/bricks/helper/builder
95
+ - etc/bricks/helper/suexec
94
96
  - etc/bricks/mounts/builder
97
+ - etc/hacker/id_container/Dockerfile
95
98
  - etc/templates/Brickyfile
96
99
  - etc/templates/bricky/bricky.yml
97
100
  - etc/templates/bricky/images/builder/Dockerfile
98
- - etc/templates/bricky/images/runtime/Dockerfile
99
101
  - lib/bricky.rb
100
102
  - lib/bricky/bricks.rb
103
+ - lib/bricky/bricks/base.rb
101
104
  - lib/bricky/bricks/bundle.rb
102
105
  - lib/bricky/bricks/debian.rb
103
106
  - lib/bricky/bricks/helper.rb
@@ -132,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
135
  version: '0'
133
136
  requirements: []
134
137
  rubyforge_project:
135
- rubygems_version: 2.4.4
138
+ rubygems_version: 2.4.3
136
139
  signing_key:
137
140
  specification_version: 4
138
141
  summary: a new way to build and package applications
@@ -1,2 +0,0 @@
1
- FROM locaweb/wheezy
2
- MAINTAINER bricky