stack_car 0.12.0 → 0.15.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 (36) hide show
  1. checksums.yaml +4 -4
  2. data/.gitlab-ci.yml +17 -12
  3. data/README.md +84 -10
  4. data/lib/stack_car/cli.rb +166 -33
  5. data/lib/stack_car/version.rb +3 -1
  6. data/stack_car.gemspec +1 -0
  7. data/templates/.env.erb +23 -0
  8. data/templates/.gitlab/issue_templates/Bug.md +46 -0
  9. data/templates/.gitlab/issue_templates/Feature.md +41 -0
  10. data/templates/.gitlab/issue_templates/Question.md +18 -0
  11. data/templates/.gitlab/issue_templates/enable_pipeline_check_before_merge.md +8 -0
  12. data/templates/.gitlab/merge_request_templates/Bug.md +36 -0
  13. data/templates/.gitlab/merge_request_templates/Feature.md +36 -0
  14. data/templates/.gitlab-ci.yml.erb +4 -3
  15. data/templates/.sops.yaml.erb +3 -0
  16. data/templates/Dockerfile.erb +6 -6
  17. data/templates/README.md +84 -7
  18. data/templates/chart/Chart.yaml.tt +15 -14
  19. data/templates/chart/bin/deploy +1 -1
  20. data/templates/chart/bin/remove +1 -1
  21. data/templates/chart/sample-values.yaml.tt +16 -1
  22. data/templates/chart/templates/_helpers.tpl.tt +1 -1
  23. data/templates/chart/templates/web-ing-wildcard.yaml +1 -1
  24. data/templates/chart/templates/web-ing.yaml +1 -1
  25. data/templates/database.yml.erb +0 -1
  26. data/templates/decrypt-secrets +22 -0
  27. data/templates/deploy.yml.erb +2 -2
  28. data/templates/development.rb.erb +90 -0
  29. data/templates/docker-compose.yml.erb +14 -21
  30. data/templates/encrypt-secrets +19 -0
  31. data/templates/production.rb.erb +117 -0
  32. data/templates/solrcloud-assign-configset.sh +35 -0
  33. data/templates/solrcloud-upload-configset.sh +42 -0
  34. metadata +34 -9
  35. data/templates/Dockerfile.base.erb +0 -57
  36. data/templates/Dockerfile.builder.erb +0 -13
@@ -0,0 +1,117 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # Code is not reloaded between requests.
5
+ config.cache_classes = true
6
+
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both threaded web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
14
+ config.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Disable serving static files from the `/public` folder by default since
18
+ # Apache or NGINX already handles this.
19
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
20
+ config.public_file_server.headers = {
21
+ 'Cache-Control' => 'public, s-maxage=31536000, maxage=15552000',
22
+ 'Expires' => "#{1.year.from_now.to_formatted_s(:rfc822)}"
23
+ }
24
+ # Compress JavaScripts and CSS.
25
+ config.assets.js_compressor = Uglifier.new(harmony: true)
26
+ # config.assets.css_compressor = :sass
27
+
28
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
29
+ config.assets.compile = false
30
+
31
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
32
+
33
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
34
+ config.action_controller.asset_host = Settings.action_controller.asset_host if Settings.action_controller.asset_host
35
+
36
+ # Specifies the header that your server uses for sending files.
37
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
38
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
39
+
40
+ # Mount Action Cable outside main process or domain
41
+ # config.action_cable.mount_path = nil
42
+ # config.action_cable.url = 'wss://example.com/cable'
43
+ # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
44
+
45
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
46
+ # config.force_ssl = true
47
+
48
+ # Use the lowest log level to ensure availability of diagnostic information
49
+ # when problems arise.
50
+ config.log_level = :debug
51
+
52
+ # Prepend all log lines with the following tags.
53
+ config.log_tags = [ :request_id ]
54
+
55
+ # Use a different cache store in production.
56
+ # config.cache_store = :mem_cache_store
57
+
58
+ # Use a real queuing backend for Active Job (and separate queues per environment)
59
+ require 'active_job/queue_adapters/better_active_elastic_job_adapter'
60
+ config.active_job.queue_adapter = Settings.active_job.queue_adapter
61
+ # config.active_job.queue_name_prefix = "hyku_#{Rails.env}"
62
+
63
+ # SMTP Mailer configuration
64
+ # Add SMTP settings to your environment and uncomment the following section to enable mailer
65
+ # if ENV['SMTP_ENABLED'].present? && ENV['SMTP_ENABLED'].to_s == 'true'
66
+ # config.action_mailer.smtp_settings = {
67
+ # user_name: ENV['SMTP_USER_NAME'],
68
+ # password: ENV['SMTP_PASSWORD'],
69
+ # address: ENV['SMTP_ADDRESS'],
70
+ # domain: ENV['SMTP_DOMAIN'],
71
+ # port: ENV['SMTP_PORT'],
72
+ # enable_starttls_auto: true,
73
+ # authentication: ENV['SMTP_TYPE']
74
+ # }
75
+ # # ActionMailer Config
76
+ # config.action_mailer.delivery_method = :smtp
77
+ # config.action_mailer.perform_deliveries = true
78
+ # config.action_mailer.raise_delivery_errors = false
79
+ <% if options[:hyku] %>
80
+ # config.action_mailer.asset_host = ENV['SETTINGS__MULTITENANCY__ADMIN_HOST']
81
+ <% end %>
82
+ # else
83
+ # config.action_mailer.delivery_method = :test
84
+ # end
85
+
86
+ config.action_mailer.perform_caching = false
87
+
88
+ # Ignore bad email addresses and do not raise email delivery errors.
89
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
90
+ # config.action_mailer.raise_delivery_errors = false
91
+ #
92
+ config.action_mailer.default_url_options = { protocol: Settings.ssl_configured ? 'https' : 'http' }
93
+
94
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
95
+ # the I18n.default_locale when a translation cannot be found).
96
+ config.i18n.fallbacks = true
97
+
98
+ # Send deprecation notices to registered listeners.
99
+ config.active_support.deprecation = :notify
100
+
101
+ # Use default logging formatter so that PID and timestamp are not suppressed.
102
+ config.log_formatter = ::Logger::Formatter.new
103
+
104
+ # Use a different logger for distributed setups.
105
+ # require 'syslog/logger'
106
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
107
+
108
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
109
+ logger = ActiveSupport::Logger.new(STDOUT)
110
+ logger.formatter = config.log_formatter
111
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
112
+ end
113
+
114
+ # Do not dump schema after migrations.
115
+ config.active_record.dump_schema_after_migration = false
116
+ end
117
+
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env sh
2
+ COUNTER=0;
3
+
4
+ if [ "$SOLR_ADMIN_USER" ]; then
5
+ solr_user_settings="--user $SOLR_ADMIN_USER:$SOLR_ADMIN_PASSWORD"
6
+ fi
7
+
8
+ solr_config_name="${SOLR_CONFIGSET_NAME:-solrconfig}"
9
+ solr_collection_name="${SOLR_COLLECTION_NAME:-hyrax}"
10
+
11
+ # Solr Cloud Collection API URLs
12
+ solr_collection_list_url="$SOLR_HOST:$SOLR_PORT/solr/admin/collections?action=LIST"
13
+ solr_collection_modify_url="$SOLR_HOST:$SOLR_PORT/solr/admin/collections?action=MODIFYCOLLECTION&collection=${solr_collection_name}&collection.configName=${solr_config_name}"
14
+
15
+ while [ $COUNTER -lt 30 ]; do
16
+ if nc -z "${SOLR_HOST}" "${SOLR_PORT}"; then
17
+ if curl --silent $solr_user_settings "$solr_collection_list_url" | grep -q "$solr_collection_name"; then
18
+ echo "-- Collection ${solr_collection_name} exists; setting ${solr_config_name} ConfigSet ..."
19
+ echo $solr_collection_modify_url
20
+ curl $solr_user_settings "$solr_collection_modify_url"
21
+ exit
22
+ else
23
+ echo "-- Collection ${solr_collection_name} does not exist; creating and setting ${solr_config_name} ConfigSet ..."
24
+ solr_collection_create_url="$SOLR_HOST:$SOLR_PORT/solr/admin/collections?action=CREATE&name=${solr_collection_name}&collection.configName=${solr_config_name}&numShards=1"
25
+ curl $solr_user_settings "$solr_collection_create_url"
26
+ exit
27
+ fi
28
+ fi
29
+ echo "-- Looking for Solr (${SOLR_HOST}:${SOLR_PORT})..."
30
+ COUNTER=$(( COUNTER+1 ));
31
+ sleep 5s
32
+ done
33
+
34
+ echo "--- ERROR: failed to create/update Solr collection after 5 minutes";
35
+ exit 1
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env sh
2
+
3
+ COUNTER=0;
4
+ # /app/samvera/hyrax-webapp/solr/conf
5
+ CONFDIR="${1}"
6
+
7
+ if [ "$SOLR_ADMIN_USER" ]; then
8
+ solr_user_settings="--user $SOLR_ADMIN_USER:$SOLR_ADMIN_PASSWORD"
9
+ fi
10
+
11
+ solr_config_name="${SOLR_CONFIGSET_NAME:-solrconfig}"
12
+
13
+ # Solr Cloud ConfigSet API URLs
14
+ solr_config_list_url="http://$SOLR_HOST:$SOLR_PORT/api/cluster/configs?omitHeader=true"
15
+ solr_config_upload_url="http://$SOLR_HOST:$SOLR_PORT/solr/admin/configs?action=UPLOAD&name=${solr_config_name}"
16
+
17
+ while [ $COUNTER -lt 30 ]; do
18
+ echo "-- Looking for Solr (${SOLR_HOST}:${SOLR_PORT})..."
19
+ if nc -z "${SOLR_HOST}" "${SOLR_PORT}"; then
20
+ # shellcheck disable=SC2143,SC2086
21
+ if curl --silent --user 'fake:fake' "$solr_config_list_url" | grep -q '401'; then
22
+ # the solr pods come up and report available before they are ready to accept trusted configs
23
+ # only try to upload the config if auth is on.
24
+ if curl --silent $solr_user_settings "$solr_config_list_url" | grep -q "$solr_config_name"; then
25
+ echo "-- ConfigSet already exists; skipping creation ...";
26
+ else
27
+ echo "-- ConfigSet for ${CONFDIR} does not exist; creating ..."
28
+ (cd "$CONFDIR" && zip -r - *) | curl -X POST $solr_user_settings --header "Content-Type:application/octet-stream" --data-binary @- "$solr_config_upload_url"
29
+ fi
30
+ exit
31
+ else
32
+ echo "-- Solr at $solr_config_list_url is accepting unauthorized connections; we can't upload a trusted ConfigSet."
33
+ echo "-- It's possible SolrCloud is bootstrapping its configuration, so this process will retry."
34
+ echo "-- see: https://solr.apache.org/guide/8_6/configsets-api.html#configsets-upload"
35
+ fi
36
+ fi
37
+ COUNTER=$(( COUNTER+1 ));
38
+ sleep 5s
39
+ done
40
+
41
+ echo "--- ERROR: failed to create Solr ConfigSet after 5 minutes";
42
+ exit 1
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.12.0
4
+ version: 0.15.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: 2021-03-26 00:00:00.000000000 Z
11
+ date: 2022-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: byebug
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -136,7 +150,7 @@ dependencies:
136
150
  - - "~>"
