stack_car 0.9.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +64 -1
  3. data/lib/stack_car.rb +1 -0
  4. data/lib/stack_car/cli.rb +112 -36
  5. data/lib/stack_car/dot_rc.rb +25 -0
  6. data/lib/stack_car/version.rb +1 -1
  7. data/stack_car.gemspec +1 -0
  8. data/templates/.dockerignore.erb +2 -2
  9. data/templates/.env.development.erb +2 -0
  10. data/templates/.env.erb +15 -16
  11. data/templates/.gitlab-ci.yml.erb +94 -62
  12. data/templates/Dockerfile.base.erb +28 -19
  13. data/templates/Dockerfile.erb +26 -7
  14. data/templates/chart-fcrepo/fcrepo-deploy.yaml +63 -0
  15. data/templates/chart-fcrepo/fcrepo-env-cm.yaml +8 -0
  16. data/templates/chart-fcrepo/fcrepo-env-secret.yaml.tt +10 -0
  17. data/templates/chart-fcrepo/fcrepo-pvc.yaml +20 -0
  18. data/templates/chart-fcrepo/fcrepo-svc.yaml +19 -0
  19. data/templates/chart-sidekiq/sidekiq-deploy.yaml +80 -0
  20. data/templates/chart/.gitignore +3 -0
  21. data/templates/chart/.helmignore +23 -0
  22. data/templates/chart/Chart.yaml.tt +29 -0
  23. data/templates/chart/README.md +223 -0
  24. data/templates/chart/bin/check_sidekiq.rb +0 -0
  25. data/templates/chart/bin/decrypt +17 -0
  26. data/templates/chart/bin/deploy +14 -0
  27. data/templates/chart/bin/encrypt +15 -0
  28. data/templates/chart/bin/remove +15 -0
  29. data/templates/chart/sample-values.yaml.tt +138 -0
  30. data/templates/chart/templates/_helpers.tpl.tt +85 -0
  31. data/templates/chart/templates/rails-env-cm.yaml.tt +47 -0
  32. data/templates/chart/templates/rails-env-secret.yaml +10 -0
  33. data/templates/chart/templates/rails-pvc-shared.yml +20 -0
  34. data/templates/chart/templates/setup-job.yaml +73 -0
  35. data/templates/chart/templates/web-deploy.yaml +67 -0
  36. data/templates/chart/templates/web-ing-wildcard.yaml +20 -0
  37. data/templates/chart/templates/web-ing.yaml +20 -0
  38. data/templates/chart/templates/web-svc.yaml +20 -0
  39. data/templates/database.yml.erb +10 -10
  40. data/templates/docker-compose.yml.erb +53 -12
  41. data/templates/env.conf.erb +11 -11
  42. data/templates/nginx.sh.erb +17 -0
  43. metadata +47 -10
  44. data/templates/docker-compose.ci.yml.erb +0 -87
  45. data/templates/docker-compose.production.yml.erb +0 -26
@@ -0,0 +1,20 @@
1
+ ---
2
+ apiVersion: extensions/v1beta1
3
+ kind: Ingress
4
+ metadata:
5
+ name: {{ template "app.web.name" . }}-in-wildcard
6
+ annotations:
7
+ # kubernetes.io/ingress.allow-http: "false"
8
+ # for GKE
9
+ # kubernetes.io/ingress.global-static-ip-name: rails-k8s-app
10
+ spec:
11
+ # tls:
12
+ # - hosts:
13
+ # - {{ .Values.ingress.host }}
14
+ rules:
15
+ - host: "*.{{ .Values.ingress.host }}"
16
+ http:
17
+ paths:
18
+ - backend:
19
+ serviceName: {{ template "app.web.name" . }}
20
+ servicePort: 80
@@ -0,0 +1,20 @@
1
+ ---
2
+ apiVersion: extensions/v1beta1
3
+ kind: Ingress
4
+ metadata:
5
+ name: {{ template "app.web.name" . }}-in
6
+ annotations:
7
+ {{- range $key, $value := .Values.ingress.annotations }}
8
+ {{ $key }}: {{ $value | quote }}
9
+ {{- end }}
10
+ spec:
11
+ # tls:
12
+ # - hosts:
13
+ # - {{ .Values.ingress.host }}
14
+ rules:
15
+ - host: "{{ .Values.ingress.host }}"
16
+ http:
17
+ paths:
18
+ - backend:
19
+ serviceName: {{ template "app.web.name" . }}
20
+ servicePort: 80
@@ -0,0 +1,20 @@
1
+ ---
2
+ apiVersion: v1
3
+ kind: Service
4
+ metadata:
5
+ name: {{ template "app.web.name" . }}
6
+ labels:
7
+ app: {{ template "app.name" . }}
8
+ chart: {{ template "app.chart" . }}
9
+ release: {{ .Release.Name }}
10
+ heritage: {{ .Release.Service }}
11
+ component: web
12
+ spec:
13
+ ports:
14
+ - protocol: TCP
15
+ port: 80
16
+ targetPort: 80
17
+ selector:
18
+ app: {{ template "app.name" . }}
19
+ release: {{ .Release.Name }}
20
+ component: web
@@ -3,21 +3,21 @@
3
3
  <% if options[:mysql] -%>
4
4
  login: &login
5
5
  adapter: mysql2
6
- adapter: <%%= ENV['DB_ADAPTER'] %>
7
- host: <%%= ENV['MYSQL_HOST'] %>
8
- username: <%%= ENV['MYSQL_USER'] %>
9
- password: <%%= ENV['MYSQL_PASSWORD'] %>
10
- database: <%%= ENV['MYSQL_DATABASE'] %>
6
+ adapter: <%%= ENV['DATABASE_ADAPTER'] %>
7
+ host: <%%= ENV['DATABASE_HOST'] %>
8
+ username: <%%= ENV['DATABASE_USER'] %>
9
+ password: <%%= ENV['DATABASE_PASSWORD'] %>
10
+ database: <%%= ENV['DATABASE_NAME'] %>
11
11
  pool: 5
12
12
  timeout: 5000
13
13
  <% end -%>
14
14
  <% if options[:postgres] -%>
15
15
  login: &login
16
- adapter: <%%= ENV['DB_ADAPTER'] %>
17
- host: <%%= ENV['POSTGRES_HOST'] %>
18
- username: <%%= ENV['POSTGRES_USER'] %>
19
- password: <%%= ENV['POSTGRES_PASSWORD'] %>
20
- database: <%%= ENV['POSTGRES_DB'] %>
16
+ adapter: <%%= ENV['DATABASE_ADAPTER'] %>
17
+ host: <%%= ENV['DATABASE_HOST'] %>
18
+ username: <%%= ENV['DATABASE_USER'] %>
19
+ password: <%%= ENV['DATABASE_PASSWORD'] %>
20
+ database: <%%= ENV['DATABASE_NAME'] %>
21
21
  pool: 5
22
22
  timeout: 5000
23
23
  <% end -%>
@@ -2,10 +2,11 @@ version: '2.1'
2
2
  services:
3
3
  <% if options[:postgres] -%>
4
4
  postgres:
5
- image: postgres
6
- env_file:
7
- - .env
8
- - .env.development
5
+ image: postgres:11.1
6
+ environment:
7
+ - POSTGRES_USER=postgres
8
+ - POSTGRES_PASSWORD=DatabaseFTW
9
+ - POSTGRES_DB=<%= @project_name %>
9
10
  ports:
10
11
  - "5432"
11
12
  volumes:
@@ -13,10 +14,12 @@ services:
13
14
  <% end -%>
14
15
  <% if options[:mysql] -%>
15
16
  mysql:
16
- image: mysql
17
- env_file:
18
- - .env
19
- - .env.development
17
+ image: mysql:5.7
18
+ environment:
19
+ - MYSQL_DATABASE=<%= @project_name %>
20
+ - MYSQL_USER=<%= @project_name %>
21
+ - MYSQL_PASSWORD=DatabaseFTW
22
+ - MYSQL_ROOT_PASSWORD=DatabaseFTW
20
23
  ports:
21
24
  - '3306'
22
25
  volumes:
@@ -99,25 +102,61 @@ services:
99
102
  build:
100
103
  context: .
101
104
  dockerfile: Dockerfile.base
105
+ args:
106
+ DEPLOY_KEY: "${DEPLOY_KEY}"
107
+ APP_NAME: "${APP_NAME}"
108
+ REPO_URL: "${REPO_URL}"
109
+ env_file:
110
+ - .env
111
+ - .env.development
102
112
 
103
- web:
104
- build: .
113
+ app:
114
+ build:
115
+ context: ..
116
+ dockerfile: stack_car/Dockerfile
117
+ args:
118
+ DEPLOY_KEY: "${DEPLOY_KEY}"
119
+ REPO_URL: "${REPO_URL}"
120
+ BRANCH: "${BRANCH}"
105
121
  image: "${REGISTRY_HOST}${REGISTRY_URI}:${TAG:-master}"
106
122
  env_file:
107
123
  - .env
108
124
  - .env.development
109
125
  volumes:
110
- - .:/home/app/webapp
126
+ - .:/home/app/webapp:cached
127
+ - node_modules:/home/app/webapp/node_modules
128
+ - tmp_cache:/home/app/webapp/tmp/cache
111
129
  # Keep the stdin open, so we can attach to our app container's process
112
130
  # and do things such as byebug, etc:
113
131
  stdin_open: true
114
132
  # Enable sending signals (CTRL+C, CTRL+P + CTRL+Q) into the container:
115
133
  tty: true
134
+
135
+ web:
136
+ extends:
137
+ app:
116
138
  ports:
117
- - "${DOCKER_PORT}"
139
+ - "${WEB_PORT}"
140
+ environment:
141
+ - VIRTUAL_HOST=<%= @project_name %>.docker
142
+ - VIRTUAL_PORT=80
118
143
  depends_on:
119
144
  <%= compose_depends %>
120
145
 
146
+ <% if options[:delayed_job] %>
147
+ worker:
148
+ extends: app
149
+ command: ./bin/delayed_job run
150
+ <%= compose_depends %>
151
+ <% end %>
152
+
153
+ <% if options[:sidekiq] %>
154
+ worker:
155
+ extends: app
156
+ command: bundle exec sidekiq
157
+ <%= compose_depends %>
158
+ <% end %>
159
+
121
160
  volumes:
122
161
  <% if options[:postgres] -%>
123
162
  postgres:
@@ -140,3 +179,5 @@ volumes:
140
179
  <% if options[:fcrepo] -%>
141
180
  fcrepo:
142
181
  <% end -%>
182
+ tmp_cache:
183
+ node_modules:
@@ -1,18 +1,18 @@
1
1
  <% if options[:postgres] -%>
2
- env DB_ADAPTER;
3
- env POSTGRES_DB;
4
- env POSTGRES_USER;
5
- env POSTGRES_PASSWORD;
6
- env POSTGRES_HOST;
2
+ env DATABASE_ADAPTER;
3
+ env DATABASE_NAME;
4
+ env DATABASE_USER;
5
+ env DATABASE_PASSWORD;
6
+ env DATABASE_HOST;
7
7
  env TEST_DB;
8
8
  <% end -%>
9
9
  <% if options[:mysql] -%>
10
- env DB_ADAPTER;
11
- env MYSQL_DATABASE;
12
- env MYSQL_USER;
13
- env MYSQL_PASSWORD;
14
- env MYSQL_ROOT_PASSWORD;
15
- env MYSQL_HOST;
10
+ env DATABASE_ADAPTER;
11
+ env DATABASE_NAME;
12
+ env DATABASE_USER;
13
+ env DATABASE_PASSWORD;
14
+ env DATABASE_ROOT_PASSWORD;
15
+ env DATABASE_HOST;
16
16
  env TEST_DB;
