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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e8df8e8dbd70e738de0a61cd09489c72e4cd822326b237269d21ebe4dacd258
4
- data.tar.gz: 11214bdf66ad316ad4feec518f0ef0e39f9e146aea500c3b7e187a67ecaa33fe
3
+ metadata.gz: e6cc442f70a939d0c26964b5b37fab7c115ce5de2c1c7ad2decf317854028b4b
4
+ data.tar.gz: a245e1232281276530a1b16be06a2baedf938eb39db836d39786f99cd52a2264
5
5
  SHA512:
6
- metadata.gz: 65b81508cd79dd4fdff903820133034b4dc894eeaff69a3033e2439b9cae81f5b34e48055a83485e56f3236ea7111cc9dc24d3c8a3a8cdb8341a5b64490e070a
7
- data.tar.gz: 60223a2ce56c3173e4c62b8d08e05e1d8c6c5fcd2c64027864cef6aa76857c88e3b9a9ae2d6c88cd4a229f2c858f1f1359959b849faffe129119258500b97b2c
6
+ metadata.gz: 7108eaf37d7a5f0ae241eb6365a93d731329c04cbe13571002894ae4c80192893512dc29a1a32f95dfd15d3309682290682a2efa381b93dcce894c1e551072ae
7
+ data.tar.gz: d23c829079977213a1877733c8f814041df4afb258269861311184e5044ded8b5dcda760b31c3ec4a9e6e5ea8f8a23d43f23ad65f385e329271db2b2d50f985b
data/.gitlab-ci.yml CHANGED
@@ -1,17 +1,22 @@
1
- image: ruby:2.3
1
+ stages:
2
+ - rspec
2
3
 
3
4
  before_script:
4
- bundle
5
+ - bundle
5
6
 
