stack_car 0.2.8 → 0.3.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: e5c18ca3a905df3da0c9039321540b89745d2423
4
- data.tar.gz: 73bb0eccbcf82a7bd062c480eeb4444976c71195
3
+ metadata.gz: ab548993e40ac69f202ebd527b9267a894384564
4
+ data.tar.gz: e83132c55cb05ecbfa64030fc4ef1c285a30e4ea
5
5
  SHA512:
6
- metadata.gz: 3f0d974686a5500bf35d12c4ec3f69f1c1b5093e82ea8105529ab386c7b664c633ffc927398c4807a98674481d3f3ebe8b77ff05bb5a1425a4360fcd1137eff1
7
- data.tar.gz: 550714d0683a6f3f0b7abd35b8b9899a7a4143066c450fb73adfcc88538f57c9da72c41808c131be270f14e2dbdb0da5f2dd812a76e184f05cb7b586177785e6
6
+ metadata.gz: 83328c92add8711e0d8a22519de375069ad8f3b11e5741eca0daaee75305564bdda5038f74183cb6da4b2c0da830791dfb2a2ea613761720b80fb373be6e99dc
7
+ data.tar.gz: 070fc4e7bf7d2d00a3b0607ac23d20ae77f33c3fdf398b605383c362dd527167634c64c3b2002738d6a4320b635cd8bbf9815536f8fd9c969fc882283789dacd
data/exe/sc CHANGED
@@ -1 +1 @@
1
- stack_car
1
+ exe/stack_car
data/lib/stack_car/cli.rb CHANGED
@@ -12,25 +12,16 @@ 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
15
  method_option :logs, default: true, type: :boolean
17
16
  desc "up", "starts docker-compose with rebuild and orphan removal, defaults to web"
18
17
  def up
19
18
  args = ['--remove-orphans']
20
19
  args << '--build' if options[:build]
21
- args << '-d' if !options[:foreground]
22
20
  if options[:build]
23
21
  run("docker-compose pull #{options[:service]}")
24
22
  end
25
23
 
26
24
  run("docker-compose up #{args.join(' ')} #{options[:service]}")
27
-
28
- if options[:build]
29
- @project_name = File.basename(File.expand_path('.'))
30
- say 'copying bundle to local, you can start using the app now.'
31
- run("docker cp #{@project_name}_#{options[:service]}_1:/bundle .") if options[:build]
32
- end
33
- run("docker-compose logs --tail 20 --follow ") if options[:logs]
34
25
  end
35
26
 
36
27
  method_option :service, default: '', type: :string, aliases: '-s'
@@ -63,8 +54,6 @@ module StackCar
63
54
  desc "bundle ARGS", "wraps docker-compose run web unless --service is used to specify"
64
55
  def bundle(*args)
65
56
  run("docker-compose exec #{options[:service]} bundle")
66
- @project_name = File.basename(File.expand_path('.'))
67
- run("docker cp #{@project_name}_#{options[:service]}_1:/bundle .")
68
57
  end
69
58
 
70
59
  method_option :service, default: 'web', type: :string, aliases: '-s'
@@ -119,9 +108,10 @@ module StackCar
119
108
  method_option :postgres, default: false, type: :boolean, aliases: '-p'
120
109
  method_option :mysql, default: false, type: :boolean, aliases: '-m'
121
110
  method_option :redis, default: false, type: :boolean, aliases: '-r'
122
- method_option :delayed_job, default: false, type: :boolean, aliases: '-dj'
111
+ method_option :delayed_job, default: false, type: :boolean, aliases: '-j'
123
112
  method_option :fcrepo, default: false, type: :boolean, aliases: '-f'
124
113
  method_option :deploy, default: false, type: :boolean, aliases: '-d'
114
+ method_option :heroku, default: false, type: :boolean, aliases: '-h'
125
115
  method_option :rancher, default: false, type: :boolean, aliases: '-dr'
126
116
  method_option :sidekiq, default: false, type: :boolean, aliases: '-sq' # TODO
127
117
  method_option :mongodb, default: false, type: :boolean, aliases: '-mg'
@@ -148,9 +138,6 @@ module StackCar
148
138
  template("#{template_file}.erb", template_file)
149
139
  end
150
140
  template("database.yml.erb", "config/database.yml")
151
- empty_directory('bundle')
152
- run("touch bundle/.gitkeep && git add bundle/.gitkeep") unless File.exists?('bundle/.gitkeep')
153
- insert_into_file ".gitignore", "/bundle", :after => "/.bundle"
154
141
  if File.exists?('README.md')