17
17
  <% end -%>
18
18
  <% if options[:deploy] || options[:rancher] -%>
@@ -12,9 +12,26 @@ then
12
12
  export PASSENGER_APP_ENV=development
13
13
  fi
14
14
 
15
+ rm -rf /home/app/webapp/.ruby*
16
+
17
+ declare -p | grep -Ev 'BASHOPTS|PWD|BASH_VERSINFO|EUID|PPID|SHELLOPTS|UID' > /container.env
18
+
19
+ if [[ $PASSENGER_APP_ENV == "development" ]] || [[ $PASSENGER_APP_ENV == "test" ]]
20
+ then
21
+ /sbin/setuser app /bin/bash -l -c 'cd /home/app/webapp && bundle exec rails db:create db:migrate db:test:prepare'
22
+ fi
23
+
15
24
  if [[ $PASSENGER_APP_ENV == "production" ]] || [[ $PASSENGER_APP_ENV == "staging" ]]
16
25
  then
26
+ /bin/bash -l -c 'chown -R app:app /home/app/webapp/tmp' # mounted volume may have wrong permissions
27
+ /bin/bash -l -c 'chown -R app:app /home/app/webapp/public' # mounted volume may have wrong permissions
17
28
  /sbin/setuser app /bin/bash -l -c 'cd /home/app/webapp && bundle exec rake db:migrate'
29
+ if [ -d /home/app/webapp/public/assets-new ]; then
30
+ /sbin/setuser app /bin/bash -l -c 'cd /home/app/webapp && rsync -a public/assets-new/ public/assets/'
31
+ fi
32
+ if [ -d /home/app/webapp/public/packs-new ]; then
33
+ /sbin/setuser app /bin/bash -l -c 'cd /home/app/webapp && rsync -a public/packs-new/ public/packs/'
34
+ fi
18
35
  fi
19
36
 
20
37
  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.9.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Kaufman
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-27 00:00:00.000000000 Z
11
+ date: 2021-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '2.2'
111
+ - !ruby/object:Gem::Dependency
112
+ name: json
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.3'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.3'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: thor
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -122,7 +136,7 @@ dependencies:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0.19'
125
- description:
139
+ description:
126
140
  email:
127
141
  - rob@notch8.com
128
142
  executables:
@@ -144,6 +158,7 @@ files:
144
158
  - exe/stack_car
145
159
  - lib/stack_car.rb
146
160
  - lib/stack_car/cli.rb
161
+ - lib/stack_car/dot_rc.rb
147
162
  - lib/stack_car/version.rb
148
163
  - logo.jpg
149
164
  - public/.gitkeep
@@ -158,10 +173,33 @@ files:
158
173
  - templates/Dockerfile.builder.erb
159
174
  - templates/Dockerfile.erb
160
175
  - templates/README.md
176
+ - templates/chart-fcrepo/fcrepo-deploy.yaml
177
+ - templates/chart-fcrepo/fcrepo-env-cm.yaml
178
+ - templates/chart-fcrepo/fcrepo-env-secret.yaml.tt
179
+ - templates/chart-fcrepo/fcrepo-pvc.yaml
180
+ - templates/chart-fcrepo/fcrepo-svc.yaml
181
+ - templates/chart-sidekiq/sidekiq-deploy.yaml
182
+ - templates/chart/.gitignore
183
+ - templates/chart/.helmignore
184
+ - templates/chart/Chart.yaml.tt
185
+ - templates/chart/README.md
186
+ - templates/chart/bin/check_sidekiq.rb
187
+ - templates/chart/bin/decrypt
188
+ - templates/chart/bin/deploy
189
+ - templates/chart/bin/encrypt
190
+ - templates/chart/bin/remove
191
+ - templates/chart/sample-values.yaml.tt
192
+ - templates/chart/templates/_helpers.tpl.tt
193
+ - templates/chart/templates/rails-env-cm.yaml.tt
194
+ - templates/chart/templates/rails-env-secret.yaml
195
+ - templates/chart/templates/rails-pvc-shared.yml
196
+ - templates/chart/templates/setup-job.yaml
197
+ - templates/chart/templates/web-deploy.yaml
198
+ - templates/chart/templates/web-ing-wildcard.yaml
199
+ - templates/chart/templates/web-ing.yaml
200
+ - templates/chart/templates/web-svc.yaml
161
201
  - templates/database.yml.erb
