Skip to content
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

Rename cpl to cpflow #595

Merged
merged 2 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions .controlplane/controlplane.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Configuration for `cpl` commands.
# Configuration for `cpflow` commands.

# Keys beginning with "cpln_" correspond to your settings in Control Plane.

# Global settings that apply to `cpl` usage.
# Global settings that apply to `cpflow` usage.
# You can opt out of allowing the use of CPLN_ORG and CPLN_APP env vars
# to avoid any accidents with the wrong org / app.
allow_org_override_by_env: true
Expand All @@ -13,7 +13,7 @@ aliases:
# Org for staging and QA apps is typically set as an alias, shared by all apps, except for production apps.
# Production apps will use a different org than staging for security.
# Change this value to your org name
# or set ENV CPLN_ORG to your org name as that will override whatever is used here for all cpl commands
# or set ENV CPLN_ORG to your org name as that will override whatever is used here for all cpflow commands
# cpln_org: shakacode-open-source-examples

# Example apps use only location. CPLN offers the ability to use multiple locations.
Expand Down Expand Up @@ -53,7 +53,7 @@ apps:
<<: *common
# QA Apps are like Heroku review apps, but the use `prefix` so you can run a commmand like
# this to create a QA app for the tutorial app.
# `cpl setup gvc postgres redis rails -a qa-react-webpack-rails-tutorial-pr-1234`
# `cpflow setup gvc postgres redis rails -a qa-react-webpack-rails-tutorial-pr-1234`
qa-react-webpack-rails-tutorial:
<<: *common
# Prefix is used to identify these "qa" apps.
Expand Down
34 changes: 17 additions & 17 deletions .controlplane/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ _If you need a free demo account for Control Plane (no CC required), you can con

---

