stack_car 0.2.3 → 0.2.4

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: f6733f0600c47bc8fe2254c6cb13f319f95c951e
4
- data.tar.gz: 6d6ae0940f19e2f2ad7ca10878f2d359018940d9
3
+ metadata.gz: 29d6252b6c7b9f9bdc155585e7166cc3ba4bf35f
4
+ data.tar.gz: bf7a74d80e7caa0de9ecd68724c472455dc0bae9
5
5
  SHA512:
6
- metadata.gz: 1ce405538df50e3ea51e9adb2cf6664333091ba2a96689c17a09a308ad6d94e6a20531c0384fad527ca17436ab6ff698e6b6f12cbd81b133d6decbdb07de59c8
7
- data.tar.gz: 1a3c3b6627138f91875d0d0bd66bb9726e1ed3759e124bb7ee8f49602ae15ec35a64e1df51314557d39530e806b05299beb35d8a7d80dd1d549fa953d504d608
6
+ metadata.gz: 2619dad34b6a619141aa8d3a6b11cf60253dc95ecbcad07bbf839bd2cfa3bdbf2ee214de7fe6e25f20bbc3fa19a693f84022984f724dbe0473d70252c593af37
7
+ data.tar.gz: c7719812cf7bfa91d3613f69d6e5de53428f9589aa1ab5a1c46023f34f27a7380c7b28795d9267fcc6afb12432f0f096fd96f77ec30dd38731c72c674fa3a35d
data/exe/sc ADDED
@@ -0,0 +1 @@
1
+ stack_car
data/lib/stack_car/cli.rb CHANGED
@@ -12,13 +12,21 @@ module StackCar
12
12
 
13
13
  method_option :service, default: 'web', type: :string, aliases: '-s'
14
14
  method_option :build, default: false, type: :boolean, aliases: '-b'
15
+ method_option :foreground, default: false, type: :boolean, aliases: '-f'
16
+ method_option :logs, default: true, type: :boolean
15
17
  desc "up", "starts docker-compose with rebuild and orphan removal, defaults to web"
16
18
  def up
17
19
  args = ['--remove-orphans']
18
20
  args << '--build' if options[:build]
21
+ args << '-d' if !options[:foreground]
19
22
  run("rm -rf tmp/pids/server.pid")
20
23
  run("docker-compose up #{args.join(' ')} #{options[:service]}")
21
- # TODO run("docker cp #{@project_name}_#{options[:service]}_1:/bundle .")
24
+ if !options[:foreground]
25
+ @project_name = File.basename(File.expand_path('.'))
26
+ say 'copying bundle to local, you can start using the app now.'
27
+ run("docker cp #{@project_name}_#{options[:service]}_1:/bundle .") if options[:build]
28
+ run("docker-compose logs --tail --follow #{options[:service]}") if options[:logs]
29
+ end
22
30
  end
23
31
 
24
32
  method_option :service, default: '', type: :string, aliases: '-s'
@@ -28,14 +36,6 @@ module StackCar
28
36
  run("rm -rf tmp/pids/server.pid")
29
37
  end
30
38
 
31
- method_option :service, default: 'web', type: :string, aliases: '-s'
32
- desc "build", "build the services, defaults to web"
33
- def build
34
- @project_name = File.basename(File.expand_path('.'))
35
- run("docker-compose build #{options[:service]}")
36
- end
37
-
38
-
39
39
  method_option :service, default: 'web', type: :string, aliases: '-s'
40
40
  desc "walk ARGS", "wraps docker-compose run web unless --service is used to specify"
41
41
  def walk(*args)
@@ -88,6 +88,7 @@ module StackCar
88
88
  method_option :postgres, default: false, type: :boolean, aliases: '-p'
89
89
  method_option :mysql, default: false, type: :boolean, aliases: '-m'
90
90
  method_option :redis, default: false, type: :boolean, aliases: '-r'
91
+ method_option :delayed_job, default: false, type: :boolean, aliases: '-dj'
91
92
  method_option :fcrepo, default: false, type: :boolean, aliases: '-f'
92
93
  method_option :deploy, default: false, type: :boolean, aliases: '-d'
93
94
  method_option :rancher, default: false, type: :boolean, aliases: '-dr'
@@ -100,18 +101,14 @@ module StackCar
100
101
 
101
102
  Pick your dependencies by using the command line arguments
102
103
  DOCKERIZE
103
- def dockerize(dir=nil)
104
- if dir
105
- Dir.chdir(dir)
106
- else
107
- dir = '.'
108
- end
109
- @project_name = File.basename(File.expand_path(dir))
110
- @db_libs = []
111
- @db_libs << "libpq-dev postgresql-client" if options[:postgres]
112
- @db_libs << "mysql-client" if options[:mysql]
113
- @db_libs << "libc6-dev libreoffice imagemagick unzip" if options[:fcrepo]
114
- @db_libs = @db_libs.join(' ')
104
+ def dockerize(dir=".")
105
+ Dir.chdir(dir)
106
+ @project_name = File.basename(File.expand_path(dir))
107
+ @db_libs = []
108
+ @db_libs << "libpq-dev postgresql-client" if options[:postgres]
109
+ @db_libs << "mysql-client" if options[:mysql]
110
+ @db_libs << "libc6-dev libreoffice imagemagick unzip" if options[:fcrepo]
111
+ @db_libs = @db_libs.join(' ')
115
112
 
