stack_car 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 20fa3436420a3bbd3aa42dedc6a623d24bef19b6
4
+ data.tar.gz: cc5db5c79c5317c7646c8f4ed0ef8140cf717777
5
+ SHA512:
6
+ metadata.gz: 5f60e7d970e3b5ddfbd078ea31ca0310c18c51d6a1221ea674274e02e530e0c48c10e8bbb75d48a940e6ff0b6c181347143f62a5c4dad238aba6a7b5269e6060
7
+ data.tar.gz: 2ccd9f75861cabb3f6ff31af734771e7a6875088746db88e3656ba2323b9abee770e99a80cdcb0fd0117230f347d5842126138f78d2342464ce41a5d9bf2af0c
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ **/.#*
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.0
5
+ before_install: gem install bundler -v 1.13.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in stack_car.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # StackCar
2
+
3
+ ## TODO
4
+ Implement UP
5
+ Implement build
6
+ Fill out readme
7
+ Work on docs
8
+ Implement deploy
9
+ Implement deploy templates
10
+ Implement database dump and restore
11
+ Implement secret sync
12
+ Convox live code reload?
13
+
14
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/stack_car`. To experiment with that code, run `bin/console` for an interactive prompt.
15
+
16
+ TODO: Delete this and the text above, and describe your gem
17
+
18
+ ## Installation
19
+
20
+ Add this line to your application's Gemfile:
21
+
22
+ ```ruby
23
+ gem 'stack_car'
24
+ ```
25
+
26
+ And then execute:
27
+
28
+ $ bundle
29
+
30
+ Or install it yourself as:
31
+
32
+ $ gem install stack_car
33
+
34
+ ## Usage
35
+
36
+ TODO: Write usage instructions here
37
+
38
+ ## Development
39
+
40
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
41
+
42
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
43
+
44
+ ## Contributing
45
+
46
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/stack_car.
47
+
48
+ ## TODO
49
+ pull down db dumps
50
+ push up db dumps
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "stack_car"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/sc ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "stack_car"
4
+
5
+ StackCar::HammerOfTheGods.start(ARGV)
data/exe/stack_car ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "stack_car"
4
+
5
+ StackCar::HammerOfTheGods.start(ARGV)
@@ -0,0 +1,71 @@
1
+ require 'thor'
2
+ require 'erb'
3
+ module StackCar
4
+ class HammerOfTheGods < Thor
5
+ include Thor::Actions
6
+ desc "up", "starts docker-compose with rebuild and orphan removal"
7
+ def up
8
+ %x{docker-compose up --build --remove-orphans}
9
+ end
10
+
11
+ method_option :service, default: 'web', type: :string, aliases: '-s'
12
+ desc "exec ARGS", "wraps docker-compose exec web unless --service is used to specify"
13
+ def exec(args)
14
+ run("docker-compose exec #{options[:service]} #{args}")
15
+ end
16
+ map e: :exec
17
+
18
+ method_option :service, default: 'web', type: :string, aliases: '-s'
19
+ desc "bundle_exec ARGS", "wraps docker-compose exec web bundle exec unless --service is used to specify"
20
+ def bundle_exec(*args)
21
+ run("docker-compose exec #{options[:service]} bundle exec #{args.join(' ')}")
22
+ end
23
+ map be: :bundle_exec
24
+
25
+ method_option :service, default: 'web', type: :string, aliases: '-s'
26
+ desc "console ARGS", "shortcut to start rails console"
27
+ def console(*args)
28
+ run("docker-compose exec #{options[:service]} bundle exec rails console #{args.join(' ')}")
29
+ end
30
+ map rc: :console
31
+
32
+ method_option :service, default: 'web', type: :string, aliases: '-s'
33
+ desc "restart", "shortcut to restart rails server"
34
+ def restart(*args)
35
+ run("docker-compose exec #{options[:service]} touch tmp/restart.txt")
36
+ end
37
+
38
+ method_option :elasticsearch, default: false, type: :boolean, aliases: '-e'
39
+ method_option :solr, default: false, type: :boolean, aliases: '-s'
40
+ method_option :postgres, default: false, type: :boolean, aliases: '-p'
41
+ method_option :mysql, default: false, type: :boolean, aliases: '-m'
42
+ method_option :redis, default: false, type: :boolean, aliases: '-r'
43
+ method_option :sidekiq, default: false, type: :boolean, aliases: '-sq' # TODO
44
+ method_option :mongodb, default: false, type: :boolean, aliases: '-mg' # TODO
45
+ desc 'dockerize DIR', 'Will copy the docker tempates in to your project, see options for supported dependencies'
46
+ long_desc <<-DOCKERIZE
47
+
48
+ `sc dockerize OPTIONS .` will create a set of docker templates to set up a project with docker
49
+
50
+ Pick your dependencies by using the command line arguments
51
+ DOCKERIZE
52
+ def dockerize(dir=nil)
53
+ if dir
54
+ Dir.chdir(dir)
55
+ end
56
+ project_name = File.basename(File.expand_path(dir))
57
+ db_libs = []
58
+ db_libs << "libpq-dev postgresql-client" if options[:postgres]
59
+ db_libs << "mysql-client" if options[:mysql]
60
+ db_libs = db_libs.join(' ')
61
+
62
+ template_path = File.join(File.dirname(__FILE__), '..', '..', 'templates')
63
+ ['.dockerignore', 'Dockerfile', 'docker-compose.yml', 'docker-compose-prod.yml'].each do |template|
64
+
65
+ renderer = ERB.new(File.read(File.join(template_path, template + '.erb')), 0, '-')
66
+ File.write(template, renderer.result(binding))
67
+ end
68
+ end
69
+
70
+ end
71
+ end
@@ -0,0 +1,3 @@
1
+ module StackCar
2
+ VERSION = "0.1.0"
3
+ end
data/lib/stack_car.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "stack_car/version"
2
+ require "stack_car/cli"
3
+
4
+ module StackCar
5
+ # Your code goes here...
6
+ end
data/stack_car.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'stack_car/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "stack_car"
8
+ spec.version = StackCar::VERSION
9
+ spec.authors = ["Rob Kaufman"]
10
+ spec.email = ["rob@notch8.com"]
11
+
12
+ spec.summary = %q{A tool to make rails + docker easy}
13
+ spec.homepage = "https://gitlab.com/notch8/stack_car"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.13"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+
26
+ spec.add_dependency 'thor'
27
+ end
@@ -0,0 +1,8 @@
1
+ .bundle
2
+ .convox
3
+ .env
4
+ .git
5
+ db/*.sqlite3
6
+ db/*.sqlite3-journal
7
+ log/*
8
+ tmp
@@ -0,0 +1,10 @@
1
+ <% if options[:postgres] -%>
2
+ POSTGRES_DB=<%= project_name %>
3
+ POSTGRES_USER=postgres
4
+ POSTGRES_PASSWORD=DatabaseFTW
5
+ <% end -%>
6
+
7
+ <% if options[:mysql] -%>
8
+ MYSQL_DATABASE=<%= project_name %>
9
+ MYSQL_ROOT_PASSWORD=<%= DatabaseFTW %>
10
+ <% end -%>
@@ -0,0 +1,68 @@
1
+ services:
2
+ - docker:dind
3
+ <% if options[:postgres] -%>
4
+ - postgres:latest
5
+ <% end -%>
6
+ <% if options[:mysql] -%>
7
+ - mysql:latest
8
+ <% end -%>
9
+ <% if options[:solr] -%>
10
+ - solr:latest
11
+ <% end -%>
12
+ <% if options[:elasticsearch] -%>
13
+ - elasticsearch:latest
14
+ <% end -%>
15
+ <% if options[:redis] -%>
16
+ - redis:latest
17
+ <% end -%>
18
+
19
+ variables:
20
+ <% if options[:postgres] -%>
21
+ POSTGRES_DB: <%= project_name %>
22
+ POSTGRES_USER: postgres
23
+ POSTGRES_PASSWORD: DatabaseFTW
24
+ <% end -%>
25
+ <% if options[:MYSQL] -%>
26
+ MYSQL_DATABASE: <%= project_name %>
27
+ MYSQL_ROOT_PASSWORD: DatabaseFTW
28
+ <% end -%>
29
+
30
+
31
+ stages:
32
+ - build
33
+ - test
34
+ - deploy
35
+
36
+ build:
37
+ stage: build
38
+ image: docker:latest
39
+ script:
40
+ - docker info
41
+ - docker login -u "gitlab-ci-token" -p "$CI_BUILD_TOKEN" $CI_REGISTRY
42
+ - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME" .
43
+ - docker push "$CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME"
44
+
45
+ test:
46
+ image: $CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME
47
+ script:
48
+ - bundle install --path /cache
49
+ - bundle exec rake db:create db:migrate db:test:prepare RAILS_ENV=test
50
+ - bundle exec rake
51
+ - bundle exec rake assets:precompile
52
+
53
+ staging:
54
+ image: $CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME
55
+ type: deploy
56
+ script:
57
+ - gem install dpl multi_json
58
+ - # TODO DEPLOY COMMAND dpl --provider=heroku --app=east-west-payroll-staging --api-key=$HEROKU_STAGING_API_KEY
59
+ only:
60
+ - master
61
+
62
+ production:
63
+ image: $CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME
64
+ type: deploy
65
+ script:
66
+ - gem install dpl multi_json
67
+ - # TODO DEPLOY COMMAND dpl --provider=heroku --app=east-west-payroll --api-key=$HEROKU_PRODUCTION_API_KEY
68
+ when: manual
@@ -0,0 +1,18 @@
1
+ FROM ruby:2.3.0
2
+
3
+ RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs mysql-client pv libsasl2-dev
4
+
5
+ ENV APP_HOME /app
6
+
7
+ RUN mkdir $APP_HOME
8
+ WORKDIR $APP_HOME
9
+
10
+ ENV BUNDLE_GEMFILE=$APP_HOME/Gemfile \
11
+ BUNDLE_JOBS=2 \
12
+ BUNDLE_PATH=/bundle
13
+ ADD Gemfile* $APP_HOME/
14
+ RUN bundle install
15
+
16
+ RUN npm install -g bower
17
+ RUN rake bower:install
18
+
@@ -0,0 +1,13 @@
1
+ version: '2'
2
+ services:
3
+ web:
4
+ image: <%= project_name %>:latest
5
+ command: bundle exec rails s -p 3000 -b '0.0.0.0'
6
+ environment:
7
+ - RAILS_ENV=production
8
+ - RACK_ENV=production
9
+ restart: unless-stopped
10
+ ports:
11
+ - "3000:3000"
12
+ volumes:
13
+ - .:/app
@@ -0,0 +1,106 @@
1
+ version: '2'
2
+ services:
3
+ <% if options[:postgres] -%>
4
+ postgres:
5
+ image: postgres
6
+ environment:
7
+ POSTGRES_DB: "${POSTGRES_DB}"
8
+ POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}"
9
+ POSTGRES_USER: "${POSTGRES_USER}"
10
+ ports:
11
+ - "5432"
12
+ volumes:
13
+ - 'postgres:/var/lib/postgresql/data'
14
+ <% end -%>
15
+ <% if options[:mysql] -%>
16
+ mysql:
17
+ image: mysql
18
+ environment:
19
+ MYSQL_DATABASE: "${MYSQL_DATABASE}"
20
+ MYSQL_ROOT_PASSWORD: "${MYSQL_ROOT_PASSWORD}"
21
+ ports:
22
+ - '3306'
23
+ volumes:
24
+ - 'mysql:/var/lib/mysql'
25
+ <% end -%>
26
+
27
+ <% if options[:solr] %>
28
+ solr:
29
+ image: solr:latest
30
+ ports:
31
+ - "8983"
32
+ volumes:
33
+ - 'solr:/opt/solr/server/solr/mycores'
34
+ entrypoint:
35
+ - docker-entrypoint.sh
36
+ - solr-precreate
37
+ - mycore
38
+ # docker-compose exec --user=solr solr bin/solr create_core -c CORENAME
39
+ <% end -%>
40
+
41
+ <% if options[:elasticsearchi] -%>
42
+ elasticsearch:
43
+ image: elasticsearch:1.7.1
44
+ ports:
45
+ - "9200"
46
+ - "9300"
47
+ volumes:
48
+ - 'elasticsearch:/usr/share/elasticsearch/data'
49
+ <% end -%>
50
+
51
+ <% if options[:redis] -%>
52
+ redis:
53
+ image: 'redis:3.2-alpine'
54
+ command: redis-server
55
+ ports:
56
+ - '6379'
57
+ volumes:
58
+ - 'redis:/var/lib/redis/data'
59
+ <% end -%>
60
+
61
+ web:
62
+ build: .
63
+ image: <%= project_name %>:latest
64
+ command: bundle exec rails s -p 3000 -b '0.0.0.0'
65
+ volumes:
66
+ - .:/app
67
+ - 'bundle:/bundle'
68
+ ports:
69
+ - "3000:3000"
70
+ environment:
71
+ - RAILS_ENV=development
72
+ - RACK_ENV=development
73
+ links:
74
+ <% if options[:postgres] -%>
75
+ - postgres
76
+ <% end -%>
77
+ <% if options[:mysql] -%>
78
+ - mysql
79
+ <% end -%>
80
+ <% if options[:redis] -%>
81
+ - redis
82
+ <% end -%>
83
+ <% if options[:elasticsearch] -%>
84
+ - elasticsearch
85
+ <% end -%>
86
+ <% if options[:solr] -%>
87
+ - solr
88
+ <% end -%>
89
+
90
+ volumes:
91
+ bundle:
92
+ <% if options[:postgres] -%>
93
+ postgres:
94
+ <% end -%>
95
+ <% if options[:mysql] -%>
96
+ mysql:
97
+ <% end -%>
98
+ <% if options[:redis] -%>
99
+ redis:
100
+ <% end -%>
101
+ <% if options[:elasticsearch] -%>
102
+ elasticsearch:
103
+ <% end -%>
104
+ <% if options[:solr] -%>
105
+ solr:
106
+ <% end -%>
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stack_car
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rob Kaufman
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-12-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email:
71
+ - rob@notch8.com
72
+ executables:
73
+ - sc
74
+ - stack_car
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - ".rspec"
80
+ - ".travis.yml"
81
+ - Gemfile
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - exe/sc
87
+ - exe/stack_car
88
+ - lib/stack_car.rb
89
+ - lib/stack_car/cli.rb
90
+ - lib/stack_car/version.rb
91
+ - stack_car.gemspec
92
+ - templates/.dockerignore.erb
93
+ - templates/.env.erb
94
+ - templates/.gitlab-ci.yml.erb
95
+ - templates/Dockerfile.erb
96
+ - templates/docker-compose-prod.yml.erb
97
+ - templates/docker-compose.yml.erb
98
+ homepage: https://gitlab.com/notch8/stack_car
99
+ licenses: []
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.4.6
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: A tool to make rails + docker easy
121
+ test_files: []