stack_car 0.7.1 → 0.13.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 +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
@@ -2,9 +2,9 @@
2
2
  .convox
3
3
  .env
4
4
  .env.*
5
- node_modules
6
- .git
5
+ .ruby-*
7
6
  db/*.sqlite3
8
7
  db/*.sqlite3-journal
9
8
  log/*
9
+ node_modules
10
10
  tmp
@@ -1 +1,3 @@
1
1
  # Items in this file override those in .env and are good for developer system specific preferences
2
+ # if not using dory uncomment the next line
3
+ WEB_PORT=3000:80
data/templates/.env.erb CHANGED
@@ -1,18 +1,23 @@
1
+ APP_NAME=<%= @project_name %>
2
+ PASSENGER_APP_ENV=development
3
+ REGISTRY_HOST=registry.gitlab.com
4
+ REGISTRY_URI=/CHANGEME/<%= @project_name %>
5
+ TAG=dev
1
6
  <% if options[:postgres] -%>
2
- POSTGRES_DB=<%= @project_name %>
3
- POSTGRES_USER=postgres
4
- POSTGRES_PASSWORD=DatabaseFTW
5
- POSTGRES_HOST=postgres
6
- DB_ADAPTER=postgresql
7
+ DATABASE_NAME=<%= @project_name %>
8
+ DATABASE_USER=postgres
9
+ DATABASE_PASSWORD=DatabaseFTW
10
+ DATABASE_HOST=postgres
11
+ DATABASE_ADAPTER=postgresql
7
12
  TEST_DB=<%= @project_name %>_test
8
13
  <% end -%>
9
14
  <% if options[:mysql] -%>
10
- MYSQL_DATABASE=<%= @project_name %>
11
- MYSQL_USER=root
12
- MYSQL_PASSWORD=DatabaseFTW
15
+ DATABASE_NAME=<%= @project_name %>
16
+ DATABASE_USER=<%= @project_name %>
17
+ DATABASE_PASSWORD=DatabaseFTW
13
18
  MYSQL_ROOT_PASSWORD=DatabaseFTW
14
- MYSQL_HOST=mysql
15
- DB_ADAPTER=mysql2
19
+ DATABASE_HOST=mysql
20
+ DATABASE_ADAPTER=mysql2
16
21
  TEST_DB=<%= @project_name %>_test
17
22
  <% end -%>
18
23
  <% if options[:elasticsearch] -%>
@@ -22,9 +27,3 @@ ES_URL=http://elasticsearch:9200
22
27
  SITE_URI=https://CHANGEME.com
23
28
  DEPLOY_HOOK=CHANGEME
24
29
  <% end -%>
25
- REGISTRY_HOST=registry.gitlab.com
26
- REGISTRY_URI=/CHANGEME/<%= @project_name %>
27
- TAG=dev
28
- VIRTUAL_PORT=80
29
- PASSENGER_APP_ENV=development
30
- DOCKER_PORT=3000:80
@@ -1,71 +1,97 @@
1
- image: $CI_REGISTRY_IMAGE/builder:latest
2
- services:
3
- - docker:dind
4
- <% if options[:postgres] -%>
5
- - postgres:latest
6
- <% end -%>
7
- <% if options[:mysql] -%>
8
- - mysql:latest
9
- <% end -%>
10
- <% if options[:solr] -%>
11
- - solr:latest
12
- <% end -%>
13
- <% if options[:elasticsearch] -%>
14
- - elasticsearch:latest
15
- <% end -%>
16
- <% if options[:redis] -%>
17
- - redis:latest
18
- <% end -%>
19
-
20
1
  stages:
21
- - build
22
- - test
23
- - review
24
- - staging
25
- - production
26
-
27
- variables:
28
- <% if options[:postgres] -%>
29
- POSTGRES_DB: <%= @project_name %>
30
- POSTGRES_USER: postgres
31
- POSTGRES_PASSWORD: password
32
- POSTGRES_HOST: postgres
33
- <% end -%>
34
- <% if options[:mysql] -%>
35
- MYSQL_DATABASE: <%= @project_name %>
36
- MYSQL_ROOT_PASSWORD: password
37
- MYSQL_USER: <%= @project_name %>_test
38
- MYSQL_PASSWORD: password
39
- MYSQL_HOST: mysql
40
- <% end -%>
41
- TEST_DB: <%= @project_name %>
42
- DOCKER_DRIVER: overlay
43
- REGISTRY_HOST: registry.gitlab.com
44
- REGISTRY_URI: TODO/<%= @project_name %>
45
- SITE_URI_BASE: TODO
46
-
2
+ - build
3
+ - lint
4
+ - test
5
+ - deploy
47
6
 
48
7
  before_script:
49
- - export REGISTRY_FULL=registry.gitlab.com/notch8/ror-site/$CI_COMMIT_REF_SLUG:${CI_COMMIT_SHA:0:8}
50
- - export TAG=$CI_COMMIT_REF_SLUG
51
- - eval $(ssh-agent -s)
52
- - bash
53
- - ssh-add <(echo "$SSH_PRIVATE_KEY")
54
- - mkdir -p ~/.ssh
55
- - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
8
+ - export TAG=${CI_COMMIT_SHORT_SHA}
9
+ - export BRANCH=${CI_COMMIT_REF_NAME}
10
+ - export REGISTRY_HOST=${CI_REGISTRY}
11
+ - export REGISTRY_URI="/${CI_PROJECT_PATH}"
12
+
13
+ base:
14
+ stage: build
15
+ script:
16
+ - docker login -u "gitlab-ci-token" -p "$CI_JOB_TOKEN" $CI_REGISTRY
17
+ - sc build -s base
18
+ - sc push -s base
19
+ when: manual
20
+ tags:
21
+ - local
56
22
 
57
23
  build:
58
24
  stage: build
59
25
  script:
60
- - docker login -u "gitlab-ci-token" -p "$CI_BUILD_TOKEN" $CI_REGISTRY
26
+ - docker login -u "gitlab-ci-token" -p "$CI_JOB_TOKEN" $CI_REGISTRY
61
27
  - sc build
62
28
  - sc push
29
+ - docker tag $CI_REGISTRY_IMAGE:$TAG $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
30
+ - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
31
+ tags:
32
+ - local
33
+
34
+ lint:
35
+ stage: go
36
+ image: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
37
+ variables:
38
+ PRONTO_GITLAB_API_ENDPOINT: "https://gitlab.com/api/v4"
39
+ before_script:
40
+ - export PRONTO_GITLAB_API_PRIVATE_TOKEN=$GITLAB_API_TOKEN
41
+ script:
42
+ - cd /home/app/webapp && bundle exec pronto run -f gitlab
63
43
  tags:
64
44
  - docker
65
45
 
66
46
  test:
67
47
  stage: test
68
- image: $CI_REGISTRY_IMAGE:$CI_PROJECT_NAME-$CI_BUILD_REF_SLUG
48
+ image: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
49
+ services:
50
+ <% if options[:postgres] -%>
51
+ - name: postgres:11.1
52
+ <% end -%>
53
+ <% if options[:mysql] -%>
54
+ - mysql:5.7
55
+ <% end -%>
56
+ <% if options[:solr] -%>
57
+ - name: solr:latest
58
+ entrypoint: ["docker-entrypoint.sh", "solr-precreate", "test"]
59
+ <% end -%>
60
+ <% if options[:elasticsearch] -%>
61
+ - elasticsearch:latest
62
+ <% end -%>
63
+ <% if options[:redis] -%>
64
+ - redis:latest
65
+ <% end -%>
66
+ <% if options[:fcrepo] -%>
67
+ - name: botimer/fcrepo:4.5.1
68
+ <% end %>
69
+ variables:
70
+ <% if options[:postgres] -%>
71
+ POSTGRES_DB: <%= @project_name %>
72
+ POSTGRES_USER: postgres
73
+ POSTGRES_PASSWORD: password
74
+ POSTGRES_HOST: postgres
75
+ DATABASE_ADAPTER: postgresql
76
+ DATABASE_HOST: postgres
77
+ DATABASE_NAME: <%= @project_name %>
78
+ DATABASE_PASSWORD: password
79
+ DATABASE_USER: postgres
80
+ <% end -%>
81
+ <% if options[:mysql] -%>
82
+ MYSQL_DATABASE: <%= @project_name %>
83
+ MYSQL_ROOT_PASSWORD: password
84
+ MYSQL_USER: <%= @project_name %>_test
85
+ MYSQL_PASSWORD: password
86
+ MYSQL_HOST: mysql
87
+ DATABASE_ADAPTER: mysql2
88
+ DATABASE_HOST: mysql
89
+ DATABASE_NAME: <%= @project_name %>
90
+ DATABASE_PASSWORD: password
91
+ DATABASE_USER: <%= @project_name %>_test
92
+ <% end -%>
93
+ TEST_DB: <%= @project_name %>
94
+ SITE_URI_BASE: TODO
69
95
  script:
70
96
  - cd /home/app/webapp && bundle exec rake db:create db:schema:load spec
71
97
  tags:
@@ -77,7 +103,7 @@ review:
77
103
  stage: review
78
104
  type: deploy
79
105
  environment:
80
- name: $CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG
106
+ name: $CI_COMMIT_REF_SLUG
81
107
  url: http://web.$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG.staging.$SITE_URI_BASE
82
108
  on_stop: stop_review
83
109
  only:
@@ -88,12 +114,13 @@ review:
88
114
  <% if options[:rancher] -%>
89
115
  - export RANCHER_ENVIRONMENT=staging
90
116
  - sc provision ci
91
- <% else %>
117
+ <% elsif options[:helm] -%>
118
+ - ./chart/bin/deploy review $CI_COMMIT_REF_SLUG
119
+ <% else -%>
92
120
  - CHANGME
93
- <% end %>
121
+ <% end -%>
94
122
  tags:
95
- - docker
96
- - mysql
123
+ - local
97
124
 
98
125
  stop_review:
99
126
  stage: review
@@ -101,6 +128,8 @@ stop_review:
101
128
  <% if options[:rancher] -%>
102
129
  - export RANCHER_ENVIRONMENT=staging
103
130
  - rancher rm $CI_PROJECT_NAME-$CI_BUILD_REF_SLUG
131
+ <% elsif options[:helm] -%>
132
+ - ./chart/bin/remove review $CI_COMMIT_REF_SLUG
104
133
  <% end %>
105
134
  when: manual
106
135
  environment:
@@ -112,7 +141,9 @@ staging:
112
141
  type: deploy
113
142
  script:
114
143
  <% if options[:rancher] -%>
115
- - sc deploy staging
144
+ - sc deploy staging
145
+ <% elsif options[:helm] -%>
146
+ - ./chart/bin/deploy staging $CI_COMMIT_REF_SLUG
116
147
  <% end -%>
117
148
  <% if options[:heroku] -%>
118
149
  - dpl --provider=heroku --app=<%= @project_name %>-staging --api-key=$HEROKU_STAGING_API_KEY --run="bundle exec rake db:migrate"
@@ -120,7 +151,7 @@ staging:
120
151
  only:
121
152
  - master
122
153
  tags:
123
- - docker
154
+ - local
124
155
 
125
156
  production:
126
157
  stage: production
@@ -128,6 +159,8 @@ production:
128
159
  script:
129
160
  <% if options[:rancher] -%>
130
161
  - sc deploy production
162
+ <% elsif options[:helm] -%>
163
+ - ./chart/bin/deploy production $CI_COMMIT_REF_SLUG
131
164
  <% end -%>
132
165
  <% if options[:heroku] -%>
133
166
  - dpl --provider=heroku --app=<%= @project_name %> --api-key=$HEROKU_PRODUCTION_API_KEY --run="bundle exec rake db:migrate"
@@ -136,4 +169,4 @@ production:
136
169
  only:
137
170
  - master
138
171
  tags:
139
- - docker
172
+ - local
@@ -1,14 +1,33 @@
1
1
  FROM CHANGEME/base:latest
2
+ <% if options[:git] -%>
3
+ ARG BRANCH=master
4
+ ARG REPO_URL
5
+ <% end -%>
2
6
 
3
- ADD http://time.jsontest.com build-time
4
7
  ADD ops/webapp.conf /etc/nginx/sites-enabled/webapp.conf
5
8
  ADD ops/env.conf /etc/nginx/main.d/env.conf
6
- ADD . $APP_HOME
7
9
 
8
- RUN cd /home/app/webapp && \
9
- (/sbin/setuser app bundle check || /sbin/setuser app bundle install) && \
10
- /sbin/setuser app bundle exec rake assets:precompile DB_ADAPTER=nulldb && \
11
- chown -R app $APP_HOME && \
12
- rm -f /etc/service/nginx/down
10
+ <% if options[:git] -%>
11
+ RUN /sbin/setuser app bash -l -c "set -x && \
12
+ git fetch -ap && \
13
+ git reset --hard && \
14
+ git checkout $BRANCH && \
15
+ git pull && \
16
+ (bundle check || bundle install) && \
17
+ bundle exec rake assets:clobber assets:precompile DATABASE_ADAPTER=nulldb && \
18
+ mv /home/app/webapp/public/assets /home/app/webapp/public/assets-new && \
19
+ mv /home/app/webapp/public/packs /home/app/webapp/public/packs-new"
20
+ <% else -%>
21
+ RUN gem install bundler -v CHANGEME # Add the BUNDLED WITH version listed at the bottom of the Gemfile.lock
22
+ COPY --chown=app . $APP_HOME
23
+ RUN /sbin/setuser app bash -l -c "set -x && \
24
+ (bundle check || bundle install) && \
25
+ bundle exec rake assets:clobber assets:precompile DATABASE_ADAPTER=nulldb && \
26
+ mv /home/app/webapp/public/assets /home/app/webapp/public/assets-new && \
27
+ mv /home/app/webapp/public/packs /home/app/webapp/public/packs-new"
28
+ <% end -%>
29
+
30
+ RUN bash -l -c "set -x && \
31
+ rm -f /etc/service/nginx/down"
13
32
 
14
33
  CMD ["/sbin/my_init"]
@@ -0,0 +1,63 @@
1
+ ---
2
+ apiVersion: apps/v1
3
+ kind: Deployment
4
+ metadata:
5
+ name: {{ template "app.fcrepo.name" . }}
6
+ labels:
7
+ app: {{ template "app.name" . }}
8
+ chart: {{ template "app.chart" . }}
9
+ release: {{ .Release.Name }}
10
+ heritage: {{ .Release.Service }}
11
+ component: fcrepo
12
+ spec:
13
+ replicas: 1
14
+ selector:
15
+ matchLabels:
16
+ app: {{ template "app.name" . }}
17
+ release: {{ .Release.Name }}
18
+ component: fcrepo
19
+ strategy:
20
+ type: Recreate
21
+ template:
22
+ metadata:
23
+ labels:
24
+ app: {{ template "app.name" . }}
25
+ release: {{ .Release.Name }}
26
+ component: fcrepo
27
+ spec:
28
+ restartPolicy: Always
29
+ {{- if .Values.fcrepo.imagePullSecrets }}
30
+ imagePullSecrets:
31
+ {{ toYaml .Values.fcrepo.imagePullSecrets }}
32
+ {{- end }}
33
+ volumes:
34
+ - name: data
35
+ persistentVolumeClaim:
36
+ claimName: {{ template "app.fcrepo.name" . }}
37
+ initContainers:
38
+ - name: "remove-lost-found"
39
+ image: "busybox:1.25.0"
40
+ command:
41
+ - rm
42
+ - -fr
43
+ - /data/lost+found
44
+ volumeMounts:
45
+ - name: data
46
+ mountPath: /data
47
+ containers:
48
+ - name: fcrepo
49
+ image: {{ .Values.fcrepo.image.repository }}:{{ .Values.fcrepo.image.tag }}
50
+ livenessProbe:
51
+ tcpSocket:
52
+ port: 8080
53
+ readinessProbe:
54
+ tcpSocket:
55
+ port: 8080
56
+ volumeMounts:
57
+ - name: data
58
+ mountPath: /data
59
+ envFrom:
60
+ - configMapRef:
61
+ name: {{ template "app.fcrepo-env.name" . }}
62
+ - secretRef:
63
+ name: {{ template "app.fcrepo-env.name" . }}
@@ -0,0 +1,8 @@
1
+ ---
2
+ apiVersion: v1
3
+ kind: ConfigMap
4
+ metadata:
5
+ name: {{ template "app.fcrepo-env.name" . }}
6
+ data:
7
+ DATABASE_USER: {{ .Values.env.configmap.DATABASE_USER }}
8
+ DATABASE_NAME: {{ .Values.env.configmap.FC_DATABASE_NAME }}
@@ -0,0 +1,10 @@
1
+ ---
2
+ apiVersion: v1
3
+ kind: Secret
4
+ metadata:
5
+ name: {{ template "app.fcrepo-env.name" . }}
6
+ data:
7
+ DATABASE_PASSWORD: {{ .Values.env.secret.DATABASE_PASSWORD | b64enc }}
8
+ <% if options[:postgres] %>
9
+ JAVA_OPTS: {{ printf "-Dfcrepo.modeshape.configuration=\"classpath:/config/jdbc-postgresql/repository.json\" -Dfcrepo.postgresql.host=\"%s\" -Dfcrepo.postgresql.username=\"%s\" -Dfcrepo.postgresql.password=\"%s\" -Dfcrepo.object.directory=\"/data/objects\" -Dfcrepo.binary.directory=\"/data/binaries\"" ( include "app.postgres.name" . ) .Values.env.configmap.DATABASE_USER .Values.env.secret.DATABASE_PASSWORD | b64enc }}
10
+ <% end %>
@@ -0,0 +1,20 @@
1
+ ---
2
+ kind: PersistentVolumeClaim
3
+ apiVersion: v1
4
+ metadata:
5
+ name: {{ template "app.fcrepo.name" . }}
6
+ labels:
7
+ app: {{ template "app.name" . }}
8
+ chart: {{ template "app.chart" . }}
9
+ release: {{ .Release.Name }}
10
+ heritage: {{ .Release.Service }}
11
+ component: fcrepo
12
+ spec:
13
+ accessModes:
14
+ - ReadWriteOnce
15
+ resources:
16
+ requests:
17
+ storage: {{ .Values.fcrepo.storage.size }}
18
+ {{- if .Values.fcrepo.storage.className }}
19
+ storageClassName: "{{ .Values.fcrepo.storage.ClassName }}"
20
+ {{- end }}
@@ -0,0 +1,19 @@
1
+ ---
2
+ apiVersion: v1
3
+ kind: Service
4
+ metadata:
5
+ name: {{ template "app.fcrepo.name" . }}
6
+ labels:
7
+ app: {{ template "app.name" . }}
8
+ chart: {{ template "app.chart" . }}
9
+ release: {{ .Release.Name }}
10
+ heritage: {{ .Release.Service }}
11
+ component: fcrepo
12
+ spec:
13
+ ports:
14
+ - protocol: TCP
15
+ port: 8080
16
+ selector:
17
+ app: {{ template "app.name" . }}
18
+ release: {{ .Release.Name }}
19
+ component: fcrepo