bricky 0.0.2 → 0.0.3

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
- NGFlNTJlZWNmYTg1MzIzY2ZlYjA3NmMwZWY4YzJmZDE1N2VmZjQ1ZA==
4
+ MzJjYzUzYjA5MTJlZGY1MGZjN2E2NjkwMmE5ZmI4NmY1NjZmY2Q0Ng==
5
5
  data.tar.gz: !binary |-
6
- MDQ2YjVkOTRmYzY5NzQyMTM3MTAzYTE3MzUxNjdmNGZjNjNmOGZmYQ==
6
+ NjRhM2NlNDNiMWJlNzViYTQ3ZTJkYTI2NDVmMDJjM2NhZWEyMDNjMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- N2Y2MjViZTAzNmY2NTg4ZGUzMGM1YmZjYTdkMjExOWRjOTVlN2YxNzQ4NzVi
10
- MGU1NGJhNDBlZjY1MTVhMDZiYjFkZTI5NWI3MzVlOGY5YzAyY2VhYTlhOGMx
11
- Nzc3NjFkODRkZGE4MmEwNzE1NDRhZTRiN2JlNjMwMDVkM2YxNzY=
9
+ MWM3NGY3MzE1YmJhM2QzMTAyZWNlYjI1NTk0MjcxYTUxYjA0YjZiOGU3MDlm
10
+ ZjI2N2JlMWIwOThmMjczOWM1MDRlYjM4YmE3NzQxNjUwMjkwMGY4ODA5Mzc3
11
+ ZjdmMTZmYTY0NmE1Mzk4MmQyMTU1ZDFhNTRhZWFiZDlhMjZjZjI=
12
12
  data.tar.gz: !binary |-
