egg 0.8.0 → 0.9.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: 6026a5fd53c8dee0e89b2e8d5955c8ad2a16da24
4
- data.tar.gz: b472e4fb29268a868cfb69b1ca5fbf65964c084c
3
+ metadata.gz: 78400ef63b85075bae4dea0fe174b765215c5d4c
4
+ data.tar.gz: a96ea239294e05e85e85d247fea18c48bfa3634d
5
5
  SHA512:
6
- metadata.gz: 6b0ee4a2cf0533f140bdfa452bd06a7ff9404887656bd58e0999ae14fa699e32213fa0d5a527be293ae1bd08163108e32592596c629fedf663464868f4223234
7
- data.tar.gz: 844ce17d559b2bcb9fdf2c591ab7001e99f30cce85ef2fc486288d230a535cc8f479712b97583dc01cb19096608ca175cc4d00cd1f179fb5c38afe0dd09f627d
6
+ metadata.gz: 4ecc1400f44c3c7ad1c452011c7d34525af61cd942aa9bf042afcdbb12fd86c98a328bfcc08eb174c5d48dc32e1aa0ff743fd962b8d08612cf8057bedbae610e
7
+ data.tar.gz: 8e99cb10911f5834bec8f0dd862ef1cf883e856f5220abef602229365b7f473651a10fb0958d3e6ffe51877fc5928d2ef17dfa84ae200ca2a4c950c16f8b186a
data/.gitignore CHANGED
@@ -8,3 +8,5 @@
8
8
 
9
9
  .idea
10
10
  /spec/examples.txt
11
+
12
+ .DS_Store
data/lib/egg.rb CHANGED
@@ -14,4 +14,3 @@ require_relative "egg/cli"
14
14
  require_relative "egg/templates"
15
15
  require_relative "egg/configuration"
16
16
  require_relative "egg/docker_compose"
17
- require_relative "egg/dockerfile"
@@ -16,7 +16,6 @@ module Egg
16
16
  else
17
17
  File.write("egg_config.rb", config.result)
18
18
  print "Wrote example egg_config.rb, customize it to suit your app"
19
- write_git_ignorance
20
19
  end
21
20
  end
22
21
 
@@ -42,15 +41,5 @@ module Egg
42
41
  config.write_docker_files
43
42
  config.docker_pull_build
44
43
  end
45
-
46
- private
47
-
48
- def write_git_ignorance
49
- gitignore = File.read(".gitignore")
50
- gitignore << "Dockerfile\n" unless /^Dockerfile$/ =~ gitignore
51
- gitignore << ".dockerignore\n" unless /^\.dockerignore$/ =~ gitignore
52
- gitignore << "docker-compose.yml\n" unless /^docker-compose\.yml$/ =~ gitignore
53
- File.write(".gitignore", gitignore)
54
- end
55
44
  end
56
45
  end
@@ -26,8 +26,7 @@ module Egg
26
26
  :ssh_support,
27
27
  :ruby_version,
28
28
  :supervisor,
29
- :dotenv,
30
- :dockerfile
29
+ :dotenv
31
30
 
32
31
  def initialize(&configuration_block)
33
32
  self.docker_compose = DockerCompose.new
@@ -35,7 +34,7 @@ module Egg
35
34
  self.ruby_version = "2.4"
36
35
  self.dotenv = DotenvUtil.new(File.read(".env.template"))
37
36
  instance_eval(&configuration_block)
38
- self # rubocop:disable Lint/Void
37
+ self
39
38
  end
40
39
 
41
40
  def after_startup(&block)
@@ -76,8 +75,6 @@ module Egg
76
75
  def write_docker_files
77
76
  dockerignore = Templates[".dockerignore"].result(binding)
78
77
  File.write(".dockerignore", dockerignore)
79
-
80
- File.write("docker-compose.yml", docker_compose.to_yaml)
81
78
  end
82
79
 
83
80
  def docker_pull_build
@@ -9,6 +9,7 @@ class DockerCompose
9
9
 
10
10
  def initialize(_compose_config = {})
11
11
  @services = []
12
+ print "Use of docker_compose is deprecated. Please craft the docker-compose.yml file yourself. This module will be dropped in a future egg."
12
13
  end
13
14
 
14
15
  def configure
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Egg
4
- VERSION = "0.8.0".freeze
4
+ VERSION = "0.9.0".freeze
5
5
  end
@@ -3,23 +3,6 @@
3
3
  Egg::Configuration.new do |config|
4
4
  # Do stuff here.
5
5
 
6
- # Example dockerfile config.
7
- # Available arguments for use: ["Ruby", "NodeJS"]
8
- # self.dockerfile = Dockerfile.use "Ruby"
9
- # self.dockerfile.ruby_version = "2.4.0"
10
- # self.dockerfile.command = "bin/rails server -p 3000"
11
- # self.dockerfile.env(dotenv.env)
12
-
13
- # Example docker_compose config:
14
- # app = config.docker_compose.service "app"
15
- # app.ports = ["3000:3000"]
16
- # app.volumes = [".:/app"]
17
-
18
- # db = config.docker_compose.service "db"
19
- # db.image = "mysql"
20
- # db.env "MYSQL_ROOT_PASSWORD", "mysqliswebscale"
21
- # app.link db
22
-
23
6
  # after_startup do
24
7
  # docker_exec "app", "rake db:setup db:seed"
25
8
  # dotenv.set("foo", "bar")
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.8.0
4
+ version: 0.9.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-10-30 00:00:00.000000000 Z
12
+ date: 2017-11-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -147,10 +147,6 @@ files:
147
147
  - lib/egg/configuration.rb
148
148
  - lib/egg/docker_compose.rb
149
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
154
150
  - lib/egg/templates.rb
155
151
  - lib/egg/version.rb
156
152
  - templates/.dockerignore
@@ -1,18 +0,0 @@
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
- print "Dockerfile.use is deprecated. Egg setup will no longer write your dockerfile, please craft it yourself."
9
- const_get("Egg::Dockerfile::#{klass}").new
10
- rescue NameError
11
- raise(NoDockerfileError, "No Dockerfile subclass for #{klass}.")
12
- end
13
- end
14
- end
15
-
16
- require_relative "dockerfile/base"
17
- require_relative "dockerfile/ruby"
18
- require_relative "dockerfile/node_js"
@@ -1,76 +0,0 @@
1
- module Egg
2
- module Dockerfile
3
- # Provides shared behavior for dockerfile template classes.
4
- class Base
5
- # Raise when before and after are both used at the same time.
6
- class QuantumStateError < RuntimeError
7
- def message
8
- "Directives cannot happen both before and after a given directive"
9
- end
10
- end
11
-
12
- attr_reader :template
13
- attr_accessor :command
14
-
15
- def initialize
16
- @template = []
17
- end
18
-
19
- def required_attributes
20
- [:command]
21
- end
22
-
23
- def render
24
- required_attributes.each do |attr|
25
- raise(MissingPropertyError, "Must populate #{attr}") if send(attr).nil?
26
- end
27
-
28
- unrendered_output = compile_unrendered_output
29
-
30
- ERB.new(unrendered_output).result(binding)
31
- end
32
-
33
- def run(command, before: [:cmd], after: nil)
34
- insert_with_before_after([:run, command], before: before, after: after)
35
- end
36
-
37
- def env(env_hash, **before_after)
38
- env_string = env_hash.reduce("") do |out, (key, value)|
39
- out << key.to_s.upcase << '="' << value.to_s << '" '
40
- end
41
- insert_with_before_after([:env, env_string], before_after)
42
- end
43
-
44
- def add(localpath, containerpath, **before_after)
45
- directive = [:add, localpath + " " + containerpath]
46
- insert_with_before_after(directive, before_after)
47
- end
48
-
49
- private
50
-
51
- def insert_with_before_after(directive, before: nil, after: nil)
52
- raise(QuantumStateError) if before && after
53
- if before
54
- template.insert(find_directive_in_template(before), directive)
55
- elsif after
56
- template.insert(find_directive_in_template(after) + 1, directive)
57
- else
58
- template << directive
59
- end
60
- end
61
-
62
- def find_directive_in_template(directive)
63
- template.index(directive) ||
64
- template.index { |tc| tc[0] == directive[0] } ||
65
- -1
66
- end
67
-
68
- def compile_unrendered_output
69
- final_template = template << [:cmd, "<%= command %>"]
70
- final_template.reduce("") do |out, (command, string)|
71
- out << command.to_s.upcase << " " << string << "\n"
72
- end
73
- end
74
- end
75
- end
76
- end
@@ -1,33 +0,0 @@
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
- ]
30
- end
31
- end
32
- end
33
- end
@@ -1,37 +0,0 @@
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