137
151
  - !ruby/object:Gem::Version
138
152
  version: '0.19'
139
- description:
153
+ description:
140
154
  email:
141
155
  - rob@notch8.com
142
156
  executables:
@@ -169,8 +183,13 @@ files:
169
183
  - templates/.env.development.erb
170
184
  - templates/.env.erb
171
185
  - templates/.gitlab-ci.yml.erb
172
- - templates/Dockerfile.base.erb
173
- - templates/Dockerfile.builder.erb
186
+ - templates/.gitlab/issue_templates/Bug.md
187
+ - templates/.gitlab/issue_templates/Feature.md
188
+ - templates/.gitlab/issue_templates/Question.md
189
+ - templates/.gitlab/issue_templates/enable_pipeline_check_before_merge.md
190
+ - templates/.gitlab/merge_request_templates/Bug.md
191
+ - templates/.gitlab/merge_request_templates/Feature.md
192
+ - templates/.sops.yaml.erb
174
193
  - templates/Dockerfile.erb
175
194
  - templates/README.md
176
195
  - templates/chart-fcrepo/fcrepo-deploy.yaml
@@ -199,8 +218,11 @@ files:
199
218
  - templates/chart/templates/web-ing.yaml
200
219
  - templates/chart/templates/web-svc.yaml
201
220
  - templates/database.yml.erb
221
+ - templates/decrypt-secrets
202
222
  - templates/deploy.yml.erb
223
+ - templates/development.rb.erb
203
224
  - templates/docker-compose.yml.erb
225
+ - templates/encrypt-secrets
204
226
  - templates/env.conf.erb
205
227
  - templates/hosts.erb
206
228
  - templates/nginx.sh.erb
@@ -220,13 +242,16 @@ files:
220
242
  - templates/ops/roles/docker.ubuntu/templates/docker.conf
221
243
  - templates/ops/roles/docker.ubuntu/tests/vagrant.yml
222
244
  - templates/ops/roles/docker.ubuntu/vars/main.yml
245
+ - templates/production.rb.erb
223
246
  - templates/provision.yml.erb
247
+ - templates/solrcloud-assign-configset.sh
248
+ - templates/solrcloud-upload-configset.sh
224
249
  - templates/webapp.conf.erb
225
250
  - templates/worker.sh.erb
226
251
  homepage: https://gitlab.com/notch8/stack_car
227
252
  licenses: []
228
253
  metadata: {}
229
- post_install_message:
254
+ post_install_message:
230
255
  rdoc_options: []
231
256
  require_paths:
232
257
  - lib
@@ -241,8 +266,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
266
  - !ruby/object:Gem::Version
242
267
  version: '0'
243
268
  requirements: []
244
- rubygems_version: 3.0.8
245
- signing_key:
269
+ rubygems_version: 3.1.4
270
+ signing_key:
246
271
  specification_version: 4
247
272
  summary: A tool to make rails + docker easy
248
273
  test_files: []
@@ -1,57 +0,0 @@
1
- FROM phusion/passenger-ruby26:1.0.9
2
- ARG DEPLOY_KEY
3
- <% if options[:git] %>
4
- ARG REPO_URL
5
- <% end %>
6
-
7
- RUN <%= pre_apt_string %> && \
8
- curl -sL https://deb.nodesource.com/setup_12.x | bash - && \
9
- apt-get update -qq && \
10
- apt-get install -y \
11
- build-essential \
12
- libsasl2-dev \
13
- nodejs \
14
- pv \
15
- tzdata \
16
- <%= apt_packages_string %> && \
17
- apt-get clean && \
18
- rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
19
- <%= post_apt_string %>
20
-
21
- <% if options[:fcrepo] %>
22
- RUN mkdir -p /opt/fits && \
23
- curl -fSL -o /opt/fits/fits-latest.zip https://projects.iq.harvard.edu/files/fits/files/fits-1.3.0.zip && \
24
- cd /opt/fits && unzip fits-latest.zip && chmod +X /opt/fits/fits.sh
25
- <% end -%>
26
-
27
- RUN rm /etc/nginx/sites-enabled/default
28
- COPY ops/webapp.conf /etc/nginx/sites-enabled/webapp.conf
29
- COPY ops/env.conf /etc/nginx/main.d/env.conf
30
-
31
- ENV APP_HOME /home/app/webapp
32
- RUN mkdir $APP_HOME
33
- WORKDIR $APP_HOME
34
-
35
- ENV BUNDLE_GEMFILE=$APP_HOME/Gemfile \
36
- BUNDLE_JOBS=4
37
-
38
- COPY --chown=app Gemfile* $APP_HOME/
39
- RUN /sbin/setuser app bash -l -c "gem update bundler && (bundle check || bundle install)"
40
-
41
- <% if options[:git] %>
42
- RUN chown -R app $APP_HOME && /sbin/setuser app bash -l -c "git clone --depth 2 ${REPO_URL} ${APP_HOME}""
43
- <% else %>
44
- COPY --chown=app . $APP_HOME
45
- <% end %>
46
-
47
- <% if options[:imagemagick] %>
48
- # reenables pdfs in imagemagick see https://ubuntuforums.org/showthread.php?t=2403266
49
- RUN sed -i '/PDF/s/none/read|write/' /etc/ImageMagick-6/policy.xml
50
- <% end %>
51
-
52
- # this is so that these items are cached and only have to be updated
53
- RUN /sbin/setuser app /bin/bash -l -c 'cd /home/app/webapp && DATABASE_ADAPTER=nulldb bundle exec rake assets:precompile'
54
- # Asset complie and migrate if prod, otherwise just start nginx
55
- ADD ops/nginx.sh /etc/service/nginx/run
56
- RUN chmod +x /etc/service/nginx/run
57
- RUN rm -f /etc/service/nginx/down
@@ -1,13 +0,0 @@
1
- FROM docker:latest
2
-
3
- RUN apk update && \
4
- apk add bash git ruby-json ansible openssh && \
5
- gem install stack_car --no-ri --no-rdoc && \
6
- <% if options[:rancher] %>
7
- wget https://github.com/rancher/cli/releases/download/v0.4.1/rancher-linux-amd64-v0.4.1.tar.gz && \
8
- tar zxfv rancher-linux-amd64-v0.4.1.tar.gz && \
9
- mv rancher-v0.4.1/rancher /bin/rancher
10
- <% end %>
11
- <% if options[:heroku] %>
12
- gem install dpl multi_json --no-ri --no-rdoc
13
- <% end %>