13
- ZWY0MWU0YjQxYmZiNjIzZjk1ZGZjMzg5OGQzN2I4MWM0MGUyZmIwZTY3ODNk
14
- Yjk5MmQwYzNjZmRhMDExOTdlYTIyNGM2ZTFlZTNmY2ZlYWJiOGE0NTQ3MmY3
15
- NjFkMjRiYTdmMTBjYmJhYTJjN2Q3NGUyOTI2YzE5MzJhYjZjOGI=
13
+ ODRjZjIxMDQxNjg4NDQ5ZTdkZjMzMzZhNzU5YzU1Zjc4NWJkYzU2NzZkYTNi
14
+ NzcyYTY4NTEzYTE4MTJlOWMzMGQ3ZDcwNTNkMWM2NGQ0NDI4MTBkY2JkMTIy
15
+ ZDAzMDFkNGRiMGNmNWYzMzdhYzE3OTcwODliZWViOWMwMGU3YTc=
@@ -0,0 +1,22 @@
1
+ module Bricky
2
+ module Bricks
3
+ class Bundle < Helper
4
+ def arguments
5
+ scripts_path = "#{bricks_path}/bundle"
6
+ results = ["-v #{scripts_path}:/bricks/bundle"]
7
+ results.push(cached) if config["cache"]
8
+ results
9
+ end
10
+
11
+ def entrypoint
12
+ "/bricks/bundle/builder"
13
+ end
14
+
15
+ private
16
+ def cached
17
+ digest = Digest::MD5.file('Gemfile').hexdigest
18
+ ["-v /tmp/bricky/cache/#{digest}:/opt/build/source/vendor/bundle"]
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,17 @@
1
+ module Bricky
2
+ module Bricks
3
+ class Debian < Helper
4
+ def arguments
5
+ builded_path = File.expand_path(config["build"])
6
+ scripts_path = "#{bricks_path}/debian"
7
+
8
+ %W(-v #{builded_path}:/builded
9
+ -v #{scripts_path}:/bricks/debian)
10
+ end
11
+
12
+ def entrypoint
13
+ "/bricks/debian/builder"
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ module Bricky
2
+ module Bricks
3
+ class Helper
4
+ attr_accessor :config
5
+
6
+ def initialize(config)
7
+ self.config = config
8
+ end
9
+
10
+ private
11
+ def bricks_path
12
+ File.expand_path("../../../../etc/bricks", __FILE__)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ module Bricky
2
+ module Bricks
3
+ class Mounts < Helper
4
+ def arguments
5
+ scripts_path = "#{bricks_path}/mounts"
6
+ command = "-v #{scripts_path}:/bricks/mounts"
7
+
8
+ config.inject([command]) do |acc, mount|
9
+ acc << "-v #{File.expand_path(mount.last)}:/bricks/mounts/volumes/#{mount.first}"
10
+ end
11
+ end
12
+
13
+ def entrypoint
14
+ "/bricks/mounts/builder"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ module Bricky
2
+ module Bricks
3
+ class Ruby < Helper
4
+ def arguments
5
+ end
6
+
7
+ def entrypoint
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,25 @@
1
+ require "byebug"
2
+ require "bricky/bricks/helper"
3
+
4
+ require "bricky/bricks/ruby"
5
+ require "bricky/bricks/bundle"
6
+ require "bricky/bricks/debian"
7
+ require "bricky/bricks/mounts"
8
+
9
+ module Bricky
10
+ module Bricks
11
+ extend self
12
+
13
+ def resolve
14
+ Bricky.config.bricks.collect do |name, config|
15
+ resolve_and_initialize(name, config)
16
+ end.uniq
17
+ end
18
+
19
+ def resolve_and_initialize(name, config)
20
+ return Bricky::Bricks::Bundle.new(config) if name.eql? "bundle"
21
+ return Bricky::Bricks::Debian.new(config) if name.eql? "debian"
22
+ return Bricky::Bricks::Mounts.new(config) if name.eql? "mounts"
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,26 @@
1
+ require "thor"
2
+ require "ostruct"
3
+ require "colorize"
4
+
5
+ require "bricky/commands/install"
6
+ require "bricky/commands/builder"
7
+ require "bricky/commands/bootstrap"
8
+
9
+ module Bricky
10
+ class Command < Thor
11
+ desc :install, "copy configuration files"
12
+ def install
13
+ Bricky::Commands::Install.new.execute
14
+ end
15
+
16
+ desc :bootstrap, "bootstrap project images"
17
+ def bootstrap
18
+ Bricky::Commands::Bootstrap.execute
19
+ end
20
+
21
+ desc :builder, "build project"
22
+ def builder
23
+ Bricky::Commands::Builder.execute
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,33 @@
1
+ module Bricky
2
+ module Commands
3
+ module Bootstrap
4
+ extend self
5
+
6
+ def execute
7
+ puts "Boostraping images".colorize(:light_blue)
8
+ images.each {|image| build(image)}
9
+ end
10
+
11
+ private
12
+ 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
19
+ end
20
+
21
+ true
22
+ end
23
+
24
+ def command(template_name, image_path)
25
+ "docker build -t #{template_name} #{image_path}"
26
+ end
27
+
28
+ def images
29
+ ["builder", "runtime"].collect {|image| Bricky::Image.new(image) }
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,35 @@
1
+ require "bricky/bricks"
2
+
3
+ module Bricky
4
+ module Commands
5
+ module Builder
6
+ extend self
7
+
8
+ def execute
9
+ puts "Building Project".colorize(:light_blue)
10
+ build(Bricky::Image.new("builder"))
11
+ end
12
+
13
+ private
14
+ def build(image)
15
+ code = command(image)
16
+ puts "Execute build: ".colorize(:blue) + code
17
+
18
+ unless system(code.gsub(/\n/, ""))
19
+ puts "~~~~~~~~~~~ Problems building image ~~~~~~~~~~~".colorize(:white).on_red
20
+ return false
21
+ end
22
+
23
+ true
24
+ end
25
+
26
+ def command(image)
27
+ bricks = Bricky::Bricks.resolve
28
+ arguments = bricks.collect(&:arguments).uniq.join(" ")
29
+ entrypoints = bricks.collect(&:entrypoint).uniq.join(";")
30
+
31
+ "docker run #{arguments} -i -t #{image.name} /bin/bash -l -c '#{entrypoints}'"
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,17 @@
1
+ module Bricky
2
+ module Commands
3
+ class Install < Thor::Group
4
+ include Thor::Actions
5
+
6
+ def execute
7
+ puts "Setup bricky configuration files".colorize(:light_blue)
8
+ directory "bricky"
9
+ copy_file "Brickyfile"
10
+ end
11
+
12
+ def self.source_root
13
+ File.expand_path("../../../../etc/templates", __FILE__)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,26 @@
1
+ require "yaml"
2
+
3
+ module Bricky
4
+ class Config
5
+ attr_accessor :name
6
+ attr_accessor :images
7
+ attr_accessor :bricks
8
+
9
+ def from_yaml(file)
10
+ config = YAML.load_file(file)["bricky"]
11
+
12
+ self.name = config["name"]
13
+ self.images = config["images"]
14
+ self.bricks = config["bricks"]
15
+ end
16
+
17
+ def full_scripts_path
18
+ File.expand_path("#{base_path}/bricky/containers/scripts", __FILE__)
19
+ end
20
+
21
+ private
22
+ def base_path
23
+ "../../.."
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,20 @@
1
+ module Bricky
2
+ class Image
3
+ attr_accessor :name
4
+ attr_accessor :path
5
+
6
+ def initialize(image)
7
+ self.name = format_name(image)
8
+ self.path = format_path(image)
9
+ end
10
+
11
+ private
12
+ def format_name(image)
13
+ "#{Bricky.config.name}/#{image}"
14
+ end
15
+
16
+ def format_path(image)
17
+ "#{Bricky.config.images}/#{image}"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ module Bricky
2
+ class Package
3
+ attr_accessor :image
4
+
5
+ def initialize(image)
6
+ self.image = image
7
+ end
8
+
9
+ project_path = File.expand_path(".")
10
+ builded_path = File.expand_path(Bricky.config.package.build)
11
+ cachedz_path = File.expand_path(Bricky.config.package.cache)
12
+
13
+ def script
14
+ "#{script_path}/#{image.name}"
15
+ end
16
+
17
+ def script_path
18
+ "#{Bricky.config.full_scripts_path}/#{Bricky.config.package.output}"
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ require "bricky/image"
2
+ require "bricky/config"
3
+
4
+ module Bricky
5
+ class Setup
6
+ def self.start
7
+ from_brickyfile
8
+ end
9
+
10
+ private
11
+ def self.from_brickyfile
12
+ configuration = "#{Dir.pwd}/Brickyfile"
13
+ if File.exists?(configuration)
14
+ eval(open("#{Dir.pwd}/Brickyfile").read)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module Bricky
2
+ VERSION = "0.0.3"
3
+ end
data/lib/bricky.rb ADDED
@@ -0,0 +1,14 @@
1
+ require "bricky/version"
2
+ require "bricky/command"
3
+
4
+ module Bricky
5
+ extend self
6
+
7
+ def configure
8
+ yield config
9
+ end
10
+
11
+ def config
12
+ @config ||= Bricky::Config.new
13
+ end
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bricky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - andrerocker
@@ -89,6 +89,22 @@ extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
91
  - bin/bricky
92
+ - lib/bricky.rb
93
+ - lib/bricky/bricks.rb
94
+ - lib/bricky/bricks/bundle.rb
95
+ - lib/bricky/bricks/debian.rb
96
+ - lib/bricky/bricks/helper.rb
97
+ - lib/bricky/bricks/mounts.rb
98
+ - lib/bricky/bricks/ruby.rb
99
+ - lib/bricky/command.rb
100
+ - lib/bricky/commands/bootstrap.rb
101
+ - lib/bricky/commands/builder.rb
102
+ - lib/bricky/commands/install.rb
103
+ - lib/bricky/config.rb
104
+ - lib/bricky/image.rb
105
+ - lib/bricky/package.rb
106
+ - lib/bricky/setup.rb
107
+ - lib/bricky/version.rb
92
108
  homepage: http://bricky.deploy42.com
93
109
  licenses:
94
110
  - MIT