stack_car 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/exe/sc +5 -0
- data/lib/stack_car/cli.rb +5 -2
- data/lib/stack_car/version.rb +1 -1
- data/stack_car.gemspec +2 -2
- data/templates/.env.erb +4 -0
- data/templates/.gitlab-ci.yml.erb +20 -11
- data/templates/Dockerfile.erb +2 -0
- data/templates/README.md +2 -1
- data/templates/docker-compose-ci.yml.erb +6 -57
- data/templates/docker-compose-prod.yml.erb +4 -3
- data/templates/docker-compose.yml.erb +2 -0
- data/templates/env.conf.erb +1 -1
- data/templates/nginx.sh.erb +21 -0
- data/templates/worker.sh.erb +6 -0
- metadata +6 -4
- data/exe/sc +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 599420272bb040246155a839e357acd506c30da0
|
4
|
+
data.tar.gz: e3782f587282d7023088dca86532d631ae6e56c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc0c57d5111533f813b3534fdc58b1c736594d3190b5716a9d8cfea210342523152e31c51304ebaf59161d8cea900d8ff9ac76752820ad74a7b0d24c76835c91
|
7
|
+
data.tar.gz: 417b8a1e0865568b470f048debdb80f9bbb34abe4c45bf93df8e087b4ae7a027ca31152931abb1b427989547f431d2e6239a9b9db253492110485dd8ab5b54e5
|
data/README.md
CHANGED
@@ -43,7 +43,10 @@ Bug reports and pull requests are welcome on Gitlab at https://gitlab.com/notch8
|
|
43
43
|
|
44
44
|
## TODO
|
45
45
|
|
46
|
-
-
|
46
|
+
- move .env files to dot style
|
47
|
+
- make .env secret by default
|
48
|
+
- update .gitlab to latest (see learn and ansur)
|
49
|
+
|
47
50
|
- Fill out readme
|
48
51
|
- Implement deploy
|
49
52
|
- Implement deploy templates
|
data/exe/sc
ADDED
data/lib/stack_car/cli.rb
CHANGED
@@ -138,6 +138,9 @@ module StackCar
|
|
138
138
|
template("#{template_file}.erb", template_file)
|
139
139
|
end
|
140
140
|
template("database.yml.erb", "config/database.yml")
|
141
|
+
template(".env.erb", ".env-example")
|
142
|
+
template(".env.erb", ".env-prod")
|
143
|
+
|
141
144
|
if File.exists?('README.md')
|
142
145
|
prepend_to_file "README.md" do
|
143
146
|
File.read("#{self.class.source_root}/README.md")
|
@@ -158,7 +161,7 @@ module StackCar
|
|
158
161
|
end
|
159
162
|
|
160
163
|
# 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|
|
164
|
+
['env.conf', 'webapp.conf', 'worker.sh', 'nginx.sh'].each do |template_file|
|
162
165
|
template("#{template_file}.erb", "ops/#{template_file}")
|
163
166
|
end
|
164
167
|
end
|
@@ -166,7 +169,7 @@ module StackCar
|
|
166
169
|
protected
|
167
170
|
def compose_depends(*excludes)
|
168
171
|
@compose_depends = []
|
169
|
-
services = [:postgres, :mysql, :elasticsearch, :solr, :redis, :mongodb, :memcached
|
172
|
+
services = [:postgres, :mysql, :elasticsearch, :solr, :redis, :mongodb, :memcached] - excludes
|
170
173
|
services.each do |service|
|
171
174
|
if options[service]
|
172
175
|
@compose_depends << " - #{service}"
|
data/lib/stack_car/version.rb
CHANGED
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.
|
29
|
-
spec.
|
28
|
+
spec.add_runtime_dependency "dotenv", "~> 2.2"
|
29
|
+
spec.add_runtime_dependency "thor", "~> 0.19"
|
30
30
|
end
|
data/templates/.env.erb
CHANGED
@@ -13,6 +13,9 @@ MYSQL_ROOT_PASSWORD=DatabaseFTW
|
|
13
13
|
MYSQL_HOST=mysql
|
14
14
|
TEST_DB=<%= @project_name %>_test
|
15
15
|
<% end -%>
|
16
|
+
<% if options[:elasticsearch] -%>
|
17
|
+
ES_URL=http://elasticsearch:9200
|
18
|
+
<% end -%>
|
16
19
|
<% if options[:deploy] || options[:rancher] -%>
|
17
20
|
REGISTRY_HOST=registry.gitlab.com
|
18
21
|
REGISTRY_URI=/TODO/<%= @project_name %>
|
@@ -21,3 +24,4 @@ DEPLOY_HOOK=TODO
|
|
21
24
|
<% end -%>
|
22
25
|
TAG=dev
|
23
26
|
VIRUAL_PORT=80
|
27
|
+
PASSENGER_APP_ENV=development
|
@@ -28,21 +28,28 @@ variables:
|
|
28
28
|
<% if options[:postgres] -%>
|
29
29
|
POSTGRES_DB: <%= @project_name %>
|
30
30
|
POSTGRES_USER: postgres
|
31
|
-
POSTGRES_PASSWORD:
|
31
|
+
POSTGRES_PASSWORD: password
|
32
|
+
POSTGRES_HOST: postgres
|
32
33
|
<% end -%>
|
33
|
-
<% if options[:
|
34
|
+
<% if options[:mysql] -%>
|
34
35
|
MYSQL_DATABASE: <%= @project_name %>
|
35
|
-
MYSQL_ROOT_PASSWORD:
|
36
|
+
MYSQL_ROOT_PASSWORD: password
|
37
|
+
MYSQL_USER: <%= @project_name %>_test
|
38
|
+
MYSQL_PASSWORD: password
|
39
|
+
MYSQL_HOST: mysql
|
36
40
|
<% end -%>
|
37
41
|
TEST_DB: <%= @project_name %>
|
38
42
|
DOCKER_DRIVER: overlay
|
43
|
+
REGISTRY_HOST: registry.gitlab.com
|
44
|
+
REGISTRY_URI: TODO/<%= @project_name %>
|
45
|
+
SITE_URI_BASE: TODO
|
39
46
|
|
40
47
|
build:
|
41
48
|
stage: build
|
42
49
|
script:
|
43
50
|
- docker login -u "gitlab-ci-token" -p "$CI_BUILD_TOKEN" $CI_REGISTRY
|
44
|
-
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG" .
|
45
|
-
- docker push "$CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG"
|
51
|
+
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_PROJECT_NAME-$CI_BUILD_REF_SLUG" .
|
52
|
+
- docker push "$CI_REGISTRY_IMAGE:$CI_PROJECT_NAME-$CI_BUILD_REF_SLUG"
|
46
53
|
variables:
|
47
54
|
GIT_STRATEGY: fetch
|
48
55
|
tags:
|
@@ -50,7 +57,7 @@ build:
|
|
50
57
|
|
51
58
|
test:
|
52
59
|
stage: test
|
53
|
-
image: $CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG
|
60
|
+
image: $CI_REGISTRY_IMAGE:$CI_PROJECT_NAME-$CI_BUILD_REF_SLUG
|
54
61
|
script:
|
55
62
|
- cd /app && bundle exec rake db:create db:schema:load spec
|
56
63
|
tags:
|
@@ -63,19 +70,21 @@ review:
|
|
63
70
|
image: docker:latest
|
64
71
|
type: deploy
|
65
72
|
environment:
|
66
|
-
name: $CI_BUILD_REF_SLUG
|
67
|
-
url: http://web.$CI_BUILD_REF_SLUG.staging.$
|
73
|
+
name: $CI_PROJECT_NAME-$CI_BUILD_REF_SLUG
|
74
|
+
url: http://web.$CI_PROJECT_NAME-$CI_BUILD_REF_SLUG.staging.$SITE_URI_BASE
|
68
75
|
on_stop: stop_review
|
69
76
|
only:
|
70
77
|
- branches
|
71
78
|
except:
|
72
79
|
- master
|
73
80
|
script:
|
81
|
+
<% if options[:rancher] -%>
|
74
82
|
- wget https://github.com/rancher/cli/releases/download/v0.4.1/rancher-linux-amd64-v0.4.1.tar.gz
|
75
83
|
- tar zxfv rancher-linux-amd64-v0.4.1.tar.gz
|
76
84
|
- export RANCHER_ENVIRONMENT=staging
|
77
|
-
- export TAG=$CI_BUILD_REF_SLUG
|
85
|
+
- export TAG=$CI_PROJECT_NAME-$CI_BUILD_REF_SLUG
|
78
86
|
- ./rancher-v0.4.1/rancher up -p -d -u -c -s $TAG -f docker-compose-ci.yml
|
87
|
+
<% end %>
|
79
88
|
variables:
|
80
89
|
GIT_STRATEGY: fetch
|
81
90
|
tags:
|
@@ -89,13 +98,13 @@ stop_review:
|
|
89
98
|
- wget https://github.com/rancher/cli/releases/download/v0.4.1/rancher-linux-amd64-v0.4.1.tar.gz
|
90
99
|
- tar zxfv rancher-linux-amd64-v0.4.1.tar.gz
|
91
100
|
- export RANCHER_ENVIRONMENT=staging
|
92
|
-
- ./rancher-v0.4.1/rancher rm $CI_BUILD_REF_SLUG
|
101
|
+
- ./rancher-v0.4.1/rancher rm $CI_PROJECT_NAME-$CI_BUILD_REF_SLUG
|
93
102
|
<% end %>
|
94
103
|
variables:
|
95
104
|
GIT_STRATEGY: none
|
96
105
|
when: manual
|
97
106
|
environment:
|
98
|
-
name: $CI_BUILD_REF_SLUG
|
107
|
+
name: $CI_PROJECT_NAME-$CI_BUILD_REF_SLUG
|
99
108
|
action: stop
|
100
109
|
|
101
110
|
staging:
|
data/templates/Dockerfile.erb
CHANGED
@@ -36,6 +36,8 @@ ADD ops/worker.sh /etc/service/worker/run
|
|
36
36
|
COPY . $APP_HOME
|
37
37
|
RUN chown -R app $APP_HOME
|
38
38
|
|
39
|
+
# Asset complie and migrate if prod, otherwise just start nginx
|
40
|
+
ADD ops/nginx.sh /etc/service/nginx/run
|
39
41
|
RUN rm -f /etc/service/nginx/down
|
40
42
|
|
41
43
|
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 or copy it from .env
|
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
|
|
@@ -21,3 +21,4 @@ sc release {staging | production} # creates and pushes the correct tags
|
|
21
21
|
sc deploy {staging | production} # deployes those tags to the server
|
22
22
|
```
|
23
23
|
|
24
|
+
Releaese and Deployment are handled by the gitlab ci by default. See ops/deploy-app to deploy from locally, but note all Rancher install pull the currently tagged registry image
|
@@ -4,21 +4,17 @@ services:
|
|
4
4
|
postgres:
|
5
5
|
image: postgres
|
6
6
|
env_file:
|
7
|
-
- .env
|
7
|
+
- .env-example
|
8
8
|
ports:
|
9
9
|
- "5432"
|
10
|
-
volumes:
|
11
|
-
- 'postgres:/var/lib/postgresql/data'
|
12
10
|
<% end -%>
|
13
11
|
<% if options[:mysql] -%>
|
14
12
|
mysql:
|
15
13
|
image: mysql
|
16
14
|
env_file:
|
17
|
-
- .env
|
15
|
+
- .env-example
|
18
16
|
ports:
|
19
17
|
- '3306'
|
20
|
-
volumes:
|
21
|
-
- 'mysql:/var/lib/mysql'
|
22
18
|
<% end -%>
|
23
19
|
<% if options[:elasticsearch] -%>
|
24
20
|
elasticsearch:
|
@@ -26,16 +22,12 @@ services:
|
|
26
22
|
ports:
|
27
23
|
- "9200"
|
28
24
|
- "9300"
|
29
|
-
volumes:
|
30
|
-
- 'elasticsearch:/usr/share/elasticsearch/data'
|
31
25
|
<% end -%>
|
32
26
|
<% if options[:solr] %>
|
33
27
|
solr:
|
34
28
|
image: solr:latest
|
35
29
|
ports:
|
36
30
|
- "8983"
|
37
|
-
volumes:
|
38
|
-
- 'solr:/opt/solr/server/solr/mycores'
|
39
31
|
entrypoint:
|
40
32
|
- docker-entrypoint.sh
|
41
33
|
- solr-precreate
|
@@ -48,14 +40,10 @@ services:
|
|
48
40
|
command: redis-server
|
49
41
|
ports:
|
50
42
|
- '6379'
|
51
|
-
volumes:
|
52
|
-
- 'redis:/var/lib/redis/data'
|
53
43
|
<% end -%>
|
54
44
|
<% if options[:mongodb] -%>
|
55
45
|
mongodb:
|
56
46
|
image: mongo:2.6.12
|
57
|
-
volumes:
|
58
|
-
- 'mongodb:/data/db'
|
59
47
|
ports:
|
60
48
|
- "27017"
|
61
49
|
<% end -%>
|
@@ -73,55 +61,16 @@ services:
|
|
73
61
|
ports:
|
74
62
|
- "8080"
|
75
63
|
<% end -%>
|
76
|
-
|
64
|
+
web:
|
77
65
|
image: "${REGISTRY_HOST}/${REGISTRY_URI}:${TAG:-master}"
|
78
|
-
volumes:
|
79
|
-
- .:/app
|
80
66
|
env_file:
|
81
|
-
- .env
|
82
|
-
# Keep the stdin open, so we can attach to our app container's process
|
83
|
-
# and do things such as byebug, etc:
|
84
|
-
stdin_open: true
|
85
|
-
# Enable sending signals (CTRL+C, CTRL+P + CTRL+Q) into the container:
|
86
|
-
tty: true
|
87
|
-
<% if options[:delayed_job] -%>
|
88
|
-
delayed_job:
|
89
|
-
extends:
|
90
|
-
service: main
|
91
|
-
command: ./bin/delayed_job run
|
92
|
-
depends_on:
|
93
|
-
<%= compose_depends(:delayed_job) %>
|
94
|
-
<% end -%>
|
95
|
-
web:
|
96
|
-
extends:
|
97
|
-
service: main
|
98
|
-
command: bundle exec rails s -p 3000 -b '0.0.0.0'
|
67
|
+
- .env-example
|
99
68
|
labels:
|
100
69
|
rap.host: ${SITE_URI}
|
101
70
|
rap.le_host: ${SITE_URI}
|
102
71
|
rap.le_test: true
|
72
|
+
io.rancher.container.pull_image: always
|
103
73
|
ports:
|
104
|
-
- "
|
74
|
+
- "80"
|
105
75
|
depends_on:
|
106
76
|
<%= compose_depends %>
|
107
|
-
|
108
|
-
volumes:
|
109
|
-
<% if options[:postgres] -%>
|
110
|
-
postgres:
|
111
|
-
<% end -%>
|
112
|
-
<% if options[:mysql] -%>
|
113
|
-
mysql:
|
114
|
-
<% end -%>
|
115
|
-
<% if options[:elasticsearch] -%>
|
116
|
-
elasticsearch:
|
117
|
-
<% end -%>
|
118
|
-
<% if options[:solr] -%>
|
119
|
-
solr:
|
120
|
-
<% end -%>
|
121
|
-
<% if options[:redis] -%>
|
122
|
-
redis:
|
123
|
-
<% end -%>
|
124
|
-
<% if options[:mongodb] -%>
|
125
|
-
mongodb:
|
126
|
-
<% end -%>
|
127
|
-
|
@@ -2,19 +2,20 @@ version: '2.1'
|
|
2
2
|
services:
|
3
3
|
web:
|
4
4
|
image: "${REGISTRY_HOST}/${REGISTRY_URI}:${TAG:-master}"
|
5
|
-
command: bash -c "bundle exec rake assets:precompile db:migrate && bundle exec passenger start -p 3000 -b '0.0.0.0'""
|
6
5
|
environment:
|
7
6
|
- RAILS_ENV=production
|
8
7
|
- RACK_ENV=production
|
8
|
+
- PASSENGER_APP_ENV=production
|
9
9
|
restart: unless-stopped
|
10
10
|
ports:
|
11
|
-
- "
|
11
|
+
- "80"
|
12
12
|
labels:
|
13
13
|
rap.host: ${SITE_URI}
|
14
14
|
rap.le_host: ${SITE_URI}
|
15
15
|
rap.le_test: true
|
16
|
+
io.rancher.container.pull_image: always
|
16
17
|
env_file:
|
17
|
-
.env
|
18
|
+
.env-prod
|
18
19
|
|
19
20
|
<% if options[:rancher] -%>
|
20
21
|
volumes:
|
data/templates/env.conf.erb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -e
|
3
|
+
if [[ ! -e /var/log/nginx/error.log ]]; then
|
4
|
+
# The Nginx log forwarder might be sleeping and waiting
|
5
|
+
# until the error log becomes available. We restart it in
|
6
|
+
# 1 second so that it picks up the new log file quickly.
|
7
|
+
(sleep 1 && sv restart /etc/service/nginx-log-forwarder)
|
8
|
+
fi
|
9
|
+
|
10
|
+
if [ -z $PASSENGER_APP_ENV ]
|
11
|
+
then
|
12
|
+
export PASSENGER_APP_ENV=development
|
13
|
+
fi
|
14
|
+
|
15
|
+
if [ $PASSENGER_APP_ENV == "production" ]
|
16
|
+
then
|
17
|
+
/sbin/setuser app /bin/bash -l -c 'cd /home/app/webapp && bundle exec rake assets:precompile db:migrate'
|
18
|
+
fi
|
19
|
+
|
20
|
+
|
21
|
+
exec /usr/sbin/nginx
|
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.3.
|
4
|
+
version: 0.3.1
|
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-
|
11
|
+
date: 2017-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '2.
|
103
|
+
version: '2.2'
|
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: '2.
|
110
|
+
version: '2.2'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: thor
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- templates/docker-compose.yml.erb
|
162
162
|
- templates/env.conf.erb
|
163
163
|
- templates/hosts.erb
|
164
|
+
- templates/nginx.sh.erb
|
164
165
|
- templates/ops/deploy-app
|
165
166
|
- templates/ops/deploy.yml
|
166
167
|
- templates/ops/provision.yml
|
@@ -181,6 +182,7 @@ files:
|
|
181
182
|
- templates/ops/roles/docker.ubuntu/tests/vagrant.yml
|
182
183
|
- templates/ops/roles/docker.ubuntu/vars/main.yml
|
183
184
|
- templates/webapp.conf.erb
|
185
|
+
- templates/worker.sh.erb
|
184
186
|
homepage: https://gitlab.com/notch8/stack_car
|
185
187
|
licenses: []
|
186
188
|
metadata: {}
|
data/exe/sc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
exe/stack_car
|