Check [how the `cpl` gem (this project) is used in the Github actions](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/.github/actions/deploy-to-control-plane/action.yml).
Check [how the `cpflow` gem (this project) is used in the Github actions](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/.github/actions/deploy-to-control-plane/action.yml).
Here is a brief [video overview](https://www.youtube.com/watch?v=llaQoAV_6Iw).

---

## Overview
This simple example shows how to deploy a simple app on Control Plane using the `cpl` gem.
This simple example shows how to deploy a simple app on Control Plane using the `cpflow` gem.

To maximize simplicity, this example creates Postgres and Redis as workloads in the same GVC as the app.
In a real app, you would likely use persistent, external resources, such as AWS RDS and AWS ElastiCache.
Expand All @@ -36,7 +36,7 @@ For more informatation check out the
3. Run `cpln image docker-login --org <your-org>` to ensure that you have access to the Control Plane Docker registry.

4. Install the latest version of
[`cpl` gem](https://rubygems.org/gems/cpl)
[`cpflow` gem](https://rubygems.org/gems/cpflow)
on your project's Gemfile or globally.
For more information check out
[Heroku to Control Plane](https://github.com/shakacode/heroku-to-control-plane).
Expand All @@ -46,14 +46,14 @@ You can use it as an example for your project.
Ensure that you have Docker running.

### Tips
Do not confuse the `cpl` CLI with the `cpln` CLI.
The `cpl` CLI is the Heroku to Control Plane playbook CLI.
Do not confuse the `cpflow` CLI with the `cpln` CLI.
The `cpflow` CLI is the Heroku to Control Plane playbook CLI.
The `cpln` CLI is the Control Plane CLI.

## Project Configuration
See the filese in the `./controlplane` directory.

1. `/templates`: defines the objects created with the `cpl setup` command.
1. `/templates`: defines the objects created with the `cpflow setup` command.
These YAML files are the same as used by the `cpln apply` command.
2. `/controlplane.yml`: defines your application, including the organization, location, and app name.
3. `Dockerfile`: defines the Docker image used to run the app on Control Plane.
Expand All @@ -65,7 +65,7 @@ Check if the Control Plane organization and location are correct in `.controlpla
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,
**Note:** The below commands use `cpflow` which is the Heroku to Control Plane playbook gem,
and not `cpln` which is the Control Plane CLI.

```sh
Expand All @@ -74,23 +74,23 @@ export APP_NAME=react-webpack-rails-tutorial

# Provision all infrastructure on Control Plane.
# app react-webpack-rails-tutorial will be created per definition in .controlplane/controlplane.yml
cpl apply-template gvc postgres redis rails daily-task -a $APP_NAME
cpflow 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 $APP_NAME
cpflow build-image -a $APP_NAME

# Promote image to app after running `cpl build-image command`
# Promote image to app after running `cpflow 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 $APP_NAME
cpflow deploy-image -a $APP_NAME

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

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

### Promoting code updates
Expand All @@ -100,22 +100,22 @@ After committing code, you will update your deployment of `react-webpack-rails-t
```sh
# Assuming you have already set APP_NAME env variable to react-webpack-rails-tutorial
# Build and push new image with sequential image tagging, e.g. 'react-webpack-rails-tutorial:1', then 'react-webpack-rails-tutorial:2', etc.
cpl build-image -a $APP_NAME
cpflow 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 $APP_NAME --image latest
cpflow run -a $APP_NAME --image latest -- rails db:migrate
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated according to the gem documentation.


# Pomote latest image to app after migrations run
cpl deploy-image -a $APP_NAME
cpflow 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. 'react-webpack-rails-tutorial:123_ABCD'
cpl build-image -a $APP_NAME --commit ABCD
cpflow build-image -a $APP_NAME --commit ABCD
```

## Other notes
Expand Down
12 changes: 6 additions & 6 deletions .github/actions/deploy-to-control-plane/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ runs:
run: |
sudo npm install -g @controlplane/cli
cpln --version
gem install cpl -v 1.2.0
gem install cpflow -v 3.0.1

- name: Set Short SHA
id: vars
shell: bash
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"

- name: cpl profile
- name: cpflow profile
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename step to cpflow profile.

The step name has been correctly updated to cpflow profile. However, the command inside the step still uses cpln. This needs to be updated to cpflow.

Update the command to use the new CLI:

- cpln profile update default
+ cpflow profile update default

Committable suggestion was skipped due to low confidence.

shell: bash
run: |
cpln profile update default
Expand All @@ -49,11 +49,11 @@ runs:
${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile', '**/package.json', '**/yarn.lock') }}
${{ runner.os }}-docker-

- name: cpl build-image
- name: cpflow build-image
shell: bash
run: |
cpln image docker-login
cpl build-image -a ${{ inputs.app_name }} --commit ${{steps.vars.outputs.sha_short}} --org ${{inputs.org}}
cpflow build-image -a ${{ inputs.app_name }} --commit ${{steps.vars.outputs.sha_short}} --org ${{inputs.org}}
# --cache /tmp/.docker-cache

- name: Run release script
Expand All @@ -62,9 +62,9 @@ runs:
# Run database migrations (or other release tasks) with the latest image,
# while the app is still running on the previous image.
# This is analogous to the release phase.
cpl run:detached './.controlplane/release_script.sh' -a ${{ inputs.app_name }} --image latest
justin808 marked this conversation as resolved.
Show resolved Hide resolved
cpflow run './.controlplane/release_script.sh' -a ${{ inputs.app_name }} --image latest

- name: Deploy to Control Plane
shell: bash
run: |
cpl deploy-image -a ${{ inputs.app_name }} --org ${{inputs.org}}
cpflow deploy-image -a ${{ inputs.app_name }} --org ${{inputs.org}}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

## Control Plane Deployment Example

[Control Plane](https://shakacode.controlplane.com) offers a viable, cost-saving alternative to Heroku, especially when using the [cpl gem](https://rubygems.org/gems/cpl) to deploy to Control Plane.
[Control Plane](https://shakacode.controlplane.com) offers a viable, cost-saving alternative to Heroku, especially when using the [cpflow gem](https://rubygems.org/gems/cpflow) to deploy to Control Plane.

ShakaCode recently migrated [HiChee.com](https://hichee.com) to Control Plane, resulting in a two-thirds reduction in server hosting costs!

See doc in [./.controlplane/readme.md](./.controlplane/readme.md) for how to easily deploy this app to Control Plane.

The instructions leverage the `cpl` CLI, with source code and many more tips on how to migrate from Heroku to Control Plane
The instructions leverage the `cpflow` CLI, with source code and many more tips on how to migrate from Heroku to Control Plane
in https://github.com/shakacode/heroku-to-control-plane.

----
Expand Down
Loading