155
142
  prepend_to_file "README.md" do
156
143
  File.read("#{self.class.source_root}/README.md")
@@ -166,6 +153,13 @@ module StackCar
166
153
  template("#{template_file}.erb", "ops/#{template_file}")
167
154
  end
168
155
  say 'Please update ops/hosts with the correct server addresses'
156
+ else
157
+ empty_directory('ops')
158
+ end
159
+
160
+ # Do this after we figure out whether to use an empty ops directory or a full one
161
+ ['env.conf', 'webapp.conf'].each do |template_file|
162
+ template("#{template_file}.erb", "ops/#{template_file}")
169
163
  end
170
164
  end
171
165
 
@@ -1,3 +1,3 @@
1
1
  module StackCar
2
- VERSION = "0.2.8"
2
+ VERSION = "0.3.0"
3
3
  end
data/stack_car.gemspec CHANGED
@@ -25,6 +25,6 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "yard"
26
26
  spec.add_development_dependency "yard-thor"
27
27
  spec.add_development_dependency "pry"
28
- spec.add_dependency 'dotenv'
29
- spec.add_dependency 'thor'
28
+ spec.add_dependency "dotenv", "~> 2.0"
29
+ spec.add_dependency "thor", "~> 0.19"
30
30
  end
data/templates/.env.erb CHANGED
@@ -17,5 +17,7 @@ TEST_DB=<%= @project_name %>_test
17
17
  REGISTRY_HOST=registry.gitlab.com
18
18
  REGISTRY_URI=/TODO/<%= @project_name %>
19
19
  SITE_URI=https://TODO.com
20
+ DEPLOY_HOOK=TODO
20
21
  <% end -%>
21
22
  TAG=dev
23
+ VIRUAL_PORT=80
@@ -1,21 +1,21 @@
1
1
  image: docker:latest
2
2
  services:
3
3
  - docker:dind
4
- <% if options[:postgres] -%>
4
+ <% if options[:postgres] -%>
5
5
  - postgres:latest
6
- <% end -%>
7
- <% if options[:mysql] -%>
6
+ <% end -%>
7
+ <% if options[:mysql] -%>
8
8
  - mysql:latest
9
- <% end -%>
10
- <% if options[:solr] -%>
9
+ <% end -%>
10
+ <% if options[:solr] -%>
11
11
  - solr:latest
12
- <% end -%>
13
- <% if options[:elasticsearch] -%>
12
+ <% end -%>
13
+ <% if options[:elasticsearch] -%>
14
14
  - elasticsearch:latest
15
- <% end -%>
16
- <% if options[:redis] -%>
15
+ <% end -%>
16
+ <% if options[:redis] -%>
17
17
  - redis:latest
18
- <% end -%>
18
+ <% end -%>
19
19
 
20
20
  stages:
21
21
  - build
@@ -25,15 +25,15 @@ stages:
25
25
  - production
26
26
 
27
27
  variables:
28
- <% if options[:postgres] -%>
28
+ <% if options[:postgres] -%>
29
29
  POSTGRES_DB: <%= @project_name %>
30
30
  POSTGRES_USER: postgres
31
31
  POSTGRES_PASSWORD: DatabaseFTW
32
- <% end -%>
33
- <% if options[:MYSQL] -%>
32
+ <% end -%>
33
+ <% if options[:MYSQL] -%>
34
34
  MYSQL_DATABASE: <%= @project_name %>
35
35
  MYSQL_ROOT_PASSWORD: DatabaseFTW
36
- <% end -%>
36
+ <% end -%>
37
37
  TEST_DB: <%= @project_name %>
38
38
  DOCKER_DRIVER: overlay
39
39
 
@@ -85,12 +85,12 @@ review:
85
85
  stop_review:
86
86
  stage: review
87
87
  script:
88
- <% if options[:rancher] -%>
88
+ <% if options[:rancher] -%>
89
89
  - wget https://github.com/rancher/cli/releases/download/v0.4.1/rancher-linux-amd64-v0.4.1.tar.gz
90
90
  - tar zxfv rancher-linux-amd64-v0.4.1.tar.gz
91
91
  - export RANCHER_ENVIRONMENT=staging
92
92
  - ./rancher-v0.4.1/rancher rm $CI_BUILD_REF_SLUG
93
- <% end %>
93
+ <% end %>
94
94
  variables:
95
95
  GIT_STRATEGY: none
96
96
  when: manual
@@ -102,13 +102,13 @@ staging:
102
102
  stage: staging
103
103
  type: deploy
104
104
  script:
105
- <% if options[:rancher] -%>
106
- - wget https://github.com/rancher/cli/releases/download/v0.4.1/rancher-linux-amd64-v0.4.1.tar.gz
107
- - tar zxfv rancher-linux-amd64-v0.4.1.tar.gz
108
- - export RANCHER_ENVIRONMENT=staging
109
- - export TAG=master
110
- - ./rancher-v0.4.1/rancher up -p -d -u -c -f docker-compose-ci.yml --stack $CI_BUILD_REF_SLUG
111
- <% end -%>
105
+ <% if options[:rancher] -%>
106
+ - ./ops/deploy-app
107
+ <% end -%>
108
+ <% if options[:heroku] -%>
109
+ - gem install dpl multi_json
110
+ - dpl --provider=heroku --app=<%= @project_name %>-staging --api-key=$HEROKU_STAGING_API_KEY --run="bundle exec rake db:migrate"
111
+ <% end -%>
112
112
  only:
113
113
  - master
114
114
  variables:
@@ -120,12 +120,13 @@ production:
120
120
  stage: production
121
121
  type: deploy
122
122
  script:
123
- <% if options[:rancher] -%>
124
- - wget https://github.com/rancher/cli/releases/download/v0.4.1/rancher-linux-amd64-v0.4.1.tar.gz
125
- - tar zxfv rancher-linux-amd64-v0.4.1.tar.gz
126
- - export RANCHER_ENVIRONMENT=production
127
- - ./rancher-v0.4.1/rancher up -p -d -u -c -f docker-compose-prod.yml
128
- <% end -%>
123
+ <% if options[:rancher] -%>
124
+ - ./ops/deploy-app
125
+ <% end -%>
126
+ <% if options[:heroku] -%>
127
+ - gem install dpl multi_json
128
+ - dpl --provider=heroku --app=<%= @project_name %> --api-key=$HEROKU_PRODUCTION_API_KEY --run="bundle exec rake db:migrate"
129
+ <% end -%>
129
130
  when: manual
130
131
  only:
131
132
  - master
@@ -12,17 +12,30 @@ RUN mkdir -p /opt/fits && \
12
12
  chmod +x fits-0.8.5/fits.sh
13
13
 
14
14
  <% end -%>
15
- ENV APP_HOME /app
16
15
 
16
+ RUN rm /etc/nginx/sites-enabled/default
17
+ COPY ops/webapp.conf /etc/nginx/sites-enabled/webapp.conf
18
+ COPY ops/env.conf /etc/nginx/main.d/env.conf
19
+
20
+ ENV APP_HOME /home/app/webapp
17
21
  RUN mkdir $APP_HOME
18
22
  WORKDIR $APP_HOME
19
23
 
20
- COPY ./bundle /bundle
21
24
  ENV BUNDLE_GEMFILE=$APP_HOME/Gemfile \
22
- BUNDLE_JOBS=2 \
23
- BUNDLE_PATH=/bundle
25
+ BUNDLE_JOBS=4
24
26
 
25
27
  ADD Gemfile* $APP_HOME/
26
28
  RUN bundle check || bundle install
27
29
 
30
+ <% if options[:delayed_job] %>
31
+ RUN touch /var/log/worker.log && chmod 666 /var/log/worker.log
32
+ RUN mkdir /etc/service/worker
33
+ ADD ops/worker.sh /etc/service/worker/run
34
+ <% end %>
35
+
28
36
  COPY . $APP_HOME
37
+ RUN chown -R app $APP_HOME
38
+
39
+ RUN rm -f /etc/service/nginx/down
40
+
41
+ CMD ["/sbin/my_init"]
data/templates/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  1) Install Docker.app
4
4
 
5
- 2) Get .env file from team member
5
+ 2) Get .env file from team member or copy it from .env.example and fill it out
6
6
 
7
7
  3) gem install stack_car
8
8
 
@@ -1,3 +1,5 @@
1
+ # Hi - please dont edit this file directly, instead make changes in your .env file
2
+
1
3
  <% if options[:mysql] -%>
2
4
  login: &login
3
5
  adapter: mysql2
@@ -73,11 +73,11 @@ services:
73
73
  ports:
74
74
  - "8080"
75
75
  <% end -%>
76
- main:
76
+ web:
77
77
  build: .
78
78
  image: "${REGISTRY_HOST}/${REGISTRY_URI}:${TAG:-master}"
79
79
  volumes:
80
- - .:/app
80
+ - .:/home/app/webapp
81
81
  env_file:
82
82
  - .env
83
83
  # Keep the stdin open, so we can attach to our app container's process
@@ -85,20 +85,8 @@ services:
85
85
  stdin_open: true
86
86
  # Enable sending signals (CTRL+C, CTRL+P + CTRL+Q) into the container:
87
87
  tty: true
88
- <% if options[:delayed_job] -%>
89
- delayed_job:
90
- extends:
91
- service: main
92
- command: ./bin/delayed_job run
93
- depends_on:
94
- <%= compose_depends(:delayed_job) %>
95
- <% end -%>
96
- web:
97
- extends:
98
- service: main
99
- command: bundle exec rails s -p 3000 -b '0.0.0.0'
100
88
  ports:
101
- - "3000"
89
+ - "80"
102
90
  depends_on:
103
91
  <%= compose_depends %>
104
92
 
@@ -0,0 +1,22 @@
1
+ <% if options[:postgres] -%>
2
+ env POSTGRES_DB;
3
+ env POSTGRES_USER;
4
+ env POSTGRES_PASSWORD;
5
+ env POSTGRES_HOST;
6
+ env TEST_DB;
7
+ <% end -%>
8
+ <% if options[:mysql] -%>
9
+ env MYSQL_DATABASE;
10
+ env MYSQL_USER;
11
+ env MYSQL_PASSWORD;
12
+ env MYSQL_ROOT_PASSWORD;
13
+ env MYSQL_HOST;
14
+ env TEST_DB;
15
+ <% end -%>
16
+ <% if options[:deploy] || options[:rancher] -%>
17
+ env REGISTRY_HOST;
18
+ env REGISTRY_URI;
19
+ env SITE_URI;
20
+ <% end -%>
21
+ env TAG;
22
+ env VIRUAL_PORT;
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+
3
+ set -x
4
+
5
+ curl -X POST -H "Content-Type: application/json" -d '{ "push_data": { "tag": "$TAG" }, "repository": { "repo_name":"$REGISTRY_HOST$REGISTRY_URI" }}' $DEPLOY_HOOK
@@ -0,0 +1,15 @@
1
+ server {
2
+ listen 80;
3
+ server_name _;
4
+ root /home/app/webapp/public;
5
+ client_body_in_file_only clean;
6
+ client_body_buffer_size 32K;
7
+
8
+ client_max_body_size 0;
9
+
10
+ sendfile on;
11
+ send_timeout 300s;
12
+ # The following deploys your Ruby/Python/Node.js/Meteor app on Passenger.
13
+ passenger_enabled on;
14
+ passenger_user app;
15
+ }
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.8
4
+ version: 0.3.0
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-03-20 00:00:00.000000000 Z
11
+ date: 2017-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -98,30 +98,30 @@ dependencies:
98
98
  name: dotenv
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: '2.0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: '2.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: thor
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: '0.19'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: '0.19'
125
125
  description:
126
126
  email:
127
127
  - rob@notch8.com
@@ -159,7 +159,9 @@ files:
159
159
  - templates/docker-compose-ci.yml.erb
160
160
  - templates/docker-compose-prod.yml.erb
161
161
  - templates/docker-compose.yml.erb
162
+ - templates/env.conf.erb
162
163
  - templates/hosts.erb
164
+ - templates/ops/deploy-app
163
165
  - templates/ops/deploy.yml
164
166
  - templates/ops/provision.yml
165
167
  - templates/ops/roles/docker.centos/README.md
@@ -178,6 +180,7 @@ files:
178
180
  - templates/ops/roles/docker.ubuntu/templates/docker.conf
179
181
  - templates/ops/roles/docker.ubuntu/tests/vagrant.yml
180
182
  - templates/ops/roles/docker.ubuntu/vars/main.yml
183
+ - templates/webapp.conf.erb
181
184
  homepage: https://gitlab.com/notch8/stack_car
182
185
  licenses: []
183
186
  metadata: {}
@@ -197,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
200
  version: '0'
198
201
  requirements: []
199
202
  rubyforge_project:
200
- rubygems_version: 2.5.1
203
+ rubygems_version: 2.6.11
201
204
  signing_key:
202
205
  specification_version: 4
203
206
  summary: A tool to make rails + docker easy