egg 0.3.4 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +9 -2
- data/{leash.gemspec → egg.gemspec} +2 -1
- data/egg.png +0 -0
- data/lib/egg.rb +1 -0
- data/lib/egg/configuration.rb +11 -1
- data/lib/egg/dockerfile.rb +17 -0
- data/lib/egg/dockerfile/base.rb +41 -0
- data/lib/egg/dockerfile/node_js.rb +34 -0
- data/lib/egg/dockerfile/ruby.rb +37 -0
- data/lib/egg/version.rb +1 -1
- metadata +9 -8
- data/lib/dockerfile.rb +0 -15
- data/lib/dockerfile/base.rb +0 -39
- data/lib/dockerfile/node_js.rb +0 -30
- data/lib/dockerfile/ruby.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c067e9add07ef645fab9715f3857ebd182246d5
|
4
|
+
data.tar.gz: a8832055723ae1426ea9dc387f92252035596fba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ae5736a532bc87b07f5b1563056a46c7dcc03a056e5971b97d6b9ccdfd3357c44d618c3369a24690140b55c572896f83620034264d33dc4f8322ad4d10cef92
|
7
|
+
data.tar.gz: 35c18a6e95ee2941ae0e0c4a0f142925215d6b51937f84decc463a4f77acdecf946f80a5e075d265791d35091792607a4ced6bb0eea8650613b65dee0ada5170
|
data/.circleci/config.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
-
# Egg
|
2
1
|
|
3
|
-
|
2
|
+
<h1 align="center">
|
3
|
+
<img src="egg.png" width="300" alt="Egg">
|
4
|
+
<br>
|
5
|
+
<br>
|
6
|
+
</h1>
|
7
|
+
|
8
|
+
![CircleCI](https://circleci.com/gh/bellycard/egg.png?style=shield&circle-token=10677521a50bce69aca6ec419794d1c44d3cd12a) [![Gem Version](https://badge.fury.io/rb/egg.svg)](https://badge.fury.io/rb/egg)
|
9
|
+
|
10
|
+
> Egg helps prevent code fires! Also he makes it easy to run complex multi-service apps with Docker.
|
4
11
|
|
5
12
|
Maintainers:
|
6
13
|
* [Carl Thuringer](https://github.com/carlthuringer)
|
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
lib = File.expand_path("../lib", __FILE__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
|
5
|
+
|
6
|
+
require "egg/version"
|
6
7
|
|
7
8
|
description = <<-EOT
|
8
9
|
Egg helps initialize, manage, and execute on complex multi-service architectures using Docker and Docker Compose
|
data/egg.png
ADDED
Binary file
|
data/lib/egg.rb
CHANGED
data/lib/egg/configuration.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require "yaml"
|
4
4
|
require "fileutils"
|
5
5
|
require "dotenv_util"
|
6
|
-
require "dockerfile"
|
7
6
|
require "open3"
|
8
7
|
|
9
8
|
module Egg
|
@@ -54,6 +53,17 @@ module Egg
|
|
54
53
|
end
|
55
54
|
end
|
56
55
|
|
56
|
+
# You may pass a block to docker_run to read the output in a controlled manner.
|
57
|
+
def docker_run(app, command)
|
58
|
+
print "docker-compose run #{app} #{command}\n"
|
59
|
+
Open3.popen2(%(docker-compose run #{app} #{command})) do |_input, output, wait_thread|
|
60
|
+
output_read = output.read
|
61
|
+
print output_read + "\n"
|
62
|
+
yield output_read if block_given?
|
63
|
+
wait_thread.value.success? || raise(StandardError, "docker_run exited with #{wait_thread.value.to_i}")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
57
67
|
def run_setup
|
58
68
|
write_docker_files
|
59
69
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Egg
|
2
|
+
# Configures dockerfiles programmatically from templates.
|
3
|
+
module Dockerfile
|
4
|
+
class NoDockerfileError < StandardError; end
|
5
|
+
class MissingPropertyError < StandardError; end
|
6
|
+
|
7
|
+
def self.use(klass)
|
8
|
+
const_get("Egg::Dockerfile::#{klass}").new
|
9
|
+
rescue NameError
|
10
|
+
raise(NoDockerfileError, "No Dockerfile subclass for #{klass}.")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
require_relative "dockerfile/base"
|
16
|
+
require_relative "dockerfile/ruby"
|
17
|
+
require_relative "dockerfile/node_js"
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Egg
|
2
|
+
module Dockerfile
|
3
|
+
# Provides shared behavior for dockerfile template classes.
|
4
|
+
class Base
|
5
|
+
attr_reader :template
|
6
|
+
attr_accessor :command
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@template = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def required_attributes
|
13
|
+
[:command]
|
14
|
+
end
|
15
|
+
|
16
|
+
def render
|
17
|
+
required_attributes.each do |attr|
|
18
|
+
raise(MissingPropertyError, "Must populate #{attr}") if send(attr).nil?
|
19
|
+
end
|
20
|
+
|
21
|
+
unrendered_output = template.reduce("") do |out, (command, string)|
|
22
|
+
out << command.to_s.upcase << " " << string << "\n"
|
23
|
+
end
|
24
|
+
|
25
|
+
ERB.new(unrendered_output).result(binding)
|
26
|
+
end
|
27
|
+
|
28
|
+
def run(command, before: [:cmd])
|
29
|
+
template.insert(do_before(before), [:run, command])
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def do_before(before)
|
35
|
+
template.index(before) ||
|
36
|
+
template.index { |tc| tc[0] == before[0] } ||
|
37
|
+
-1
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Egg
|
2
|
+
module Dockerfile
|
3
|
+
# NodeJS Dockerfile Template
|
4
|
+
# Required Attributes:
|
5
|
+
# @node_version: Version of Ruby to use for the ruby image.
|
6
|
+
class NodeJS < Base
|
7
|
+
def required_attributes
|
8
|
+
super + [:node_version]
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_accessor :node_version
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@template = dockerfile
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def dockerfile # rubocop:disable Metrics/MethodLength
|
20
|
+
[
|
21
|
+
[:from, "node:<%= node_version %>"],
|
22
|
+
[:env, "APP_HOME /app"],
|
23
|
+
[:run, "mkdir $APP_HOME"],
|
24
|
+
[:workdir, "$APP_HOME"],
|
25
|
+
[:add, "package.json $APP_HOME/"],
|
26
|
+
[:add, "yarn.lock $APP_HOME/"],
|
27
|
+
[:run, "yarn install"],
|
28
|
+
[:add, ". $APP_HOME"],
|
29
|
+
[:cmd, "<%= command %>"]
|
30
|
+
]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Egg
|
2
|
+
module Dockerfile
|
3
|
+
# Ruby Dockerfile Template
|
4
|
+
# Required Attributes:
|
5
|
+
# @ruby_version: Version of Ruby to use for the ruby image.
|
6
|
+
class Ruby < Base
|
7
|
+
def required_attributes
|
8
|
+
super + [:ruby_version]
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_accessor :ruby_version
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@template = dockerfile
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def dockerfile # rubocop:disable Metrics/MethodLength
|
20
|
+
[
|
21
|
+
[:from, "ruby:<%= ruby_version %>"],
|
22
|
+
[:run, "apt-get update -qq && apt-get upgrade -qqy"],
|
23
|
+
[:run, "apt-get -qqy install cmake"],
|
24
|
+
[:run, "gem install bundler"],
|
25
|
+
[:env, "APP_HOME /app"],
|
26
|
+
[:run, "mkdir $APP_HOME"],
|
27
|
+
[:workdir, "$APP_HOME"],
|
28
|
+
[:add, ".ruby-version $APP_HOME/"],
|
29
|
+
[:add, "Gemfile* $APP_HOME/"],
|
30
|
+
[:env, "BUNDLE_GEMFILE=$APP_HOME/Gemfile BUNDLE_JOBS=4 BUNDLE_WITHOUT=production:staging"],
|
31
|
+
[:run, "bundle install"],
|
32
|
+
[:add, ". $APP_HOME"]
|
33
|
+
]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/egg/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: egg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carl Thuringer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-09-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -138,18 +138,19 @@ files:
|
|
138
138
|
- bin/console
|
139
139
|
- bin/setup
|
140
140
|
- doc/README.md
|
141
|
+
- egg.gemspec
|
142
|
+
- egg.png
|
141
143
|
- exe/egg
|
142
|
-
- leash.gemspec
|
143
|
-
- lib/dockerfile.rb
|
144
|
-
- lib/dockerfile/base.rb
|
145
|
-
- lib/dockerfile/node_js.rb
|
146
|
-
- lib/dockerfile/ruby.rb
|
147
144
|
- lib/dotenv_util.rb
|
148
145
|
- lib/egg.rb
|
149
146
|
- lib/egg/cli.rb
|
150
147
|
- lib/egg/configuration.rb
|
151
148
|
- lib/egg/docker_compose.rb
|
152
149
|
- lib/egg/docker_compose/service.rb
|
150
|
+
- lib/egg/dockerfile.rb
|
151
|
+
- lib/egg/dockerfile/base.rb
|
152
|
+
- lib/egg/dockerfile/node_js.rb
|
153
|
+
- lib/egg/dockerfile/ruby.rb
|
153
154
|
- lib/egg/templates.rb
|
154
155
|
- lib/egg/version.rb
|
155
156
|
- templates/.dockerignore
|
@@ -177,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
178
|
version: '0'
|
178
179
|
requirements: []
|
179
180
|
rubyforge_project:
|
180
|
-
rubygems_version: 2.6.
|
181
|
+
rubygems_version: 2.6.13
|
181
182
|
signing_key:
|
182
183
|
specification_version: 4
|
183
184
|
summary: Egg helps you develop with Docker!
|
data/lib/dockerfile.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# Module that wraps configuration of Dockerfiles from Templates.
|
2
|
-
module Dockerfile
|
3
|
-
class NoDockerfileError < StandardError; end
|
4
|
-
class MissingPropertyError < StandardError; end
|
5
|
-
|
6
|
-
def self.use(klass)
|
7
|
-
const_get("Dockerfile::#{klass}").new
|
8
|
-
rescue NameError
|
9
|
-
raise(NoDockerfileError, "No Dockerfile subclass for #{klass}.")
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
require_relative "dockerfile/base"
|
14
|
-
require_relative "dockerfile/ruby"
|
15
|
-
require_relative "dockerfile/node_js"
|
data/lib/dockerfile/base.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
module Dockerfile
|
2
|
-
# Provides shared behavior for dockerfile template classes.
|
3
|
-
class Base
|
4
|
-
attr_reader :template
|
5
|
-
attr_accessor :command
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
@template = []
|
9
|
-
end
|
10
|
-
|
11
|
-
def required_attributes
|
12
|
-
[:command]
|
13
|
-
end
|
14
|
-
|
15
|
-
def render
|
16
|
-
required_attributes.each do |attr|
|
17
|
-
raise(MissingPropertyError, "Must populate #{attr}") if send(attr).nil?
|
18
|
-
end
|
19
|
-
|
20
|
-
unrendered_output = template.reduce("") do |out, (command, string)|
|
21
|
-
out << command.to_s.upcase << " " << string << "\n"
|
22
|
-
end
|
23
|
-
|
24
|
-
ERB.new(unrendered_output).result(binding)
|
25
|
-
end
|
26
|
-
|
27
|
-
def run(command, before: [:cmd])
|
28
|
-
template.insert(do_before(before), [:run, command])
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def do_before(before)
|
34
|
-
template.index(before) ||
|
35
|
-
template.index { |tc| tc[0] == before[0] } ||
|
36
|
-
-1
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/lib/dockerfile/node_js.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
module Dockerfile
|
2
|
-
# Wrapper for templating of NodeJS Dockerfile
|
3
|
-
class NodeJS < Base
|
4
|
-
def required_attributes
|
5
|
-
super + [:node_version]
|
6
|
-
end
|
7
|
-
|
8
|
-
attr_accessor :node_version
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
@template = dockerfile
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def dockerfile # rubocop:disable Metrics/MethodLength
|
17
|
-
[
|
18
|
-
[:from, "node:<%= node_version %>"],
|
19
|
-
[:env, "APP_HOME /app"],
|
20
|
-
[:run, "mkdir $APP_HOME"],
|
21
|
-
[:workdir, "$APP_HOME"],
|
22
|
-
[:add, "package.json $APP_HOME/"],
|
23
|
-
[:add, "yarn.lock $APP_HOME/"],
|
24
|
-
[:run, "yarn install"],
|
25
|
-
[:add, ". $APP_HOME"],
|
26
|
-
[:cmd, "<%= command %>"]
|
27
|
-
]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
data/lib/dockerfile/ruby.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
module Dockerfile
|
2
|
-
# Ruby Dockerfile Template
|
3
|
-
# Required Attributes:
|
4
|
-
# @ruby_version: Version of Ruby to use for the ruby image.
|
5
|
-
class Ruby < Base
|
6
|
-
def required_attributes
|
7
|
-
super + [:ruby_version]
|
8
|
-
end
|
9
|
-
|
10
|
-
attr_accessor :ruby_version
|
11
|
-
|
12
|
-
def initialize
|
13
|
-
@template = dockerfile
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def dockerfile # rubocop:disable Metrics/MethodLength
|
19
|
-
[
|
20
|
-
[:from, "ruby:<%= ruby_version %>"],
|
21
|
-
[:run, "apt-get update -qq && apt-get upgrade -qqy"],
|
22
|
-
[:run, "apt-get -qqy install cmake"],
|
23
|
-
[:run, "gem install bundler"],
|
24
|
-
[:env, "APP_HOME /app"],
|
25
|
-
[:run, "mkdir $APP_HOME"],
|
26
|
-
[:workdir, "$APP_HOME"],
|
27
|
-
[:add, ".ruby-version $APP_HOME/"],
|
28
|
-
[:add, "Gemfile* $APP_HOME/"],
|
29
|
-
[:env, "BUNDLE_GEMFILE=$APP_HOME/Gemfile BUNDLE_JOBS=4 BUNDLE_WITHOUT=production:staging"],
|
30
|
-
[:run, "bundle install"],
|
31
|
-
[:add, ". $APP_HOME"]
|
32
|
-
]
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|