Skip to content

Update cpln deployment docs #562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions .controlplane/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,55 +50,60 @@ These YAML files are the same as used by the `cpln apply` command.
## Setup and run

Check if the Control Plane organization and location are correct in `.controlplane/controlplane.yml`.
Alternatively, you can use `CPLN_ORG` environment variable to set the organization name.
You should be able to see this information in the Control Plane UI.

**Note:** The below commands use `cpl` which is the Heroku to Control Plane playbook gem,
and not `cpln` which is the Control Plane CLI.

```sh
# Use environment variable to prevent repetition
export APP_NAME=tutorial-app

# Provision all infrastructure on Control Plane.
# app tutorial-app will be created per definition in .controlplane/controlplane.yml
cpl apply-template gvc postgres redis rails -a tutorial-app
cpl apply-template gvc postgres redis rails daily-task -a $APP_NAME

# Build and push docker image to Control Plane repository
# Note, may take many minutes. Be patient.
# Check for error messages, such as forgetting to run `cpln image docker-login --org <your-org>`
cpl build-image -a tutorial-app
cpl build-image -a $APP_NAME

# Promote image to app after running `cpl build-image command`
# Note, the UX of images may not show the image for up to 5 minutes.
# However, it's ready.
cpl deploy-image -a tutorial-app
cpl deploy-image -a $APP_NAME

# See how app is starting up
cpl logs -a tutorial-app
cpl logs -a $APP_NAME

# Open app in browser (once it has started up)
cpl open -a tutorial-app
cpl open -a $APP_NAME
```

### Promoting code updates

After committing code, you will update your deployment of `tutorial-app` with the following commands:

```sh
# Assuming you have already set APP_NAME env variable to tutorial-app
# Build and push new image with sequential image tagging, e.g. 'tutorial-app:1', then 'tutorial-app:2', etc.
cpl build-image -a tutorial-app
cpl build-image -a $APP_NAME

# Run database migrations (or other release tasks) with latest image,
# while app is still running on previous image.
# This is analogous to the release phase.
cpl runner rails db:migrate -a tutorial-app --image latest
cpl runner rails db:migrate -a $APP_NAME --image latest

# Pomote latest image to app after migrations run
cpl deploy-image -a tutorial-app
cpl deploy-image -a $APP_NAME
```

If you needed to push a new image with a specific commit SHA, you can run the following command:

```sh
# Build and push with sequential image tagging and commit SHA, e.g. 'tutorial-app:123_ABCD'
cpl build-image -a tutorial-app --commit ABCD
cpl build-image -a $APP_NAME --commit ABCD
```

## Other notes
Expand Down