|
1 | 1 | # Deploying tutorial app on Control Plane
|
2 | 2 |
|
| 3 | +## Overview |
| 4 | +This simple example shows how to deploy a simple app on Control Plane using the `cpl` gem. |
| 5 | + |
| 6 | +To maximize simplicity, this example creates Postgres and Redis as workloads in the same GVC as the app. |
| 7 | +In a real app, you would likely use persistent, external resources, such as AWS RDS and AWS ElastiCache. |
| 8 | + |
| 9 | +You can see the definition of Postgres and Redis in the `.controlplane/templates` directory. |
| 10 | + |
3 | 11 | ## Prerequisites
|
4 | 12 |
|
5 |
| -1. Should have [Control Plane](https://controlplane.com) account set up. |
| 13 | +1. Ensure your [Control Plane](https://controlplane.com) account is set up. |
| 14 | + |
| 15 | +2. Set up an `organization` for testing in that account and modify `aliases.common.cpln_org` in `.controlplane/controlplane.yml` . |
| 16 | + |
| 17 | +3. Install Control Plane CLI (and configure access) [docs here](https://docs.controlplane.com/quickstart/quick-start-3-cli#getting-started-with-the-cli). You can update the `cpln` command line with the same command as installation, `npm install -g @controlplane/cli`. Then run `cpln login` to ensure access. |
| 18 | + |
| 19 | +4. Install [Heroku to Control Plane](https://github.com/shakacode/heroku-to-control-plane) playbook CLI [`cpl` gem](https://rubygems.org/gems/cpl) on your project's Gemfile or globally. |
6 | 20 |
|
7 |
| -2. Set up `organization` for testing in that account and modify org `.controlplane/controlplane.yml` . |
| 21 | +5. This project has a `Dockerfile` for Control Plane in this directory. You can use it as an example for your project. Ensure that you have Docker running. |
8 | 22 |
|
9 |
| -3. Install Control Plane CLI (and configure access) [docs here](https://docs.controlplane.com/quickstart/quick-start-3-cli#getting-started-with-the-cli). |
| 23 | +## Tips |
| 24 | +Do not confuse the `cpl` CLI with the `cpln` CLI. The `cpl` CLI is the Heroku to Control Plane playbook CLI. The `cpln` CLI is the Control Plane CLI. |
10 | 25 |
|
11 |
| -4. Install Heroku to Control Plane playbook from https://github.com/shakacode/heroku-to-control-plane. |
| 26 | +## Project Configuration |
| 27 | +See the filese in the `./controlplane` directory. |
12 | 28 |
|
13 |
| -5. This project has a `Dockerfile` for Control Plane in this directory. You can use it as an example for your project. |
| 29 | +1. `/templates`: defines the objects created with the `cpl setup` command. |
| 30 | +2. `/controlplane.yml`: defines the organization, location, and app name. |
| 31 | +3. `Dockerfile`: defines the Docker image used to run the app on Control Plane. |
| 32 | +4. `entrypoint.sh`: defines the entrypoint script used to run the app on Control Plane. |
14 | 33 |
|
15 | 34 | ## Setup and run
|
16 | 35 |
|
17 |
| -Check if the organization and location are correct in `.controlplane/controlplane.yml`. |
| 36 | +Check if the Control Plane organization and location are correct in `.controlplane/controlplane.yml`. You should be able to see this information in the Control Plane UI. |
18 | 37 |
|
19 | 38 | ```sh
|
20 | 39 | # Note, below commands use `cpl` which is the Heroku to Control Plane playbook script.
|
21 | 40 |
|
22 |
| -# Provision all infrastructure on Control Plane. It will use templates from .controlplane/templates folder. |
23 |
| -cpl setup gvc postgres redis rails -a ror-tutorial |
| 41 | +# Provision all infrastructure on Control Plane. |
| 42 | +# app tutorial-app will be created per definition in .controlplane/controlplane.yml |
| 43 | +cpl setup gvc postgres redis rails -a tutorial-app |
24 | 44 |
|
25 | 45 | # Build and push docker image to Control Plane repository
|
26 | 46 | # Note, may take many minutes. Be patient.
|
27 |
| -cpl build -a ror-tutorial |
| 47 | +cpl build-image -a tutorial-app |
28 | 48 |
|
29 |
| -# Promote image to app after running `cpl build command` |
30 |
| -cpl promote -a ror-tutorial |
| 49 | +# Promote image to app after running `cpl build-image command` |
| 50 | +cpl deploy-image -a tutorial-app |
31 | 51 |
|
32 | 52 | # See how app is starting up
|
33 |
| -cpl logs -a ror-tutorial |
| 53 | +cpl logs -a tutorial-app |
34 | 54 |
|
35 | 55 | # Open app in browser (once it has started up)
|
36 |
| -cpl open -a ror-tutorial |
| 56 | +cpl open -a tutorial-app |
37 | 57 | ```
|
38 | 58 |
|
39 | 59 | ## Promoting code upgrades
|
40 | 60 |
|
41 | 61 | ```sh
|
42 | 62 | # Build and push new image with sequential image tagging, e.g. 'ror-tutorial_123'
|
43 |
| -cpl build -a ror-tutorial |
| 63 | +cpl build-image -a tutorial-app |
44 | 64 |
|
45 | 65 | # OR
|
46 | 66 | # Build and push with sequential image tagging and commit SHA, e.g. 'ror-tutorial_123_ABCD'
|
47 |
| -cpl build -a ror-tutorial --commit ABCD |
| 67 | +cpl build-image -a tutorial-app --commit ABCD |
48 | 68 |
|
49 | 69 | # Run database migrations (or other release tasks) with latest image,
|
50 | 70 | # while app is still running on previous image.
|
51 | 71 | # This is analogous to the release phase.
|
52 |
| -cpl runner rails db:migrate -a ror-tutorial --image latest |
| 72 | +cpl runner rails db:migrate -a tutorial-app --image latest |
53 | 73 |
|
54 | 74 | # Pomote latest image to app
|
55 |
| -promote -a ror-tutorial |
| 75 | +cpl deploy-image -a tutorial-app |
56 | 76 | ```
|
57 | 77 |
|
58 | 78 | ## Other notes
|
|
0 commit comments