116
113
 
117
114
  ['.dockerignore', 'Dockerfile', 'docker-compose.yml', 'docker-compose-prod.yml', '.gitlab-ci.yml', '.env'].each do |template_file|
@@ -121,12 +118,16 @@ module StackCar
121
118
  template("database.yml.erb", "config/database.yml")
122
119
  empty_directory('bundle')
123
120
  run("touch bundle/.gitkeep && git add bundle/.gitkeep") unless File.exists?('bundle/.gitkeep')
124
- insert_into_file "config/environment.rb", "/bundle", :after => "/.bundle"
125
-
126
- prepend_to_file "README.md" do
127
- File.read("#{self.class.source_root}/README.md")
121
+ insert_into_file ".gitignore", "/bundle", :after => "/.bundle"
122
+ if File.exists?('README.md')
123
+ prepend_to_file "README.md" do
124
+ File.read("#{self.class.source_root}/README.md")
125
+ end
126
+ else
127
+ create_file "README.md" do
128
+ File.read("#{self.class.source_root}/README.md")
129
+ end
128
130
  end
129
-
130
131
  if options[:deploy] || options[:rancher]
131
132
  directory('ops')
132
133
  ['hosts'].each do |template_file|
@@ -135,5 +136,17 @@ module StackCar
135
136
  say 'Please update ops/hosts with the correct server addresses'
136
137
  end
137
138
  end
139
+
140
+ protected
141
+ def compose_depends(*excludes)
142
+ @compose_depends = []
143
+ services = [:postgres, :mysql, :elasticsearch, :solr, :redis, :delayed_job] - excludes
144
+ services.each do |service|
145
+ if options[service]
146
+ @compose_depends << " - #{service}"
147
+ end
148
+ end
149
+ return @compose_depends.join("\n")
150
+ end
138
151
  end
139
152
  end
@@ -1,3 +1,3 @@
1
1
  module StackCar
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
data/stack_car.gemspec CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "rspec", "~> 3.0"
25
25
  spec.add_development_dependency "yard"
26
26
  spec.add_development_dependency "yard-thor"
27
+ spec.add_development_dependency "pry"
27
28
  spec.add_dependency 'dotenv'
28
29
  spec.add_dependency 'thor'
29
30
  end
@@ -51,7 +51,7 @@ services:
51
51
  volumes:
52
52
  - 'redis:/var/lib/redis/data'
53
53
  <% end -%>
54
- <% if options[:fcrepo] %>
54
+ <% if options[:fcrepo] -%>
55
55
  fcrepo:
56
56
  image: botimer/fcrepo:4.5.1
57
57
  volumes:
@@ -59,32 +59,29 @@ services:
59
59
  ports:
60
60
  - "8984:8080"
61
61
  <% end -%>
62
- web:
62
+ main:
63
63
  build: .
64
64
  image: <%= @project_name %>:latest
65
- command: bundle exec rails s -p 3000 -b '0.0.0.0'
66
65
  volumes:
67
66
  - .:/app
68
- ports:
69
- - "3000:3000"
70
67
  env_file:
71
68
  - .env
69
+ <% if options[:delayed_job] -%>
70
+ delayed_job:
71
+ extends:
72
+ service: main
73
+ command: ./bin/delayed_job run
72
74
  depends_on:
73
- <% if options[:postgres] -%>
74
- - postgres
75
- <% end -%>
76
- <% if options[:mysql] -%>
77
- - mysql
78
- <% end -%>
79
- <% if options[:elasticsearch] -%>
80
- - elasticsearch
81
- <% end -%>
82
- <% if options[:solr] -%>
83
- - solr
84
- <% end -%>
85
- <% if options[:redis] -%>
86
- - redis
75
+ <%= compose_depends(:delayed_job) %>
87
76
  <% end -%>
77
+ web:
78
+ extends:
79
+ service: urp
80
+ command: bundle exec rails s -p 3000 -b '0.0.0.0'
81
+ ports:
82
+ - "3000:3000"
83
+ depends_on:
84
+ <%= compose_depends %>
88
85
 
89
86
  volumes:
90
87
  <% if options[:postgres] -%>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stack_car
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Kaufman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-22 00:00:00.000000000 Z
11
+ date: 2017-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: dotenv
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -168,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
182
  version: '0'
169
183
  requirements: []
170
184
  rubyforge_project:
171
- rubygems_version: 2.4.6
185
+ rubygems_version: 2.5.1
172
186
  signing_key:
173
187
  specification_version: 4
174
188
  summary: A tool to make rails + docker easy
data/exe/sc DELETED
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "stack_car"
4
-
5
- StackCar::HammerOfTheGods.start(ARGV)