Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2d9d32d

Browse files
ahangarhajustin808
authored andcommitted
Updates for ControlPlane deploy (#548)
1 parent d3eddb6 commit 2d9d32d

File tree

11 files changed

+311
-71
lines changed

11 files changed

+311
-71
lines changed

‎.controlplane/Dockerfile‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,18 @@ RUN bundle config set without 'development test' && \
1717
bundle install --jobs=3 --retry=3
1818

1919
# install node packages
20-
COPY package.json yarn.lock .
20+
COPY package.json yarn.lock ./
2121
RUN yarn install
2222

23-
# pick necessary app files
24-
COPY Gemfile* config.ru Rakefile babel.config.js ./
25-
COPY app ./app
26-
COPY bin ./bin
27-
COPY client ./client
28-
COPY config ./config
29-
COPY db ./db
30-
COPY lib ./lib
31-
COPY public ./public
23+
COPY . ./
3224

3325
ENV RAILS_ENV=production
3426
ENV NODE_ENV=production
3527

3628
# compiling assets requires any value for ENV of SECRET_KEY_BASE
3729
ENV SECRET_KEY_BASE=NOT_USED_NON_BLANK
3830

31+
RUN rails react_on_rails:locale
3932
RUN rails assets:precompile
4033

4134
# add entrypoint

‎.controlplane/controlplane.yml‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Configuration for "Heroku to CPLN playbook" custom scripts
22
aliases:
33
common: &common
4-
# Change this to your org name for staging. Production apps will use a different org
5-
# for security.
6-
cpln_org: shakacode-demo
7-
# Change `shakacode-staging` to your-org-name-for-staging
4+
# Org for staging and QA apps is typically set as an alias
5+
# Production apps will use a different org than staging for security.
6+
# Change this value to your org name
7+
# or set ENV value to CPLN_ORG as that will override whatever is used here for all cpl commands
8+
# cpln_org: shakacode-open-source-examples
9+
810
# Example apps use only location. CPLN offers the ability to use multiple locations.
911
default_location: aws-us-east-2
1012
# Configure the workload name used as a template for one-off scripts, like a Heroku one-off dyno.
@@ -13,10 +15,12 @@ aliases:
1315
# and the application image updates.
1416
app_workloads:
1517
- rails
18+
- daily-task
1619
# Like Heroku add-ons
1720
additional_workloads:
1821
- redis
1922
- postgres
23+
- daily-task
2024

2125
apps:
2226
react-webpack-rails-tutorial:

‎.controlplane/readme.md‎

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,63 @@ You can see the definition of Postgres and Redis in the `.controlplane/templates
1111
## Prerequisites
1212

1313
1. Ensure your [Control Plane](https://controlplane.com) account is set up.
14+
You should have an `organization` `<your-org>` for testing in that account.
15+
You will modify value for `aliases.common.cpln_org` in `.controlplane/controlplane.yml`.
16+
If you need an organization, please [contact Shakacode](mailto:controlplane@shakacode.com).
1417

15-
2. Set up an `organization` for testing in that account and modify `aliases.common.cpln_org` in `.controlplane/controlplane.yml`.
18+
2. Run `cpln image docker-login --org <your-org>` to ensure that you have access to the Control Plane Docker registry.
1619

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.
20+
3. Install Control Plane CLI (and configure access) using `npm install -g @controlplane/cli`.
21+
You can update the `cpln` command line with `npm update -g @controlplane/cli`.
22+
Then run `cpln login` to ensure access.
23+
For more informatation check out the
24+
[docs here](https://docs.controlplane.com/quickstart/quick-start-3-cli#getting-started-with-the-cli).
1825

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.
26+
4. Install the latest version of
27+
[`cpl` gem](https://rubygems.org/gems/cpl)
28+
on your project's Gemfile or globally.
29+
For more information check out
30+
[Heroku to Control Plane](https://github.com/shakacode/heroku-to-control-plane).
2031

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.
32+
5. This project has a `Dockerfile` for Control Plane in `.controlplane` directory.
33+
You can use it as an example for your project.
34+
Ensure that you have Docker running.
2235

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.
36+
### Tips
37+
Do not confuse the `cpl` CLI with the `cpln` CLI.
38+
The `cpl` CLI is the Heroku to Control Plane playbook CLI.
39+
The `cpln` CLI is the Control Plane CLI.
2540

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

2944
1. `/templates`: defines the objects created with the `cpl setup` command.
30-
2. `/controlplane.yml`: defines the organization, location, and app name.
45+
These YAML files are the same as used by the `cpln apply` command.
46+
2. `/controlplane.yml`: defines your application, including the organization, location, and app name.
3147
3. `Dockerfile`: defines the Docker image used to run the app on Control Plane.
3248
4. `entrypoint.sh`: defines the entrypoint script used to run the app on Control Plane.
3349

3450
## Setup and run
3551

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.
52+
Check if the Control Plane organization and location are correct in `.controlplane/controlplane.yml`.
53+
You should be able to see this information in the Control Plane UI.
3754

38-
```sh
39-
# Note, below commands use `cpl` which is the Heroku to Control Plane playbook script.
55+
**Note:** The below commands use `cpl` which is the Heroku to Control Plane playbook gem,
56+
and not `cpln` which is the Control Plane CLI.
4057

58+
```sh
4159
# Provision all infrastructure on Control Plane.
4260
# app tutorial-app will be created per definition in .controlplane/controlplane.yml
43-
cpl setup gvc postgres redis rails -a tutorial-app
61+
cpl apply-template gvc postgres redis rails -a tutorial-app
4462

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

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

5273
# See how app is starting up
@@ -56,25 +77,30 @@ cpl logs -a tutorial-app
5677
cpl open -a tutorial-app
5778
```
5879

59-
## Promoting code upgrades
80+
### Promoting code updates
81+
82+
After committing code, you will update your deployment of `tutorial-app` with the following commands:
6083

6184
```sh
62-
# Build and push new image with sequential image tagging, e.g. 'ror-tutorial_123'
85+
# Build and push new image with sequential image tagging, e.g. 'tutorial-app:1', then 'tutorial-app:2', etc.
6386
cpl build-image -a tutorial-app
6487

65-
# OR
66-
# Build and push with sequential image tagging and commit SHA, e.g. 'ror-tutorial_123_ABCD'
67-
cpl build-image -a tutorial-app --commit ABCD
68-
6988
# Run database migrations (or other release tasks) with latest image,
7089
# while app is still running on previous image.
7190
# This is analogous to the release phase.
7291
cpl runner rails db:migrate -a tutorial-app --image latest
7392

74-
# Pomote latest image to app
93+
# Pomote latest image to app after migrations run
7594
cpl deploy-image -a tutorial-app
7695
```
7796

97+
If you needed to push a new image with a specific commit SHA, you can run the following command:
98+
99+
```sh
100+
# Build and push with sequential image tagging and commit SHA, e.g. 'tutorial-app:123_ABCD'
101+
cpl build-image -a tutorial-app --commit ABCD
102+
```
103+
78104
## Other notes
79105

80106
### `entrypoint.sh`
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
kind: workload
2+
name: daily-task
3+
spec:
4+
# https://docs.controlplane.com/reference/workload#cron-configuration
5+
type: cron
6+
job:
7+
activeDeadlineSeconds: 3600
8+
concurrencyPolicy: Forbid
9+
historyLimit: 5
10+
restartPolicy: Never
11+
# daily. See cron docs
12+
schedule: 0 0 * * *
13+
containers:
14+
- name: daily-task
15+
cpu: 50m
16+
memory: 256Mi
17+
args:
18+
- bundle
19+
- exec
20+
- rake
21+
- daily
22+
inheritEnv: true
23+
image: "/org/APP_ORG/image/APP_IMAGE"
24+
defaultOptions:
25+
autoscaling:
26+
minScale: 1
27+
maxScale: 1
28+
capacityAI: false
29+
firewallConfig:
30+
external:
31+
outboundAllowCIDR:
32+
- 0.0.0.0/0
33+
identityLink: /org/APP_ORG/gvc/APP_GVC/identity/postgres-poc-identity

‎.controlplane/templates/gvc.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ spec:
99
# Password does not matter because host postgres.APP_GVC.cpln.local can only be accessed
1010
# locally within CPLN GVC, and postgres running on a CPLN workload is something only for a
1111
# test app that lacks persistence.
12-
value: 'postgres://postgres:password123@postgres.APP_GVC.cpln.local:5432/APP_GVC'
12+
value: 'postgres://the_user:the_password@postgres.APP_GVC.cpln.local:5432/APP_GVC'
1313
- name: RAILS_ENV
1414
value: production
1515
- name: NODE_ENV

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /