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,14 @@
1
+ #!/bin/bash
2
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
3
+ cd $DIR/../../chart
4
+
5
+ REPO=$(basename $(git config --get remote.origin.url))
6
+ NAMESPACE=${REPO%.git}
7
+
8
+ if [ -z "$1" ] || [ -z "$2" ]
9
+ then
10
+ echo './chart/bin/deploy ENVIRONMENT TAG'
11
+ exit 1
12
+ fi
13
+
14
+ helm upgrade --install --namespace $1-$NAMESPACE $1 . -f $1-values.yaml --set rails.image.tag=$2
@@ -0,0 +1,15 @@
1
+ #!/bin/bash
2
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
3
+ cd $DIR/../../chart
4
+
5
+ REPO=$(basename $(git config --get remote.origin.url))
6
+ NAMESPACE=${REPO%.git}
7
+
8
+ if [ -z "$1" ] || [ -z "$2" ]
9
+ then
10
+ echo './chart/bin/encrypt ENVIRONMENT TEAM'
11
+ exit 1
12
+ fi
13
+
14
+ keybase encrypt -i $1-values.yaml -o $1-values.yaml.enc --team $2
15
+
@@ -0,0 +1,15 @@
1
+ #!/bin/bash
2
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
3
+ cd $DIR/../../chart
4
+
5
+ REPO=$(basename $(git config --get remote.origin.url))
6
+ NAMESPACE=${REPO%.git}
7
+
8
+ if [ -z "$1" ] || [ -z "$2" ]
9
+ then
10
+ echo './chart/bin/remove ENVIRONMENT TAG'
11
+ exit 1
12
+ fi
13
+
14
+ raise 'refusing to remove production' if $1 == 'production'
15
+ helm uninstall --namespace $1-$NAMESPACE $1 . -f $1-values.yaml --set rails.image.tag=$2
@@ -0,0 +1,138 @@
1
+ # Customize the following values as needed
2
+
3
+ <% if options[:solr] %>
4
+ solr:
5
+ image:
6
+ repository: solr
7
+ tag: 7.4
8
+ replicaCount: 1
9
+ volumeClaimTemplates:
10
+ storageSize: 1Gi
11
+
12
+ zookeeper:
13
+ replicaCount: 1
14
+ persistence:
15
+ enabled: true
16
+ accessMode: ReadWriteOnce
17
+ size: 1Gi
18
+ <% end %>
19
+
20
+ postgresql:
21
+ enabled: true
22
+ <% if options[:fedora] %>
23
+ # Use fcrepo; the web app can create it's own db with db:create
24
+ postgresqlDatabase: fcrepo
25
+ <% else %>
26
+ postgresqlDatabase: <%= @project_name %>
27
+ <% end %>
28
+ postgresqlUsername: postgres
29
+ # Only used when internal PG is disabled
30
+ # postgresqlHost: postgres
31
+ postgresqlPassword: passwordabc
32
+ # postgresqlPort: 5432
33
+ persistence:
34
+ enabled: true
35
+ size: 1Gi
36
+ <% if options[:mysql] %>
37
+ externalDatabase:
38
+ host: host_name
39
+ user: <%= @project_name %>
40
+ password: 05cb2c6a26ce76
41
+ database: <%= @project_name %>
42
+ port: '3306'
43
+
44
+ mariadb:
45
+ enabled: false
46
+ replication:
47
+ enabled: false
48
+ db:
49
+ name: <%= @project_name %>
50
+ user: <%= @project_name %>
51
+ ## If the password is not specified, mariadb will generates a random password
52
+ # password:
53
+ # rootUser:
54
+ # password:
55
+ master:
56
+ persistence:
57
+ enabled: true
58
+ # storageClass: "-"
59
+ accessMode: ReadWriteOnce
60
+ size: 8Gi
61
+ <% end %>
62
+ <% if options[:redis] %>
63
+ redis:
64
+ enabled: true
65
+ usePassword: false
66
+ # Only used when internal redis is disabled
67
+ # host: redis
68
+ # Just omit the password field if your redis cluster doesn't use password
69
+ # password: redis
70
+ # port: 6379
71
+ master:
72
+ persistence:
73
+ enabled: true
74
+ size: 1Gi
75
+ slave:
76
+ persistence:
77
+ enabled: true
78
+ size: 1Gi
79
+ <% end %>
80
+ <% if options[:fcrepo] %>
81
+ fcrepo:
82
+ image:
83
+ repository: ualbertalib/docker-fcrepo4
84
+ tag: 4.7
85
+ storage:
86
+ size: 1Gi
87
+ <% end %>
88
+ web:
89
+ replicas: 2
90
+ <% if options[:sidekiq] %>
91
+ sidekiq:
92
+ replicas: 1
93
+ timeout: 3600
94
+ <% end %>
95
+ rails:
96
+ image:
97
+ repository: <%= @project_name %>
98
+ tag: latest
99
+ # If using a private registry setup access via secrets
100
+ # imagePullSecrets:
101
+ # - name: gitlab
102
+ shared:
103
+ storage:
104
+ size: 1Gi
105
+ className: nfs
106
+
107
+ ingress:
108
+ tlsSecretName: <%= @project_name %>_tls
109
+ # helm upgrade release-name . --set ingress.localhost
110
+ host: <%= @project_name %>.com
111
+
112
+ env:
113
+ configmap:
114
+ NAME: <%= @project_name %>
115
+ DATABASE_ADAPTER: postgresql
116
+ DATABASE_USER: postgres
117
+ <% if options[:fcrepo] %>
118
+ FC_DATABASE_NAME: fcrepo
119
+ LD_LIBRARY_PATH: /opt/fits-latest/tools/mediainfo/linux
120
+ SETTINGS__ACTIVE_JOB__QUEUE_ADAPTER: sidekiq
121
+ SETTINGS__CONTACT_EMAIL: admin@example.org
122
+ SETTINGS__DEVISE__INVITATION_FROM_EMAIL: admin@example.org
123
+ SETTINGS__FITS_PATH: /opt/fits/fits.sh
124
+ SETTINGS__MULTITENANCY__ADMIN_HOST: app.docker
125
+ SETTINGS__MULTITENANCY__ADMIN_ONLY_TENANT_CREATION: "true"
126
+ SETTINGS__MULTITENANCY__DEFAULT_HOST: "%{tenant}.app.docker"
127
+ SETTINGS__MULTITENANCY__ENABLED: "true"
128
+ <% end %>
129
+ DATABASE_NAME: <%= @project_name %>
130
+ IN_DOCKER: "true"
131
+ PASSENGER_APP_ENV: production
132
+ RAILS_ENV: production
133
+ RAILS_LOG_TO_STDOUT: "true"
134
+ RAILS_SERVE_STATIC_FILES: "true"
135
+
136
+ secret:
137
+ SECRET_KEY_BASE: secretabc
138
+ DATABASE_PASSWORD: passwordabc
@@ -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" . }}