6
- pages:
7
- script:
8
- - bundle exec yardoc --plugin yard-thor -o public - templates/.* templates/*
9
- artifacts:
10
- paths:
11
- - public
12
- only:
13
- - master
7
+ # pages:
8
+ # script:
9
+ # - bundle exec yardoc --plugin yard-thor -o public - templates/.* templates/*
10
+ # artifacts:
11
+ # paths:
12
+ # - public
13
+ # only:
14
+ # - master
14
15
 
15
- test:
16
+ rspec:
17
+ stage: rspec
18
+ image: ruby:2.3
16
19
  script:
17
- bundle exec rake
20
+ - bundle exec rspec
21
+ tags:
22
+ - docker
data/README.md CHANGED
@@ -4,6 +4,13 @@
4
4
 
5
5
  Stack Car is an opinionated set of tools around Docker and Rails. It provides convenent methods to start and stop docker-compose, to deploy with rancher and a set of templates to get a new Rails app in to docker as quickly as possible.
6
6
 
7
+ ## Table of Contents
8
+
9
+ - [Installation](#installation)
10
+ - [Usage](#usage)
11
+ - [Development](#development)
12
+ - [Dockerizing an Application](#dockerizing-an-application)
13
+ - [Generating a Helm Chart](#generating-a-helm-chart)
7
14
 
8
15
  ## Installation
9
16
 
@@ -19,14 +26,14 @@ Commands are accesible via the "sc" short cut. Note: this will need to be in you
19
26
 
20
27
  ```ruby
21
28
  Commands:
22
- stack_car bundle_exec ARGS # wraps docker-compose exec web bundle exec unless --service is used to specify (sc be ARGS)
29
+ stack_car bundle_exec ARGS # wraps docker compose exec web bundle exec unless --service is used to specify (sc be ARGS)
23
30
  stack_car console ARGS # shortcut to start rails console
24
31
  stack_car dockerize DIR # Will copy the docker tempates in to your project, see options for supported dependencies
25
- stack_car exec ARGS # wraps docker-compose exec web unless --service is used to specify
32
+ stack_car exec ARGS # wraps docker compose exec web unless --service is used to specify
26
33
  stack_car help [COMMAND] # Describe available commands or one specific command
27
- stack_car stop # starts docker-compose with rebuild and orphan removal, defaults to all
28
- stack_car up # starts docker-compose with rebuild and orphan removal, defaults to web
29
- stack_car walk ARGS # wraps docker-compose run web unless --service is used to specify
34
+ stack_car stop # starts docker compose with rebuild and orphan removal, defaults to all
35
+ stack_car up # starts docker compose with rebuild and orphan removal, defaults to web
36
+ stack_car walk ARGS # wraps docker compose run web unless --service is used to specify
30
37
  ```
31
38
 
32
39
  ## Development
@@ -50,10 +57,78 @@ Developing stack_car often requires a rails application for you to run updated c
50
57
  - Commit your changes
51
58
 
52
59
  ### Releasing a new version
53
- - Update the version number in `version.rb`
60
+ **NOTE:** You will need an account for [rubygems.org](https://rubygems.org) and be made an owner of the [stack_car gem](https://rubygems.org/gems/stack_car) in order to release a new version.
61
+
62
+ - Update the version number in `version.rb`. Please follow [Semantic Versioning](https://semver.org/) guidelines.
63
+ - Commit `version.rb` and create an MR. Once the MR is approved and merged, checkout the `main` branch and do a `git pull`.
54
64
  - Run `bundle exec rake release`
55
65
  - This will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
56
66
 
67
+ ## Dockerizing an application
68
+
69
+ Dockerizing your application with stack_car can be thought of in 2 steps:
70
+ - **Generate the file templates**
71
+ - **Customize provided templates to the requirements of the application**
72
+
73
+ **Set MERGE tool**
74
+ When using stack_car to dockerize an app, it might be necessary to merge templates as opposed to completely overwriting them. To set a tool run:
75
+ ```bash
76
+ export THOR_MERGE=<editor>
77
+ ```
78
+ Alternatively, set it in your shell's `rc` file (`~/.bashrc`, `~/.zshrc`, etc.)
79
+
80
+ With `THOR_MERGE` set, you can enter `m` at the command prompt when there is a conflict between app and `sc` template files.
81
+
82
+ *Note*: For best experience, set `THOR_MERGE` to **GUI text editor** (ie. `code` or `atom`).
83
+
84
+ Initiating a merge pulls 2 versions of the file to the editor. One is what is proposed by stack_car, the other is the original. **Add what you need from the template version to the original file and save the changes**.
85
+
86
+ ### Generate templates (`sc dockerize`)
87
+ You can generate requisite files for running your application for local development in Docker with the **dockerize** command.
88
+
89
+ To **dockerize** your application:
90
+ - `cd` into your project dir
91
+ - Run `sc dockerize` to generate files, appending **service flags** to scaffold any other services your application requires
92
+ - **For example**:
93
+ - For rails/postgres: `sc dockerize --postgres`
94
+ - For rails/mysql/redis: `sc dockerize --mysql --redis`
95
+
96
+ This command will provide:
97
+ - `Dockerfile`
98
+ - `docker-compose.yml`
99
+ - `.env*` files
100
+ - **ops** files to get you set up for running your application with **nginx**.
101
+
102
+ ### Customize templates
103
+
104
+ stack_car will have provided sensible defaults for your services but customization will be required per needs of each project (ie api tokens and email configuration where applicable).
105
+
106
+ **Customization workflow**
107
+ - Do a text search to find and replace any instances `CHANGEME` in the generated files
108
+ - Add any **general environment variables** to `.env`
109
+ - This sets defaults for all docker compose environments
110
+ - Add any **development environment variables** to `.env.development`
111
+ - These set up any new values or overrides specific to your development env
112
+ - Run `sc build` to build your image
113
+ - On failed build, browse the terminal output to track down and squash any misconfigurations. Rebuild
114
+ - Upon successful build, run `sc up` to spin up project
115
+ - If you get errors, browse the terminal output to track down and squash any misconfigurations (refer to the Docker dashboard to see separate logs for each service)
116
+ - Visit site at `localhost:3000`
117
+ - Alternatively, visit it at the host you have specified to work with **Dory**
118
+ - **Note**: *Depending on the DB required by your application, you will need to create the DB. You need to do that within from the container:*
119
+ - Using the `bundle-exec` command: `sc bundle-exec db:create`
120
+ - Shelling in and running in the container shell:
121
+ ```bash
122
+ sc exec bash
123
+ bundle exec rails db:create
124
+ ```
125
+
126
+ Once all services are running and speaking to each other you are good to go.
127
+
128
+ **Tips**:
129
+ - Any changes to `Dockerfile` will require `sc build` for the changes to manifest
130
+ - Changes to `docker-compose.yml` **do not require rebuild unless you have changed the image**
131
+
57
132
  ## Generating a Helm Chart
58
133
 
59
134
  stack_car's **dockerize** command can be used in conjunction with available flags to generate a **Helm chart** template for your application. You will need to create the *values* files with necessary configuration values from the *sample-values* provided by stack_car, but the command will effectively give you the baseline Notch8 template (scripts, template files, template helpers, sample values file) for a **Helm base Kubernetes deploy**
@@ -88,15 +163,14 @@ Since values files are likely to contain sensitive information like API keys, th
88
163
 
89
164
  Example workflow (given values file is already created):
90
165
  - Edit values file
91
- - `chart/bin/encrypt staging <keybase-team-name>`
92
- - This command will create `staging-values.yaml.enc`
93
- - `git add staging-values.yaml.enc`
166
+ - `bin/encrypt-secrets`
167
+ - This command will create/update `staging-values.yaml.enc`
94
168
  - Commit and push
95
169
 
96
170
  When pulling down a repo or branch, you will need to start by decrypting.
97
171
 
98
172
  Example:
99
- - `chart/bin/decrypt staging`
173
+ - `bin/decrypt-secrets`
100
174
 
101
175
  ## Contributing
102
176
 
data/lib/stack_car/cli.rb CHANGED
@@ -18,17 +18,17 @@ module StackCar
18
18
  method_option :service, default: 'web', type: :string, aliases: '-s'
19
19
  method_option :build, default: false, type: :boolean, aliases: '-b'
20
20
  method_option :logs, default: true, type: :boolean
21
- desc "up", "starts docker-compose with rebuild and orphan removal, defaults to web"
21
+ desc "up", "starts docker compose with rebuild and orphan removal, defaults to web"
22
22
  def up
23
23
  setup
24
24
  ensure_development_env
25
25
  args = ['--remove-orphans']
26
26
  args << '--build' if options[:build]
27
27
  if options[:build]
28
- run("#{dotenv} docker-compose pull #{options[:service]}")
28
+ run("#{dotenv} docker compose pull #{options[:service]}")
29
29
  end
30
30
 
31
- run_with_exit("#{dotenv} docker-compose up #{args.join(' ')} #{options[:service]}")
31
+ run_with_exit("#{dotenv} docker compose up #{args.join(' ')} #{options[:service]}")
32
32
  end
33
33
 
34
34
  method_option :service, default: '', type: :string, aliases: '-s'
@@ -36,75 +36,123 @@ module StackCar
36
36
  def stop
37
37
  setup
38
38
  ensure_development_env
39
- run("#{dotenv} docker-compose stop #{options[:service]}")
39
+ run("#{dotenv} docker compose stop #{options[:service]}")
40
40
  run_with_exit("rm -rf tmp/pids/*")
41
41
  end
42
- map down: :stop
42
+
43
+ method_option :volumes, aliases: '-v'
44
+ method_option :rmi
45
+ method_option :'remove-orphans'
46
+ method_option :service, aliases: '-s'
47
+ method_option :timeout, aliases: '-t'
48
+ method_option :all, aliases: '-a'
49
+ method_option :help, aliases: '-h'
50
+ desc 'down', 'stops and removes containers and networks specific to this project by default, run with -h for more options'
51
+ def down
52
+ setup
53
+ ensure_development_env
54
+
55
+ if options[:help]
56
+ run('docker compose down --help')
57
+ say 'Additional stack_car options:'
58
+ say ' -a, --all Removes all containers, networks, volumes, and'
59
+ say ' images created by `up`.'
60
+ say ' -s, --service Specify a service defined in the Compose file'
61
+ say ' whose containers and volumes should be removed.'
62
+ exit(0)
63
+ end
64
+
65
+ if options[:service]
66
+ rm_vol = true if options[:volumes]
67
+
68
+ remove_container(options[:service], rm_vol)
69
+ exit(0)
70
+ end
71
+
72
+ run_conf = 'Running down will stop and remove all of the Docker containers and networks ' \
73
+ 'defined in the docker-compose.yml file. Continue?'
74
+ prompt_run_confirmation(run_conf)
75
+
76
+ args = []
77
+ if options[:all]
78
+ prompt_run_confirmation('--all will remove all containers, volumes, networks, local images, and orphaned containers. Continue?')
79
+
80
+ args = %w[--volumes --rmi=local --remove-orphans]
81
+ else
82
+ args << '--volumes' if options[:volumes]
83
+ args << '--rmi=local' if options[:rmi]
84
+ args << '--remove-orphans' if options[:'remove-orphans']
85
+ args << '--timeout' if options[:timeout]
86
+ end
87
+
88
+ run("#{dotenv} docker compose down #{args.join(' ')}")
89
+ run_with_exit('rm -rf tmp/pids/*')
90
+ end
43
91
 
44
92
  method_option :service, default: 'web', type: :string, aliases: '-s'
45
93
  desc "build", "builds specified service, defaults to web"
46
94
  def build
47
95
  setup
48
96
  ensure_development_env
49
- run_with_exit("#{dotenv} docker-compose build #{options[:service]}")
97
+ run_with_exit("#{dotenv} docker compose build #{options[:service]}")
50
98
  end
51
99
 
52
100
  method_option :service, default: 'web', type: :string, aliases: '-s'
53
- desc "push ARGS", "wraps docker-compose push web unless --service is used to specify"
101
+ desc "push ARGS", "wraps docker compose push web unless --service is used to specify"
54
102
  def push(*args)
55
103
  setup
56
- run_with_exit("#{dotenv} docker-compose push #{options[:service]} #{args.join(' ')}")
104
+ run_with_exit("#{dotenv} docker compose push #{options[:service]} #{args.join(' ')}")
57
105
  end
58
106
 
59
107
  method_option :service, default: 'web', type: :string, aliases: '-s'
60
- desc "pull ARGS", "wraps docker-compose pull web unless --service is used to specify"
108
+ desc "pull ARGS", "wraps docker compose pull web unless --service is used to specify"
61
109
  def pull(*args)
62
110
  setup
63
- run_with_exit("#{dotenv} docker-compose pull #{options[:service]} #{args.join(' ')}")
111
+ run_with_exit("#{dotenv} docker compose pull #{options[:service]} #{args.join(' ')}")
64
112
  end
65
113
 
66
114
  method_option :service, default: '', type: :string, aliases: '-s'
67
- desc "ps ARGS", "wraps docker-compose pull web unless --service is used to specify"
115
+ desc "ps ARGS", "wraps docker compose pull web unless --service is used to specify"
68
116
  def ps(*args)
69
117
  setup
70
- run_with_exit("#{dotenv} docker-compose ps #{options[:service]} #{args.join(' ')}")
118
+ run_with_exit("#{dotenv} docker compose ps #{options[:service]} #{args.join(' ')}")
71
119
  end
72
120
  map status: :ps
73
121
 
74
122
  method_option :service, default: 'web', type: :string, aliases: '-s'
75
- desc "bundle ARGS", "wraps docker-compose run web unless --service is used to specify"
123
+ desc "bundle ARGS", "wraps docker compose run web unless --service is used to specify"
76
124
  def bundle(*args)
77
125
  setup
78
- run_with_exit("#{dotenv} docker-compose exec #{options[:service]} bundle")
126
+ run_with_exit("#{dotenv} docker compose exec #{options[:service]} bundle")
79
127
  end
80
128
 
81
129
  method_option :service, default: 'web', type: :string, aliases: '-s'
82
- desc "walk ARGS", "wraps docker-compose run web unless --service is used to specify"
130
+ desc "walk ARGS", "wraps docker compose run web unless --service is used to specify"
83
131
  def walk(*args)
84
132
  setup
85
- run_with_exit("#{dotenv} docker-compose run #{options[:service]} #{args.join(' ')}")
133
+ run_with_exit("#{dotenv} docker compose run #{options[:service]} #{args.join(' ')}")
86
134
  end
87
135
 
88
136
  method_option :service, default: 'web', type: :string, aliases: '-s'
89
- desc "exec ARGS", "wraps docker-compose exec web unless --service is used to specify"
137
+ desc "exec ARGS", "wraps docker compose exec web unless --service is used to specify"
90
138
  def exec(*args)
91
139
  setup
92
- run_with_exit("#{dotenv} docker-compose exec #{options[:service]} #{args.join(' ')}")
140
+ run_with_exit("#{dotenv} docker compose exec #{options[:service]} #{args.join(' ')}")
93
141
  end
94
142
  map ex: :exec
95
143
 
96
144
  method_option :service, default: 'web', type: :string, aliases: '-s'
97
- desc 'sh ARGS', "launch a shell using docker-compose exec, sets tty properly"
145
+ desc 'sh ARGS', "launch a shell using docker compose exec, sets tty properly"
98
146
  def sh(*args)
99
147
  setup
100
- run_with_exit("#{dotenv} docker-compose exec -e COLUMNS=\"\`tput cols\`\" -e LINES=\"\`tput lines\`\" #{options[:service]} bash #{args.join(' ')}")
148
+ run_with_exit("#{dotenv} docker compose exec -e COLUMNS=\"\`tput cols\`\" -e LINES=\"\`tput lines\`\" #{options[:service]} bash #{args.join(' ')}")
101
149
  end
102
150
 
103
151
  method_option :service, default: 'web', type: :string, aliases: '-s'
104
- desc "bundle_exec ARGS", "wraps docker-compose exec web bundle exec unless --service is used to specify"
152
+ desc "bundle_exec ARGS", "wraps docker compose exec web bundle exec unless --service is used to specify"
105
153
  def bundle_exec(*args)
106
154
  setup
107
- run_with_exit("#{dotenv} docker-compose exec #{options[:service]} bundle exec #{args.join(' ')}")
155
+ run_with_exit("#{dotenv} docker compose exec #{options[:service]} bundle exec #{args.join(' ')}")
108
156
  end
109
157
  map be: :bundle_exec
110
158
 
@@ -112,7 +160,7 @@ module StackCar
112
160
  desc "console ARGS", "shortcut to start rails console"
113
161
  def console(*args)
114
162
  setup
115
- run_with_exit("#{dotenv} docker-compose exec #{options[:service]} bundle exec rails console #{args.join(' ')}")
163
+ run_with_exit("#{dotenv} docker compose exec #{options[:service]} bundle exec rails console #{args.join(' ')}")
116
164
  end
117
165
  map rc: :console
118
166
 
@@ -165,17 +213,17 @@ module StackCar
165
213
  method_option :elasticsearch, default: false, type: :boolean, aliases: '-e'
166
214
  method_option :fcrepo, default: false, type: :boolean, aliases: '-f'
167
215
  method_option :helm, default: false, type: :boolean, aliases: '-h'
168
- method_option :git, default: true, type: :boolean, aliases: '-g'
216
+ method_option :git, default: false, type: :boolean, aliases: '-g'
169
217
  method_option :heroku, default: false, type: :boolean, aliases: '-h'
170
- method_option :hyku, default: false, type: :boolean, aliases: '-u'
218
+ method_option :hyku, default: false, type: :boolean, aliases: "\--hu"
171
219
  method_option :imagemagick, default: false, type: :boolean, aliases: '-i'
172
- method_option :memcached, default: false, type: :boolean, aliases: '-mc'
173
- method_option :mongodb, default: false, type: :boolean, aliases: '-mg'
220
+ method_option :memcached, default: false, type: :boolean, aliases: "\--mc"
221
+ method_option :mongodb, default: false, type: :boolean, aliases: "\--mg"
174
222
  method_option :mysql, default: false, type: :boolean, aliases: '-m'
175
223
  method_option :postgres, default: false, type: :boolean, aliases: '-p'
176
- method_option :rancher, default: false, type: :boolean, aliases: '-dr'
224
+ method_option :rancher, default: false, type: :boolean, aliases: "\--dr"
177
225
  method_option :redis, default: false, type: :boolean, aliases: '-r'
178
- method_option :sidekiq, default: false, type: :boolean, aliases: '-sq' # TODO
226
+ method_option :sidekiq, default: false, type: :boolean, aliases: "\--sk"
179
227
  method_option :solr, default: false, type: :boolean, aliases: '-s'
180
228
  method_option :yarn, default: false, type: :boolean, aliases: '-y'
181
229
  desc 'dockerize DIR', 'Will copy the docker tempates in to your project, see options for supported dependencies'
@@ -191,7 +239,8 @@ module StackCar
191
239
  setup
192
240
  # Commandline overrides config files
193
241
  # options = file_config.merge(options)
194
- @project_name = File.basename(File.expand_path(dir))
242
+ # Sets project name to parent directory name if working with stack_car dir
243
+ @project_name = @sc_dir ? File.basename(File.expand_path('..')) : File.basename(File.expand_path(dir))
195
244
  apt_packages << "libpq-dev postgresql-client" if options[:postgres]
196
245
  apt_packages << "mysql-client" if options[:mysql]
197
246
  apt_packages << "imagemagick" if options[:imagemagick]
@@ -214,14 +263,25 @@ module StackCar
214
263
  post_apt << "cd /opt && unzip fits-1.0.5.zip && chmod +X fits-1.0.5/fits.sh"
215
264
  end
216
265
 
217
- ['.dockerignore', 'Dockerfile', 'Dockerfile.base', 'docker-compose.yml', '.gitlab-ci.yml', '.env'].each do |template_file|
266
+ ['.dockerignore', 'Dockerfile', 'docker-compose.yml', '.gitlab-ci.yml', '.env'].each do |template_file|
218
267
  puts template_file
219
268
  template("#{template_file}.erb", template_file)
220
269
  end
221
- template("database.yml.erb", "config/database.yml")
270
+ directory('.gitlab', '.gitlab')
222
271
  template(".env.development.erb", ".env.development")
223
272
  template(".env.erb", ".env.production")
273
+ template(".sops.yaml.erb", ".sops.yaml")
274
+ template("decrypt-secrets", "bin/decrypt-secrets")
275
+ template("encrypt-secrets", "bin/encrypt-secrets")
276
+ template("database.yml.erb", "config/database.yml")
277
+ template("development.rb.erb", "config/environments/development.rb")
278
+ template("production.rb.erb", "config/environments/production.rb")
224
279
 
280
+ if options[:solr]
281
+ template("solrcloud-upload-configset.sh", "bin/solrcloud-upload-configset.sh")
282
+ template("solrcloud-assign-configset.sh", "bin/solrcloud-assign-configset.sh")
283
+ end
284
+
225
285
  if File.exists?('README.md')
226
286
  prepend_to_file "README.md" do
227
287
  File.read("#{self.class.source_root}/README.md")
@@ -272,7 +332,7 @@ module StackCar
272
332
  protected
273
333
  def compose_depends(*excludes)
274
334
  @compose_depends = []
275
- services = [:postgres, :mysql, :elasticsearch, :solr, :redis, :mongodb, :memcached] - excludes
335
+ services = [:fcrepo, :postgres, :mysql, :elasticsearch, :sidekiq, :solr, :redis, :mongodb, :memcached] - excludes
276
336
  services.each do |service|
277
337
  if options[service]
278
338
  @compose_depends << " - #{service}"
@@ -344,10 +404,83 @@ module StackCar
344
404
 
345
405
  def setup
346
406
  if File.exists?('stack_car')
407
+ @sc_dir = true
347
408
  Dir.chdir('stack_car')
348
409
  self.destination_root += "/stack_car"
349
410
  end
350
411
  DotRc.new
351
412
  end
413
+
414
+ def remove_container(service_name, remove_volumes)
415
+ container = find_container_by_service(service_name)
416
+
417
+ container.map do |id, name|
418
+ prompt_run_confirmation("Remove #{name} container?")
419
+
420
+ if `docker container ls --format "{{.Names}}"`.include?(name)
421
+ say 'Stopping container...'
422
+ `docker stop #{id}`
423
+ end
424
+
425
+ say 'Removing container...'
426
+ `docker container rm #{id}`
427
+
428
+ # Ensure container was removed
429
+ if `docker ps -aqf id=#{id}`.empty?
430
+ say " Container #{name} was removed"
431
+ else
432
+ say ">>> There was an issue removing container #{name} (#{id})"
433
+ end
434
+ end
435
+
436
+ remove_volumes_mounted_to_container(@container_volume_names) if remove_volumes
437
+ end
438
+
439
+ def find_container_by_service(service_name)
440
+ container_id = `docker compose ps -aq #{service_name}`.strip
441
+
442
+ if container_id.empty?
443
+ say "Unable to locate a container for the service '#{service_name}'"
444
+ say "Try running `docker compose ps #{service_name}` to make sure the container exists"
445
+ exit(1)
446
+ end
447
+
448
+ get_volume_names_for_container(container_id)
449
+ container_name = `docker ps -af id=#{container_id} --format "{{.Names}}"`.strip
450
+
451
+ { container_id => container_name }
452
+ end
453
+
454
+ def remove_volumes_mounted_to_container(volumes)
455
+ return if volumes.empty?
456
+
457
+ prompt_run_confirmation("\n#{volumes.join("\n")}\nRemove these volume(s)?")
458
+ volumes.each do |v|
459
+ say 'Removing volume...'
460
+ `docker volume rm #{v}`
461
+
462
+ if `docker volume ls -q`.include?(v)
463
+ say ">>> There was an issue removing volume #{v}"
464
+ else
465
+ say " Volume #{v} was removed"
466
+ end
467
+ end
468
+ end
469
+
470
+ def get_volume_names_for_container(container_id)
471
+ @container_volume_names ||= []
472
+ return @container_volume_names unless @container_volume_names.empty?
473
+
474
+ JSON.parse(`docker inspect --format="{{json .Mounts}}" #{container_id}`).map do |mount_info|
475
+ @container_volume_names << mount_info['Name'] if mount_info['Type'] == 'volume'
476
+ end
477
+
478
+ @container_volume_names
479
+ end
480
+
481
+ def prompt_run_confirmation(question)
482
+ response = ask(question, limited_to: %w[y n])
483
+ exit(1) unless response == 'y'
484
+ end
352
485
  end
353
486
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module StackCar
2
- VERSION = "0.12.0"
4
+ VERSION = '0.15.0'
3
5
  end
data/stack_car.gemspec CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  spec.add_development_dependency "bundler", "~> 1.13"
23
+ spec.add_development_dependency "byebug"
23
24
  spec.add_development_dependency "rake", "~> 10.0"
24
25
  spec.add_development_dependency "rspec", "~> 3.0"
25
26
  spec.add_development_dependency "yard"
data/templates/.env.erb CHANGED
@@ -2,6 +2,20 @@ APP_NAME=<%= @project_name %>
2
2
  PASSENGER_APP_ENV=development
3
3
  REGISTRY_HOST=registry.gitlab.com
4
4
  REGISTRY_URI=/CHANGEME/<%= @project_name %>
5
+
6
+ # SMTP Mailer variables
7
+ # To enable mailer:
8
+ # - Uncomment and edit SMTP vars
9
+ # - Uncomment SMTP Mailer section in respective config/environments file
10
+ # SMTP_USER_NAME=CHANGEME
11
+ # SMTP_PASSWORD=CHANGEME
12
+ # SMTP_ADDRESS=CHANGEME
13
+ # SMTP_DOMAIN=CHANGEME
14
+ # SMTP_PORT=CHANGEME
15
+ # SMTP_TYPE=CHANGEME
16
+ <% if options[:hyku] %>
17
+ # SETTINGS__MULTITENANCY__ADMIN_HOST=CHANGEME
18
+ <% end %>
5
19
  TAG=dev
6
20
  <% if options[:postgres] -%>
7
21
  DATABASE_NAME=<%= @project_name %>
@@ -27,3 +41,12 @@ ES_URL=http://elasticsearch:9200
27
41
  SITE_URI=https://CHANGEME.com
28
42
  DEPLOY_HOOK=CHANGEME
29
43
  <% end -%>
44
+ <% if options[:solr] -%>
45
+ SOLR_URL=http://admin:admin@solr:8983/solr/<%= @project_name %>-development
46
+ SOLR_ADMIN_PASSWORD=admin
47
+ SOLR_ADMIN_USER=admin
48
+ SOLR_COLLECTION_NAME=<%= @project_name %>-development
49
+ SOLR_CONFIGSET_NAME=<%= @project_name %>
50
+ SOLR_HOST=solr
51
+ SOLR_PORT=8983
52
+ <% end -%>
@@ -0,0 +1,46 @@
1
+ # Summary
2
+
3
+ A short description of the bug. Use # to link to the parent issue or merge request
4
+
5
+ # Observed Behavior
6
+
7
+ The current, bugged behavior.
8
+
9
+ # Expected Behavior
10
+
11
+ How it should behave once it's fixed. What "done" looks like.
12
+
13
+ # Screenshots or Video
14
+
15
+ Include screenshots or videos that demonstrate the bug
16
+
17
+ # Other Information
18
+
19
+ Any other logs, related issues, merge requests, wireframes, documentation, slack conversations or anything else that would help the developer try to find and fix this issue, or provide context.
20
+
21
+ # Acceptance Criteria
22
+
23
+ This is what done looks like. A higher level checklist of the goals and functionality after this bug is fixed
24
+
25
+ * [ ] I see these views
26
+ * [ ] When a user does this, that happens
27
+
28
+ # Steps to Reproduce / Testing Instructions
29
+
30
+ How did you trigger this bug? Include links to the page where the error occured, if applicable.
31
+
32
+ * [ ] As a (logged in/admin/etc) User
33
+ * [ ] With these other conditions
34
+ * [ ] I did these things
35
+ * [ ] And observed this behavior
36
+
37
+ ## Further information
38
+
39
+ Edit in any later issues or merge requests that are conencted to this issue, for future reference
40
+
41
+ ### Implementation suggestions
42
+
43
+ Are nice, but should probably go in a comment. e.g. gems, unrelated issues that dealt with similar problems, stack overflow links.
44
+
45
+ /label ~"Needs Rework", ~"Ready for Development"
46
+ <!-- By default, should bugs go to Ready for development, to be on the development board, or be like normal issues and go to the planning board> -->
@@ -0,0 +1,41 @@
1
+ # Summary
2
+
3
+ A short description of the feature
4
+
5
+ # User Stories
6
+
7
+ What problem is this feature going to solve?
8
+
9
+ # Screenshots or Video
10
+
11
+ Include any relevant media such as wireframes, screenshots, or videos
12
+
13
+ # Relationships
14
+
15
+ Are there any other issues or merge requests that are related to this feature (use # to generate a quick link). In particular, is this part of a larger epic, or does it depend on any other tickets being resolved first? Do you need anything else or are you making any other assumptions for this feature?
16
+
17
+ # Acceptance Criteria
18
+
19
+ This is what done looks like. A higher level checklist of the goals and functionality of this feature
20
+
21
+ * [ ] I see these views
22
+ * [ ] When a user does this, that happens
23
+
24
+ # Testing Instructions
25
+
26
+ Steps to demonstrate this feature is properly working. Include a video, if possible. The How to the Acceptance Criteria's What
27
+
28
+ * [ ] As a (user/admin)
29
+ * [ ] Go here and do these things
30
+ * [ ] To see this happen
31
+
32
+
33
+ ## Further information
34
+
35
+ Edit in any later issues or merge requests that are conencted to this issue, for future reference
36
+
37
+ ### Implimentation Suggestions
38
+
39
+ Any development details that would be helpful when working on this feature e.g. gems, unrelated issues that dealt with similar problems, stack overflow links.
40
+
41
+ /label ~Icebox
@@ -0,0 +1,18 @@
1
+ # Summary
2
+ A short description of the question.
3
+
4
+ ## Who has this information
5
+ Consider using @ to tag them, if they're in this repository
6
+
7
+ # Additional information
8
+ More details about what needs to be answered
9
+ * [ ] Checkboxes are helpful
10
+ * [ ] To make sure all answers are enumerated
11
+
12
+ # Other links
13
+ Pictures, videos, links to issues, or anything else that might be helpful to provide context for the question
14
+
15
+ /label ~"Planning in Progress"
16
+
17
+ /assign me
18
+ <!-- this might cause inboxes to explode, but presumably the one creating a question ticket would be the one who was taking ownership for it, and would be the one responsible for cleaning it up once the question was answered -->