162
202
  - templates/deploy.yml.erb
163
- - templates/docker-compose.ci.yml.erb
164
- - templates/docker-compose.production.yml.erb
165
203
  - templates/docker-compose.yml.erb
166
204
  - templates/env.conf.erb
167
205
  - templates/hosts.erb
@@ -188,7 +226,7 @@ files:
188
226
  homepage: https://gitlab.com/notch8/stack_car
189
227
  licenses: []
190
228
  metadata: {}
191
- post_install_message:
229
+ post_install_message:
192
230
  rdoc_options: []
193
231
  require_paths:
194
232
  - lib
@@ -203,9 +241,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
241
  - !ruby/object:Gem::Version
204
242
  version: '0'
205
243
  requirements: []
206
- rubyforge_project:
207
- rubygems_version: 2.6.12
208
- signing_key:
244
+ rubygems_version: 3.0.8
245
+ signing_key:
209
246
  specification_version: 4
210
247
  summary: A tool to make rails + docker easy
211
248
  test_files: []
@@ -1,87 +0,0 @@
1
- version: '2.1'
2
- services:
3
- <% if options[:postgres] -%>
4
- postgres:
5
- image: postgres
6
- env_file:
7
- - .env
8
- ports:
9
- - "5432"
10
- <% end -%>
11
- <% if options[:mysql] -%>
12
- mysql:
13
- image: mysql
14
- env_file:
15
- - .env
16
- ports:
17
- - '3306'
18
- <% end -%>
19
- <% if options[:elasticsearch] -%>
20
- elasticsearch:
21
- image: elasticsearch:1.7.1
22
- env_file:
23
- - .env
24
- ports:
25
- - "9200"
26
- - "9300"
27
- <% end -%>
28
- <% if options[:solr] %>
29
- solr:
30
- image: solr:latest
31
- env_file:
32
- - .env
33
- ports:
34
- - "8983"
35
- entrypoint:
36
- - docker-entrypoint.sh
37
- - solr-precreate
38
- - mycore
39
- # docker-compose exec --user=solr solr bin/solr create_core -c CORENAME
40
- <% end -%>
41
- <% if options[:redis] -%>
42
- redis:
43
- image: 'redis:3.2-alpine'
44
- env_file:
45
- - .env
46
- command: redis-server
47
- ports:
48
- - '6379'
49
- <% end -%>
50
- <% if options[:mongodb] -%>
51
- mongodb:
52
- image: mongo:2.6.12
53
- env_file:
54
- - .env
55
- ports:
56
- - "27017"
57
- <% end -%>
58
- <% if options[:memcached] -%>
59
- memcached:
60
- image: memcached
61
- env_file:
62
- - .env
63
- ports:
64
- - "11211"
65
- <% end -%>
66
- <% if options[:fcrepo] -%>
67
- fcrepo:
68
- image: botimer/fcrepo:4.5.1
69
- env_file:
70
- - .env
71
- volumes:
72
- - 'fcrepo:/opt/data'
73
- ports:
74
- - "8080"
75
- <% end -%>
76
- web:
77
- image: "${REGISTRY_HOST}${REGISTRY_URI}:${TAG:-master}"
78
- env_file:
79
- - .env
80
- rap.host: ${SITE_URI}
81
- rap.le_host: ${SITE_URI}
82
- rap.le_test: true
83
- io.rancher.container.pull_image: always
84
- ports:
85
- - "80"
86
- depends_on:
87
- <%= compose_depends %>