stack_car 0.7.1 → 0.13.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.
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 +131 -38
  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 +95 -62
  12. data/templates/Dockerfile.erb +26 -7
  13. data/templates/chart-fcrepo/fcrepo-deploy.yaml +63 -0
  14. data/templates/chart-fcrepo/fcrepo-env-cm.yaml +8 -0
  15. data/templates/chart-fcrepo/fcrepo-env-secret.yaml.tt +10 -0
  16. data/templates/chart-fcrepo/fcrepo-pvc.yaml +20 -0
  17. data/templates/chart-fcrepo/fcrepo-svc.yaml +19 -0
  18. data/templates/chart-sidekiq/sidekiq-deploy.yaml +80 -0
  19. data/templates/chart/.gitignore +3 -0
  20. data/templates/chart/.helmignore +23 -0
  21. data/templates/chart/Chart.yaml.tt +29 -0
  22. data/templates/chart/README.md +223 -0
  23. data/templates/chart/bin/check_sidekiq.rb +0 -0
  24. data/templates/chart/bin/decrypt +17 -0
  25. data/templates/chart/bin/deploy +14 -0
  26. data/templates/chart/bin/encrypt +15 -0
  27. data/templates/chart/bin/remove +15 -0
  28. data/templates/chart/sample-values.yaml.tt +138 -0
  29. data/templates/chart/templates/_helpers.tpl.tt +85 -0
  30. data/templates/chart/templates/rails-env-cm.yaml.tt +47 -0
  31. data/templates/chart/templates/rails-env-secret.yaml +10 -0
  32. data/templates/chart/templates/rails-pvc-shared.yml +20 -0
  33. data/templates/chart/templates/setup-job.yaml +73 -0
  34. data/templates/chart/templates/web-deploy.yaml +67 -0
  35. data/templates/chart/templates/web-ing-wildcard.yaml +20 -0
  36. data/templates/chart/templates/web-ing.yaml +20 -0
  37. data/templates/chart/templates/web-svc.yaml +20 -0
  38. data/templates/database.yml.erb +10 -10
  39. data/templates/docker-compose.yml.erb +49 -17
  40. data/templates/env.conf.erb +11 -9
  41. data/templates/nginx.sh.erb +17 -0
  42. metadata +47 -11
  43. data/templates/Dockerfile.base.erb +0 -48
  44. data/templates/docker-compose.ci.yml.erb +0 -87
  45. data/templates/docker-compose.production.yml.erb +0 -26
@@ -0,0 +1,85 @@
1
+ {{/* vim: set filetype=mustache: */}}
2
+ {{/*
3
+ Expand the name of the chart.
4
+ */}}
5
+ {{- define "app.name" -}}
6
+ {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7
+ {{- end -}}
8
+
9
+ {{/*
10
+ Create a default fully qualified app name.
11
+ We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12
+ If release name contains chart name it will be used as a full name.
13
+ */}}
14
+ {{- define "app.fullname" -}}
15
+ {{- if .Values.fullnameOverride -}}
16
+ {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17
+ {{- else -}}
18
+ {{- $name := default .Chart.Name .Values.nameOverride -}}
19
+ {{- if contains $name .Release.Name -}}
20
+ {{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21
+ {{- else -}}
22
+ {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23
+ {{- end -}}
24
+ {{- end -}}
25
+ {{- end -}}
26
+
27
+ {{/*
28
+ Create chart name and version as used by the chart label.
29
+ */}}
30
+ {{- define "app.chart" -}}
31
+ {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32
+ {{- end -}}
33
+
34
+ {{/*
35
+ Shorthand for component names
36
+ */}}
37
+ <%- if options[:postgres] %>
38
+ {{- define "app.postgres.name" -}}
39
+ {{- .Release.Name -}}-postgresql
40
+ {{- end -}}
41
+ {{- define "app.postgres-env.name" -}}
42
+ {{- include "app.fullname" . -}}-postgres-env
43
+ {{- end -}}
44
+ <%- end %>
45
+ <%- if options[:redis] %>
46
+ {{- define "app.redis.name" -}}
47
+ {{- .Release.Name -}}-redis-master
48
+ {{- end -}}
49
+ <%- end %>
50
+ <%- if options[:sidekiq] %>
51
+ {{- define "app.sidekiq.name" -}}
52
+ {{- include "app.fullname" . -}}-sidekiq
53
+ {{- end -}}
54
+ <%- end %>
55
+ {{- define "app.web.name" -}}
56
+ {{- include "app.fullname" . -}}-web
57
+ {{- end -}}
58
+ {{- define "app.rails-env.name" -}}
59
+ {{- include "app.fullname" . -}}-rails-env
60
+ {{- end -}}
61
+ {{- define "app.setup.name" -}}
62
+ {{- include "app.fullname" . -}}-setup
63
+ {{- end -}}
64
+ <%- if options[:solr] %>
65
+ {{- define "app.zookeeper.name" -}}
66
+ {{- include "solr.zookeeper-service-name" . -}}
67
+ {{- end -}}
68
+ {{- define "app.zookeeper-env.name" -}}
69
+ {{- include "app.fullname" . -}}-zookeeper-env
70
+ {{- end -}}
71
+ {{- define "app.solr.name" -}}
72
+ {{- .Release.Name -}}-solr-svc
73
+ {{- end -}}
74
+ {{- define "app.solr.collection" -}}
75
+ {{- if eq .Values.env.configmap.SETTINGS__MULTITENANCY__ENABLED false }}single{{- end -}}
76
+ {{- end -}}
77
+ <%- end %>
78
+ <%- if options[:fcrepo] %>
79
+ {{- define "app.fcrepo.name" -}}
80
+ {{- include "app.fullname" . -}}-fcrepo
81
+ {{- end -}}
82
+ {{- define "app.fcrepo-env.name" -}}
83
+ {{- include "app.fullname" . -}}-fcrepo-env
84
+ {{- end -}}
85
+ <%- end %>
@@ -0,0 +1,47 @@
1
+ ---
2
+ apiVersion: v1
3
+ kind: ConfigMap
4
+ metadata:
5
+ name: {{ template "app.rails-env.name" . }}
6
+ data:
7
+ <% if options[:postgres] %>
8
+ DATABASE_HOST: {{ template "app.postgres.name" . }}
9
+ <% end %>
10
+ <% if options[:fcrepo] %>
11
+ FEDORA_URL: http://{{ template "app.fcrepo.name" . }}:8080/fcrepo/rest
12
+ <% end %>
13
+ <% if options[:redis] %>
14
+ RAILS_CACHE_STORE_URL: redis://{{ template "app.redis.name" . }}:6379/1
15
+ REDIS_HOST: {{ template "app.redis.name" . }}
16
+ REDIS_URL: redis://{{ template "app.redis.name" . }}:6379/1
17
+ <% end %>
18
+ <% if options[:sidekiq] %>
19
+ SIDEKIQ_TIMEOUT: {{ .Values.sidekiq.timeout | quote }}
20
+ <% end -%>
21
+ <% if options[:solr] %>
22
+ SOLR_URL: http://{{ template "app.solr.name" . }}:8983/solr/
23
+ SETTINGS__SOLR__URL: http://{{ template "app.solr.name" . }}:8983/solr/
24
+ SETTINGS__ZOOKEEPER__CONNECTION_STR: {{ template "app.zookeeper.name" . }}:2181/configs
25
+ <% end %>
26
+ <% if options[:hyku] %>
27
+ {{- if hasKey $.Values.env.configmap "SETTINGS__MULTITENANCY__ENABLED"}}
28
+ {{- if eq $.Values.env.configmap.SETTINGS__MULTITENANCY__ENABLED false }}
29
+ SETTINGS__MULTITENANCY__ROOT_HOST: {{ .Values.ingress.host }}
30
+ {{- end -}}
31
+ {{- end -}}
32
+ <% end %>
33
+ {{- range $key, $value := .Values.env.configmap }}
34
+ <% if options[:hyku] %>
35
+ {{- if hasKey $.Values.env.configmap "SETTINGS__MULTITENANCY__ENABLED"}}
36
+ {{- if eq $.Values.env.configmap.SETTINGS__MULTITENANCY__ENABLED false }}
37
+ {{- if and (ne $key "SETTINGS__MULTITENANCY__ADMIN_HOST") (ne $key "SETTINGS__MULTITENANCY__DEFAULT_HOST") }}
38
+ {{ $key }}: {{ $value | quote }}
39
+ {{- end }}
40
+ {{- else }}
41
+ {{ $key }}: {{ $value | quote }}
42
+ {{- end }}
43
+ {{- end }}
44
+ <% else %>
45
+ {{ $key }}: {{ $value | quote }}
46
+ <% end %>
47
+ {{- end }}
@@ -0,0 +1,10 @@
1
+ ---
2
+ apiVersion: v1
3
+ kind: Secret
4
+ metadata:
5
+ name: {{ template "app.rails-env.name" . }}
6
+ data:
7
+ {{- range $key, $value := .Values.env.secret }}
8
+ {{ $key }}: {{ $value |b64enc }}
9
+ {{- end }}
10
+
@@ -0,0 +1,20 @@
1
+ ---
2
+ kind: PersistentVolumeClaim
3
+ apiVersion: v1
4
+ metadata:
5
+ name: {{ template "app.rails-env.name" . }}-shared
6
+ labels:
7
+ app: {{ template "app.name" . }}
8
+ chart: {{ template "app.chart" . }}
9
+ release: {{ .Release.Name }}
10
+ heritage: {{ .Release.Service }}
11
+ component: rails
12
+ spec:
13
+ accessModes:
14
+ - ReadWriteMany
15
+ resources:
16
+ requests:
17
+ storage: {{ .Values.rails.shared.storage.size }}
18
+ {{- if .Values.rails.shared.storage.className }}
19
+ storageClassName: "{{ .Values.rails.shared.storage.className }}"
20
+ {{- end }}
@@ -0,0 +1,73 @@
1
+ ---
2
+ apiVersion: batch/v1
3
+ kind: Job
4
+ metadata:
5
+ name: {{ template "app.setup.name" . }}
6
+ labels:
7
+ app: {{ template "app.name" . }}
8
+ chart: {{ template "app.chart" . }}
9
+ release: {{ .Release.Name }}
10
+ heritage: {{ .Release.Service }}
11
+ annotations:
12
+ # This is what defines this resource as a hook. Without this line, the
13
+ # job is considered part of the release.
14
+ "helm.sh/hook": post-install,pre-upgrade
15
+ "helm.sh/hook-weight": "-5"
16
+ "helm.sh/hook-delete-policy": before-hook-creation
17
+ spec:
18
+ backoffLimit: 4
19
+ template:
20
+ metadata:
21
+ labels:
22
+ app: {{ template "app.name" . }}
23
+ release: {{ .Release.Name }}
24
+ spec:
25
+ restartPolicy: Never
26
+ {{- if .Values.rails.imagePullSecrets }}
27
+ imagePullSecrets:
28
+ {{ toYaml .Values.rails.imagePullSecrets }}
29
+ {{- end }}
30
+ volumes:
31
+ - name: shared
32
+ persistentVolumeClaim:
33
+ claimName: {{ template "app.rails-env.name" . }}-shared
34
+ <% if options[:solr] %>
35
+ initContainers:
36
+ - name: check-solr-ready
37
+ image: {{ .Values.rails.image.repository }}:{{ .Values.rails.image.tag }}
38
+ command: ["/bin/bash"]
39
+ args:
40
+ - "-l"
41
+ - "-c"
42
+ - "response=0 && until [ $response == 200 ]; do response=$(curl --write-out %{http_code} --silent --output /dev/null $(echo $SETTINGS__SOLR__URL)admin/collections?action=LIST); echo Response is $response; sleep 5; done;"
43
+ envFrom:
44
+ - configMapRef:
45
+ name: {{ template "app.rails-env.name" . }}
46
+ <% end %>
47
+ containers:
48
+ - name: setup
49
+ image: {{ .Values.rails.image.repository }}:{{ .Values.rails.image.tag }}
50
+ volumeMounts:
51
+ - mountPath: /home/app/webapp/public/assets
52
+ name: shared
53
+ subPath: assets
54
+ - mountPath: /home/app/webapp/public/packs
55
+ name: shared
56
+ subPath: packs
57
+ - mountPath: /home/app/webapp/public/system
58
+ name: shared
59
+ subPath: system
60
+ command: ["/bin/bash"]
61
+ args:
62
+ - "-l"
63
+ - "-c"
64
+ <% if options[:solr] %>
65
+ - "(bundle check || bundle install) && bundle exec rails db:create zookeeper:upload db:migrate db:seed && RAILS_ENV=production bundle exec rails assets:precompile DATABASE_ADAPTER=nulldb && echo SETUP COMPLETE"
66
+ <% else %>
67
+ - "(bundle check || bundle install) && bundle exec rails db:create db:migrate db:seed && RAILS_ENV=production bundle exec rails assets:precompile DATABASE_ADAPTER=nulldb && echo SETUP COMPLETE"
68
+ <% end %>
69
+ envFrom:
70
+ - configMapRef:
71
+ name: {{ template "app.rails-env.name" . }}
72
+ - secretRef:
73
+ name: {{ template "app.rails-env.name" . }}
@@ -0,0 +1,67 @@
1
+ ---
2
+ apiVersion: apps/v1
3
+ kind: Deployment
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
+ replicas: {{ .Values.web.replicas }}
14
+ selector:
15
+ matchLabels:
16
+ app: {{ template "app.name" . }}
17
+ release: {{ .Release.Name }}
18
+ component: web
19
+ template:
20
+ metadata:
21
+ labels:
22
+ app: {{ template "app.name" . }}
23
+ release: {{ .Release.Name }}
24
+ component: web
25
+ annotations:
26
+ checksum/rails-env-cm: {{ include (print $.Template.BasePath "/rails-env-cm.yaml") . | sha256sum }}
27
+ checksum/rails-env-secret: {{ include (print $.Template.BasePath "/rails-env-secret.yaml") . | sha256sum }}
28
+ spec:
29
+ restartPolicy: Always
30
+ {{- if .Values.rails.imagePullSecrets }}
31
+ imagePullSecrets:
32
+ {{ toYaml .Values.rails.imagePullSecrets }}
33
+ {{- end }}
34
+ volumes:
35
+ - name: shared
36
+ persistentVolumeClaim:
37
+ claimName: {{ template "app.rails-env.name" . }}-shared
38
+ containers:
39
+ - name: web
40
+ image: {{ .Values.rails.image.repository }}:{{ .Values.rails.image.tag }}
41
+ imagePullPolicy: IfNotPresent
42
+ # Use sub-path for individual folders
43
+ volumeMounts:
44
+ - mountPath: /home/app/webapp/public/assets
45
+ name: shared
46
+ subPath: assets
47
+ - mountPath: /home/app/webapp/public/packs
48
+ name: shared
49
+ subPath: packs
50
+ - mountPath: /home/app/webapp/public/system
51
+ name: shared
52
+ subPath: system
53
+ readinessProbe:
54
+ tcpSocket:
55
+ port: 80
56
+ initialDelaySeconds: 30
57
+ periodSeconds: 10
58
+ livenessProbe:
59
+ tcpSocket:
60
+ port: 80
61
+ initialDelaySeconds: 60
62
+ periodSeconds: 120
63
+ envFrom:
64
+ - configMapRef:
65
+ name: {{ template "app.rails-env.name" . }}
66
+ - secretRef:
67
+ name: {{ template "app.rails-env.name" . }}
@@ -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:
@@ -94,30 +97,57 @@ services:
94
97
  - "8080"
95
98
  <% end -%>
96
99
 
97
- base:
98
- image: "${REGISTRY_HOST}${REGISTRY_URI}/base:latest"
100
+ app:
99
101
  build:
100
- context: .
101
- dockerfile: Dockerfile.base
102
-
103
- web:
104
- build: .
102
+ <% if @sc_dir -%>
103
+ context: ..
104
+ dockerfile: stack_car/Dockerfile
105
+ <% else -%>
106
+ context: .
107
+ dockerfile: Dockerfile
108
+ <% end -%>
109
+ args:
110
+ DEPLOY_KEY: "${DEPLOY_KEY}"
111
+ REPO_URL: "${REPO_URL}"
112
+ BRANCH: "${BRANCH}"
105
113
  image: "${REGISTRY_HOST}${REGISTRY_URI}:${TAG:-master}"
106
114
  env_file:
107
115
  - .env
108
116
  - .env.development
109
117
  volumes:
110
- - .:/home/app/webapp
118
+ - .:/home/app/webapp:cached
119
+ - node_modules:/home/app/webapp/node_modules
120
+ - tmp_cache:/home/app/webapp/tmp/cache
111
121
  # Keep the stdin open, so we can attach to our app container's process
112
122
  # and do things such as byebug, etc:
113
123
  stdin_open: true
114
124
  # Enable sending signals (CTRL+C, CTRL+P + CTRL+Q) into the container:
115
125
  tty: true
126
+
127
+ web:
128
+ extends: app
116
129
  ports:
117
- - "${DOCKER_PORT}"
130
+ - "${WEB_PORT}"
131
+ environment:
132
+ - VIRTUAL_HOST=<%= @project_name %>.docker
133
+ - VIRTUAL_PORT=80
118
134
  depends_on:
119
135
  <%= compose_depends %>
120
136
 
137
+ <% if options[:delayed_job] %>
138
+ worker:
139
+ extends: app
140
+ command: ./bin/delayed_job run
141
+ <%= compose_depends %>
142
+ <% end %>
143
+
144
+ <% if options[:sidekiq] %>
145
+ worker:
146
+ extends: app
147
+ command: bundle exec sidekiq
148
+ <%= compose_depends %>
149
+ <% end %>
150
+
121
151
  volumes:
122
152
  <% if options[:postgres] -%>
123
153
  postgres:
@@ -140,3 +170,5 @@ volumes:
140
170
  <% if options[:fcrepo] -%>
141
171
  fcrepo:
142
172
  <% end -%>
173
+ tmp_cache:
174
+ node_modules: