cpl 1.4.0 → 2.0.0.rc.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/command_docs.yml +1 -1
- data/.github/workflows/rspec-shared.yml +56 -0
- data/.github/workflows/rspec.yml +19 -31
- data/.github/workflows/rubocop.yml +2 -10
- data/.gitignore +2 -0
- data/.simplecov_spawn.rb +10 -0
- data/CHANGELOG.md +8 -0
- data/CONTRIBUTING.md +32 -2
- data/Gemfile.lock +34 -29
- data/README.md +34 -25
- data/cpl.gemspec +1 -1
- data/docs/commands.md +54 -54
- data/docs/dns.md +6 -0
- data/docs/migrating.md +10 -10
- data/docs/tips.md +12 -10
- data/examples/circleci.yml +3 -3
- data/examples/controlplane.yml +25 -16
- data/lib/command/apply_template.rb +9 -9
- data/lib/command/base.rb +132 -37
- data/lib/command/build_image.rb +4 -9
- data/lib/command/cleanup_stale_apps.rb +1 -1
- data/lib/command/copy_image_from_upstream.rb +0 -7
- data/lib/command/delete.rb +39 -7
- data/lib/command/deploy_image.rb +18 -3
- data/lib/command/exists.rb +1 -1
- data/lib/command/generate.rb +1 -1
- data/lib/command/info.rb +7 -3
- data/lib/command/logs.rb +22 -2
- data/lib/command/maintenance_off.rb +1 -1
- data/lib/command/maintenance_on.rb +1 -1
- data/lib/command/open.rb +2 -2
- data/lib/command/open_console.rb +2 -2
- data/lib/command/ps.rb +1 -1
- data/lib/command/ps_start.rb +2 -1
- data/lib/command/ps_stop.rb +40 -8
- data/lib/command/ps_wait.rb +3 -2
- data/lib/command/run.rb +430 -69
- data/lib/command/setup_app.rb +4 -1
- data/lib/constants/exit_code.rb +7 -0
- data/lib/core/config.rb +1 -1
- data/lib/core/controlplane.rb +109 -48
- data/lib/core/controlplane_api.rb +7 -1
- data/lib/core/controlplane_api_cli.rb +3 -3
- data/lib/core/controlplane_api_direct.rb +1 -1
- data/lib/core/shell.rb +15 -9
- data/lib/cpl/version.rb +1 -1
- data/lib/cpl.rb +48 -9
- data/lib/deprecated_commands.json +2 -1
- data/lib/generator_templates/controlplane.yml +2 -2
- data/script/check_cpln_links +3 -3
- data/templates/{gvc.yml → app.yml} +5 -0
- data/templates/secrets.yml +8 -0
- metadata +23 -26
- data/.rspec +0 -1
- data/lib/command/run_cleanup.rb +0 -116
- data/lib/command/run_detached.rb +0 -176
- data/lib/core/scripts.rb +0 -34
- data/templates/identity.yml +0 -3
- data/templates/secrets-policy.yml +0 -4
- /data/lib/generator_templates/templates/{gvc.yml → app.yml} +0 -0
data/docs/commands.md
CHANGED
@@ -36,7 +36,7 @@ This `-a` option is used in most of the commands and will pick all other app con
|
|
36
36
|
cpl apply-template redis -a $APP_NAME
|
37
37
|
|
38
38
|
# Applies several templates (practically creating full app).
|
39
|
-
cpl apply-template
|
39
|
+
cpl apply-template app postgres redis rails -a $APP_NAME
|
40
40
|
```
|
41
41
|
|
42
42
|
### `build-image`
|
@@ -105,17 +105,22 @@ cpl copy-image-from-upstream -a $APP_NAME --upstream-token $UPSTREAM_TOKEN --ima
|
|
105
105
|
|
106
106
|
### `delete`
|
107
107
|
|
108
|
-
- Deletes the whole app (GVC with all workloads, all volumesets and all images)
|
108
|
+
- Deletes the whole app (GVC with all workloads, all volumesets and all images) or a specific workload
|
109
109
|
- Will ask for explicit user confirmation
|
110
110
|
|
111
111
|
```sh
|
112
|
+
# Deletes the whole app (GVC with all workloads, all volumesets and all images).
|
112
113
|
cpl delete -a $APP_NAME
|
114
|
+
|
115
|
+
# Deletes a specific workload.
|
116
|
+
cpl delete -a $APP_NAME -w $WORKLOAD_NAME
|
113
117
|
```
|
114
118
|
|
115
119
|
### `deploy-image`
|
116
120
|
|
117
121
|
- Deploys the latest image to app workloads
|
118
122
|
- Optionally runs a release script before deploying if specified through `release_script` in the `.controlplane/controlplane.yml` file and `--run-release-phase` is provided
|
123
|
+
- The release script is run in the context of `cpl run` with the latest image
|
119
124
|
- The deploy will fail if the release script exits with a non-zero code or doesn't exist
|
120
125
|
|
121
126
|
```sh
|
@@ -177,6 +182,7 @@ cpl latest-image -a $APP_NAME
|
|
177
182
|
### `logs`
|
178
183
|
|
179
184
|
- Light wrapper to display tailed raw logs for app/workload syntax
|
185
|
+
- Defaults to showing the last 200 entries from the past 1 hour before tailing
|
180
186
|
|
181
187
|
```sh
|
182
188
|
# Displays logs for the default workload (`one_off_workload`).
|
@@ -184,6 +190,15 @@ cpl logs -a $APP_NAME
|
|
184
190
|
|
185
191
|
# Displays logs for a specific workload.
|
186
192
|
cpl logs -a $APP_NAME -w $WORKLOAD_NAME
|
193
|
+
|
194
|
+
# Displays logs for a specific replica of a workload.
|
195
|
+
cpl logs -a $APP_NAME -w $WORKLOAD_NAME -r $REPLICA_NAME
|
196
|
+
|
197
|
+
# Uses a different limit on number of entries.
|
198
|
+
cpl logs -a $APP_NAME --limit 100
|
199
|
+
|
200
|
+
# Uses a different loopback window.
|
201
|
+
cpl logs -a $APP_NAME --since 30min
|
187
202
|
```
|
188
203
|
|
189
204
|
### `maintenance`
|
@@ -311,6 +326,9 @@ cpl ps:stop -a $APP_NAME
|
|
311
326
|
|
312
327
|
# Stops a specific workload in app.
|
313
328
|
cpl ps:stop -a $APP_NAME -w $WORKLOAD_NAME
|
329
|
+
|
330
|
+
# Stops a specific replica of a workload.
|
331
|
+
cpl ps:stop -a $APP_NAME -w $WORKLOAD_NAME -r $REPLICA_NAME
|
314
332
|
```
|
315
333
|
|
316
334
|
### `ps:wait`
|
@@ -327,26 +345,43 @@ cpl ps:swait -a $APP_NAME -w $WORKLOAD_NAME
|
|
327
345
|
|
328
346
|
### `run`
|
329
347
|
|
330
|
-
- Runs one-off
|
331
|
-
- Uses `
|
332
|
-
-
|
333
|
-
|
334
|
-
|
335
|
-
|
348
|
+
- Runs one-off interactive or non-interactive replicas (analog of `heroku run`)
|
349
|
+
- Uses `Cron` workload type and either:
|
350
|
+
- - `cpln workload exec` for interactive mode, with CLI streaming
|
351
|
+
- - log async fetching for non-interactive mode
|
352
|
+
- The Dockerfile entrypoint is used as the command by default, which assumes `exec "${@}"` to be present,
|
353
|
+
and the args ["bash", "-c", cmd_to_run] are passed
|
354
|
+
- The entrypoint can be overriden through `--entrypoint`, which must be a single command or a script path that exists in the container,
|
355
|
+
and the args ["bash", "-c", cmd_to_run] are passed,
|
356
|
+
unless the entrypoint is `bash`, in which case the args ["-c", cmd_to_run] are passed
|
357
|
+
- Providing `--entrypoint none` sets the entrypoint to `bash` by default
|
358
|
+
- If `fix_terminal_size` is `true` in the `.controlplane/controlplane.yml` file,
|
359
|
+
the remote terminal size will be fixed to match the local terminal size (may also be overriden through `--terminal-size`)
|
336
360
|
|
337
361
|
```sh
|
338
362
|
# Opens shell (bash by default).
|
339
363
|
cpl run -a $APP_NAME
|
340
364
|
|
341
|
-
#
|
342
|
-
cpl run -a $APP_NAME --
|
365
|
+
# Runs interactive command, keeps shell open, and stops job when exiting.
|
366
|
+
cpl run -a $APP_NAME --interactive -- rails c
|
343
367
|
|
344
|
-
#
|
345
|
-
cpl run -a $APP_NAME --
|
346
|
-
cpl run -a $APP_NAME -- rails
|
368
|
+
# Some commands are automatically detected as interactive, so no need to pass `--interactive`.
|
369
|
+
cpl run -a $APP_NAME -- bash
|
370
|
+
cpl run -a $APP_NAME -- rails console
|
371
|
+
cpl run -a $APP_NAME -- rails c
|
372
|
+
cpl run -a $APP_NAME -- rails dbconsole
|
373
|
+
cpl run -a $APP_NAME -- rails db
|
347
374
|
|
348
|
-
# Runs command and
|
349
|
-
cpl run -a $APP_NAME -- rails
|
375
|
+
# Runs non-interactive command, outputs logs, exits with the exit code of the command and stops job.
|
376
|
+
cpl run -a $APP_NAME -- rails db:migrate
|
377
|
+
|
378
|
+
# Runs non-iteractive command, detaches, exits with 0, and prints commands to:
|
379
|
+
# - see logs from the job
|
380
|
+
# - stop the job
|
381
|
+
cpl run -a $APP_NAME --detached -- rails db:migrate
|
382
|
+
|
383
|
+
# The command needs to be quoted if setting an env variable or passing args.
|
384
|
+
cpl run -a $APP_NAME -- 'SOME_ENV_VAR=some_value rails db:migrate'
|
350
385
|
|
351
386
|
# Uses a different image (which may not be promoted yet).
|
352
387
|
cpl run -a $APP_NAME --image appimage:123 -- rails db:migrate # Exact image name
|
@@ -358,47 +393,12 @@ cpl run -a $APP_NAME -w other-workload -- bash
|
|
358
393
|
# Overrides remote CPLN_TOKEN env variable with local token.
|
359
394
|
# Useful when superuser rights are needed in remote container.
|
360
395
|
cpl run -a $APP_NAME --use-local-token -- bash
|
361
|
-
```
|
362
|
-
|
363
|
-
### `run:cleanup`
|
364
|
-
|
365
|
-
- Deletes stale run workloads for an app
|
366
|
-
- Workloads are considered stale based on how many days since created
|
367
|
-
- `stale_run_workload_created_days` in the `.controlplane/controlplane.yml` file specifies the number of days after created that the workload is considered stale
|
368
|
-
- Works for both interactive workloads (created with `cpl run`) and non-interactive workloads (created with `cpl run:detached`)
|
369
|
-
- Will ask for explicit user confirmation of deletion
|
370
|
-
|
371
|
-
```sh
|
372
|
-
cpl run:cleanup -a $APP_NAME
|
373
|
-
```
|
374
|
-
|
375
|
-
### `run:detached`
|
376
|
-
|
377
|
-
- Runs one-off **_non-interactive_** replicas (close analog of `heroku run:detached`)
|
378
|
-
- Uses `Cron` workload type with log async fetching
|
379
|
-
- Implemented with only async execution methods, more suitable for production tasks
|
380
|
-
- Has alternative log fetch implementation with only JSON-polling and no WebSockets
|
381
|
-
- Less responsive but more stable, useful for CI tasks
|
382
|
-
- Deletes the workload whenever finished with success
|
383
|
-
- Deletes the workload whenever finished with failure by default
|
384
|
-
- Use `--no-clean-on-failure` to disable cleanup to help with debugging failed runs
|
385
|
-
|
386
|
-
```sh
|
387
|
-
cpl run:detached rails db:prepare -a $APP_NAME
|
388
396
|
|
389
|
-
#
|
390
|
-
cpl run
|
397
|
+
# Replaces the existing Dockerfile entrypoint with `bash`.
|
398
|
+
cpl run -a $APP_NAME --entrypoint none -- rails db:migrate
|
391
399
|
|
392
|
-
#
|
393
|
-
cpl run
|
394
|
-
cpl run:detached -a $APP_NAME --image latest -- rails db:migrate # Latest sequential image
|
395
|
-
|
396
|
-
# Uses a different workload than `one_off_workload` from `.controlplane/controlplane.yml`.
|
397
|
-
cpl run:detached -a $APP_NAME -w other-workload -- rails db:migrate:status
|
398
|
-
|
399
|
-
# Overrides remote CPLN_TOKEN env variable with local token.
|
400
|
-
# Useful when superuser rights are needed in remote container.
|
401
|
-
cpl run:detached -a $APP_NAME --use-local-token -- rails db:migrate:status
|
400
|
+
# Replaces the existing Dockerfile entrypoint.
|
401
|
+
cpl run -a $APP_NAME --entrypoint /app/alternative-entrypoint.sh -- rails db:migrate
|
402
402
|
```
|
403
403
|
|
404
404
|
### `setup-app`
|
data/docs/dns.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# DNS Setup Example
|
2
2
|
|
3
|
+
## Docs
|
4
|
+
|
5
|
+
https://shakadocs.controlplane.com/guides/configure-domain#dns-records
|
6
|
+
|
7
|
+
## Example
|
8
|
+
|
3
9
|
About reactrails.com DNS, steps:
|
4
10
|
1. create CNAME or ALIAS record pointing to rails-xxxx.cpln.app
|
5
11
|
1. go to CPLN Domains -> create
|
data/docs/migrating.md
CHANGED
@@ -36,7 +36,7 @@ key, e.g.:
|
|
36
36
|
my-app-staging:
|
37
37
|
<<: *common
|
38
38
|
setup_app_templates:
|
39
|
-
-
|
39
|
+
- app
|
40
40
|
- redis
|
41
41
|
- memcached
|
42
42
|
- rails
|
@@ -46,8 +46,8 @@ my-app-staging:
|
|
46
46
|
Note how the templates correspond to files in the `.controlplane/templates/` directory. These files will be used by the
|
47
47
|
`cpl setup-app` and `cpl apply-template` commands.
|
48
48
|
|
49
|
-
Ensure that env vars point to the Heroku add-ons in the template for the app (`.controlplane/templates/
|
50
|
-
[this example](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/.controlplane/templates/
|
49
|
+
Ensure that env vars point to the Heroku add-ons in the template for the app (`.controlplane/templates/app.yml`). See
|
50
|
+
[this example](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/.controlplane/templates/app.yml).
|
51
51
|
|
52
52
|
After that, create a Dockerfile in `.controlplane/Dockerfile` for your deployment. See
|
53
53
|
[this example](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/.controlplane/Dockerfile).
|
@@ -61,7 +61,7 @@ app_main_folder/
|
|
61
61
|
controlplane.yml
|
62
62
|
entrypoint.sh # App-specific - edit as needed.
|
63
63
|
templates/
|
64
|
-
|
64
|
+
app.yml
|
65
65
|
memcached.yml
|
66
66
|
rails.yml
|
67
67
|
redis.yml
|
@@ -93,7 +93,7 @@ cpl setup-app -a my-app-staging
|
|
93
93
|
cpl build-image -a my-app-staging --commit 456
|
94
94
|
|
95
95
|
# Prepare database.
|
96
|
-
cpl run
|
96
|
+
cpl run -a my-app-staging --image latest -- rails db:prepare
|
97
97
|
|
98
98
|
# Deploy latest image.
|
99
99
|
cpl deploy-image -a my-app-staging
|
@@ -113,7 +113,7 @@ cpl build-image -a my-app-staging --commit ABC
|
|
113
113
|
|
114
114
|
# Run database migrations (or other release tasks) with latest image, while app is still running on previous image.
|
115
115
|
# This is analogous to the release phase.
|
116
|
-
cpl run
|
116
|
+
cpl run -a my-app-staging --image latest -- rails db:migrate
|
117
117
|
|
118
118
|
# Deploy latest image.
|
119
119
|
cpl deploy-image -a my-app-staging
|
@@ -192,7 +192,7 @@ configure an entry for, e.g., `my-app-review`, and then create review apps start
|
|
192
192
|
<<: *common
|
193
193
|
match_if_app_name_starts_with: true
|
194
194
|
setup_app_templates:
|
195
|
-
-
|
195
|
+
- app
|
196
196
|
- redis
|
197
197
|
- memcached
|
198
198
|
- rails
|
@@ -215,9 +215,9 @@ fi
|
|
215
215
|
|
216
216
|
# The `NEW_APP` env var that we exported above can be used to either reset or migrate the database before deploying.
|
217
217
|
if [ -n "${NEW_APP}" ]; then
|
218
|
-
cpl run
|
218
|
+
cpl run -a ${APP_NAME} --image latest -- rails db:reset
|
219
219
|
else
|
220
|
-
cpl run
|
220
|
+
cpl run -a ${APP_NAME} --image latest -- rails db:migrate
|
221
221
|
fi
|
222
222
|
```
|
223
223
|
|
@@ -226,7 +226,7 @@ Then follow the same steps for the initial deployment or code upgrades.
|
|
226
226
|
### Database for Review Apps
|
227
227
|
|
228
228
|
For the review app resources, these should be handled as env vars in the template for the app
|
229
|
-
(`.controlplane/templates/
|
229
|
+
(`.controlplane/templates/app.yml`), .e.g.:
|
230
230
|
|
231
231
|
```yaml
|
232
232
|
- name: DATABASE_URL
|
data/docs/tips.md
CHANGED
@@ -65,7 +65,7 @@ The actual remote IP of the workload container is in the 127.0.0.x network, so t
|
|
65
65
|
`REMOTE_ADDR` env var.
|
66
66
|
|
67
67
|
However, Control Plane additionally sets the `x-forwarded-for` and `x-envoy-external-address` headers (and others - see:
|
68
|
-
https://
|
68
|
+
https://shakadocs.controlplane.com/concepts/security#headers). On Rails, the `ActionDispatch::RemoteIp` middleware should
|
69
69
|
pick those up and automatically populate `request.remote_ip`.
|
70
70
|
|
71
71
|
So `REMOTE_ADDR` should not be used directly, only `request.remote_ip`.
|
@@ -87,17 +87,19 @@ level, which applies to your GVCs mapped to that org.
|
|
87
87
|
|
88
88
|
You can do this during the initial app setup, like this:
|
89
89
|
|
90
|
-
1. Add the templates for `
|
91
|
-
2. Ensure that the
|
92
|
-
3.
|
93
|
-
4.
|
94
|
-
5.
|
95
|
-
6.
|
96
|
-
7.
|
90
|
+
1. Add the templates for `app` and `secrets` to `.controlplane/templates`
|
91
|
+
2. Ensure that the `app` template includes the `identity`
|
92
|
+
3. Ensure that the `app` template is listed in `setup_app_templates` for the app in `.controlplane/controlplane.yml`
|
93
|
+
4. Run `cpl apply-template secrets -a $APP_NAME` (one-time setup)
|
94
|
+
5. Run `cpl setup-app -a $APP_NAME`
|
95
|
+
6. The secrets, secrets policy and identity will be automatically created, along with the proper binding
|
96
|
+
7. In the Control Plane console, upper left "Manage Org" menu, click on "Secrets"
|
97
|
+
8. Find the created secret (it will be in the `$APP_PREFIX-secrets` format) and add the secret env vars there
|
98
|
+
9. Use `cpln://secret/...` in the app to access the secret env vars (e.g., `cpln://secret/$APP_PREFIX-secrets.SOME_VAR`)
|
97
99
|
|
98
|
-
|
100
|
+
Here are the manual steps for reference. We recommend that you follow the steps above:
|
99
101
|
|
100
|
-
1. In the upper left "Manage Org" menu, click on "Secrets"
|
102
|
+
1. In the upper left of the Control Plane console, "Manage Org" menu, click on "Secrets"
|
101
103
|
2. Create a secret with `Secret Type: Dictionary` (e.g., `my-secrets`) and add the secret env vars there
|
102
104
|
3. In the upper left "Manage GVC" menu, click on "Identities"
|
103
105
|
4. Create an identity (e.g., `my-identity`)
|
data/examples/circleci.yml
CHANGED
@@ -27,7 +27,7 @@ build-staging:
|
|
27
27
|
command: cpl build-image -a ${APP_NAME}
|
28
28
|
- run:
|
29
29
|
name: Database tasks
|
30
|
-
command: cpl run
|
30
|
+
command: cpl run -a ${APP_NAME} --image latest -- rails db:migrate
|
31
31
|
- run:
|
32
32
|
name: Deploy image
|
33
33
|
command: cpl deploy-image -a ${APP_NAME}
|
@@ -75,9 +75,9 @@ build-review-app:
|
|
75
75
|
name: Database tasks
|
76
76
|
command: |
|
77
77
|
if [ -n "${NEW_APP}" ]; then
|
78
|
-
cpl run
|
78
|
+
cpl run -a ${APP_NAME} --image latest -- rails db:reset
|
79
79
|
else
|
80
|
-
cpl run
|
80
|
+
cpl run -a ${APP_NAME} --image latest -- rails db:migrate
|
81
81
|
fi
|
82
82
|
- run:
|
83
83
|
name: Deploy image
|
data/examples/controlplane.yml
CHANGED
@@ -17,40 +17,53 @@ aliases:
|
|
17
17
|
|
18
18
|
# Control Plane offers the ability to use multiple locations.
|
19
19
|
# default_location is used for commands that require a location
|
20
|
-
# including `ps`, `run`, `
|
20
|
+
# including `ps`, `run`, `apply-template`.
|
21
21
|
# This can be overridden with option --location=<location> and
|
22
22
|
# CPLN_LOCATION environment variable.
|
23
23
|
# TODO: Allow specification of multiple locations.
|
24
24
|
default_location: aws-us-east-2
|
25
25
|
|
26
26
|
# Allows running the command `cpl setup-app`
|
27
|
-
# instead of `cpl apply-template
|
27
|
+
# instead of `cpl apply-template app redis postgres memcached rails sidekiq`.
|
28
28
|
#
|
29
29
|
# Note:
|
30
30
|
# 1. These names correspond to files in the `./controlplane/templates` directory.
|
31
31
|
# 2. Each file can contain many objects, such as in the case of templates that create a resource, like `postgres`.
|
32
32
|
# 3. While the naming often corresponds to a workload or other object name, the naming is arbitrary.
|
33
33
|
# Naming does not need to match anything other than the file name without the `.yml` extension.
|
34
|
+
#
|
35
|
+
# If you're going to use secrets, you need to apply the `secrets.yml` template separately (one-time setup):
|
36
|
+
# `cpl apply-template secrets -a my-app`
|
34
37
|
setup_app_templates:
|
35
|
-
-
|
36
|
-
|
37
|
-
# These templates are only required if using secrets.
|
38
|
-
- identity
|
39
|
-
- secrets
|
40
|
-
- secrets-policy
|
41
|
-
|
38
|
+
- app
|
42
39
|
- redis
|
43
40
|
- postgres
|
44
41
|
- memcached
|
45
42
|
- rails
|
46
43
|
- sidekiq
|
47
44
|
|
45
|
+
# Only needed if using a custom secrets name.
|
46
|
+
# The default is '{APP_PREFIX}-secrets'. For example:
|
47
|
+
# - for an app 'my-app-staging' with `match_if_app_name_starts_with` set to `false`,
|
48
|
+
# it would be 'my-app-staging-secrets'
|
49
|
+
# - for an app 'my-app-review-1234' with `match_if_app_name_starts_with` set to `true`,
|
50
|
+
# it would be 'my-app-review-secrets'
|
51
|
+
secrets_name: my-secrets
|
52
|
+
|
53
|
+
# Only needed if using a custom secrets policy name.
|
54
|
+
# The default is '{APP_SECRETS}-policy'. For example:
|
55
|
+
# - for an app 'my-app-staging' with `match_if_app_name_starts_with` set to `false`,
|
56
|
+
# it would be 'my-app-staging-secrets-policy'
|
57
|
+
# - for an app 'my-app-review-1234' with `match_if_app_name_starts_with` set to `true`,
|
58
|
+
# it would be 'my-app-review-secrets-policy'
|
59
|
+
secrets_policy_name: my-secrets-policy
|
60
|
+
|
48
61
|
# Configure the workload name used as a template for one-off scripts, like a Heroku one-off dyno.
|
49
62
|
one_off_workload: rails
|
50
63
|
|
51
64
|
# Workloads that are for the application itself and are using application Docker images.
|
52
65
|
# These are updated with the new image when running the `deploy-image` command,
|
53
|
-
# and are also used by the `info
|
66
|
+
# and are also used by the `info` and `ps:` commands in order to get all of the defined workloads.
|
54
67
|
# On the other hand, if you have a workload for Redis, that would NOT use the application Docker image
|
55
68
|
# and not be listed here.
|
56
69
|
app_workloads:
|
@@ -58,7 +71,7 @@ aliases:
|
|
58
71
|
- sidekiq
|
59
72
|
|
60
73
|
# Additional "service type" workloads, using non-application Docker images.
|
61
|
-
# These are only used by the `info
|
74
|
+
# These are only used by the `info` and `ps:` commands in order to get all of the defined workloads.
|
62
75
|
additional_workloads:
|
63
76
|
- redis
|
64
77
|
- postgres
|
@@ -68,7 +81,7 @@ aliases:
|
|
68
81
|
maintenance_workload: maintenance
|
69
82
|
|
70
83
|
# Fixes the remote terminal size to match the local terminal size
|
71
|
-
# when running
|
84
|
+
# when running `cpl run`.
|
72
85
|
fix_terminal_size: true
|
73
86
|
|
74
87
|
# Apps with a deployed image created before this amount of days will be listed for deletion
|
@@ -83,10 +96,6 @@ aliases:
|
|
83
96
|
# when running the command `cpl cleanup-images` (`image_retention_max_qty` takes precedence).
|
84
97
|
image_retention_days: 5
|
85
98
|
|
86
|
-
# Run workloads created before this amount of days will be listed for deletion
|
87
|
-
# when running the command `cpl run:cleanup`.
|
88
|
-
stale_run_workload_created_days: 2
|
89
|
-
|
90
99
|
apps:
|
91
100
|
my-app-staging:
|
92
101
|
# Use the values from the common section above.
|
@@ -36,7 +36,7 @@ module Command
|
|
36
36
|
cpl apply-template redis -a $APP_NAME
|
37
37
|
|
38
38
|
# Applies several templates (practically creating full app).
|
39
|
-
cpl apply-template
|
39
|
+
cpl apply-template app postgres redis rails -a $APP_NAME
|
40
40
|
```
|
41
41
|
EX
|
42
42
|
|
@@ -50,7 +50,7 @@ module Command
|
|
50
50
|
@asked_for_confirmation = false
|
51
51
|
|
52
52
|
pending_templates = templates.select do |template|
|
53
|
-
if template == "
|
53
|
+
if template == "app"
|
54
54
|
confirm_app(template)
|
55
55
|
else
|
56
56
|
confirm_workload(template)
|
@@ -64,15 +64,15 @@ module Command
|
|
64
64
|
pending_templates.each do |template, filename|
|
65
65
|
step("Applying template '#{template}'", abort_on_error: false) do
|
66
66
|
items = apply_template(filename)
|
67
|
-
|
68
|
-
items.each do |item|
|
69
|
-
report_success(item)
|
70
|
-
end
|
71
|
-
else
|
67
|
+
unless items
|
72
68
|
report_failure(template)
|
69
|
+
next false
|
73
70
|
end
|
74
71
|
|
75
|
-
|
72
|
+
items.each do |item|
|
73
|
+
report_success(item)
|
74
|
+
end
|
75
|
+
true
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -82,7 +82,7 @@ module Command
|
|
82
82
|
print_failed_templates
|
83
83
|
print_skipped_templates
|
84
84
|
|
85
|
-
exit(
|
85
|
+
exit(ExitCode::ERROR_DEFAULT) if @failed_templates.any?
|
86
86
|
end
|
87
87
|
|
88
88
|
private
|