From 3336b2c20359c1755bdd1e0848b85235f9d80b5d Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Mon, 15 Jan 2024 17:28:36 -1000 Subject: [PATCH 01/22] WIP --- .../app/bundles/comments/rescript/CommentForm/CommentForm.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/app/bundles/comments/rescript/CommentForm/CommentForm.res b/client/app/bundles/comments/rescript/CommentForm/CommentForm.res index db964269..c075452d 100644 --- a/client/app/bundles/comments/rescript/CommentForm/CommentForm.res +++ b/client/app/bundles/comments/rescript/CommentForm/CommentForm.res @@ -90,7 +90,7 @@ let make = (~fetchData) => { } let forms: array = [ - {formName: "Horizontal Form", formType: Horizontal}, + {formName: "Horizontal Form XXXX", formType: Horizontal}, {formName: "Inline Form", formType: Inline}, {formName: "Stacked Form", formType: Stacked}, ] From 203b307cfa629f1d9eadbcecf2b85b55551ed3c9 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Mon, 15 Jan 2024 22:29:33 -1000 Subject: [PATCH 02/22] WIP --- .../deploy-to-control-plane-review.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-to-control-plane-review.yml b/.github/workflows/deploy-to-control-plane-review.yml index ad6516f3..5e80dfd6 100644 --- a/.github/workflows/deploy-to-control-plane-review.yml +++ b/.github/workflows/deploy-to-control-plane-review.yml @@ -6,6 +6,14 @@ name: Deploy Review App to Control Plane on: # Allows you to run this workflow manually from the Actions tab workflow_dispatch: +# inputs: +# pr_number: +# description: 'Pull request number' +# required: false +# Triggers the workflow on pull request events +# pull_request: +# branches: +# - main # or the branch you want to trigger the workflow # Convert the GitHub secret variables to environment variables for use by the Control Plane CLI env: @@ -20,7 +28,16 @@ jobs: - name: Check out the repo uses: actions/checkout@v2 + - name: Extract PR number from branch name + run: | + PR_NUMBER=$(echo ${GITHUB_REF#refs/heads/pr-}) + if [ -z "$PR_NUMBER" ]; then + echo "PR_NUMBER is not set. Aborting." + exit 1 + fi + echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV + - uses: ./.github/actions/deploy-to-control-plane with: - app_name: qa-react-webpack-rails-tutorial-pr-${{ github.event.pull_request.number }} + app_name: qa-react-webpack-rails-tutorial-pr-${{ env.PR_NUMBER }} org: ${{ secrets.CPLN_ORG_STAGING }} From bbb994d27a1099e854f9c1ce4e66563bea1692fd Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Mon, 15 Jan 2024 22:38:26 -1000 Subject: [PATCH 03/22] WIP --- .github/workflows/deploy-to-control-plane-review.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-to-control-plane-review.yml b/.github/workflows/deploy-to-control-plane-review.yml index 5e80dfd6..c3d6446d 100644 --- a/.github/workflows/deploy-to-control-plane-review.yml +++ b/.github/workflows/deploy-to-control-plane-review.yml @@ -28,9 +28,11 @@ jobs: - name: Check out the repo uses: actions/checkout@v2 - - name: Extract PR number from branch name + - name: Get PR number run: | - PR_NUMBER=$(echo ${GITHUB_REF#refs/heads/pr-}) + PR_NUMBER=$(curl --location --request GET 'https://api.github.com/repos/$GITHUB_REPOSITORY/pulls?state=open' \ + --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ + | jq '.[] | select(.head.ref=="'${{ github.ref }}'") | .number') if [ -z "$PR_NUMBER" ]; then echo "PR_NUMBER is not set. Aborting." exit 1 From a94c8a2e7c3fcc49aa2805e58dd7ddd852d4c661 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Mon, 15 Jan 2024 22:57:44 -1000 Subject: [PATCH 04/22] WIP --- .github/workflows/deploy-to-control-plane-review.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy-to-control-plane-review.yml b/.github/workflows/deploy-to-control-plane-review.yml index c3d6446d..1adb3137 100644 --- a/.github/workflows/deploy-to-control-plane-review.yml +++ b/.github/workflows/deploy-to-control-plane-review.yml @@ -28,11 +28,13 @@ jobs: - name: Check out the repo uses: actions/checkout@v2 + - name: Get PR number run: | - PR_NUMBER=$(curl --location --request GET 'https://api.github.com/repos/$GITHUB_REPOSITORY/pulls?state=open' \ - --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ - | jq '.[] | select(.head.ref=="'${{ github.ref }}'") | .number') + API_RESPONSE=$(curl --location --request GET 'https://api.github.com/repos/$GITHUB_REPOSITORY/pulls?state=open' \ + --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}') + echo "API_RESPONSE: $API_RESPONSE" + PR_NUMBER=$(echo $API_RESPONSE | jq '.[] | select(.head.ref=="'${{ github.ref }}'") | .number') if [ -z "$PR_NUMBER" ]; then echo "PR_NUMBER is not set. Aborting." exit 1 From f1b9767638a48f7cb78865a28df0f26ff86cdbdc Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Mon, 15 Jan 2024 23:35:28 -1000 Subject: [PATCH 05/22] WIP --- .github/workflows/deploy-to-control-plane-review.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy-to-control-plane-review.yml b/.github/workflows/deploy-to-control-plane-review.yml index 1adb3137..6f70c7e9 100644 --- a/.github/workflows/deploy-to-control-plane-review.yml +++ b/.github/workflows/deploy-to-control-plane-review.yml @@ -31,6 +31,7 @@ jobs: - name: Get PR number run: | + echo "GITHUB_REPOSITORY: '$GITHUB_REPOSITORY'" API_RESPONSE=$(curl --location --request GET 'https://api.github.com/repos/$GITHUB_REPOSITORY/pulls?state=open' \ --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}') echo "API_RESPONSE: $API_RESPONSE" From c9651881f9222b10e4ee555be9cc30624f39d52a Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Mon, 15 Jan 2024 23:38:36 -1000 Subject: [PATCH 06/22] WIP --- .github/workflows/deploy-to-control-plane-review.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy-to-control-plane-review.yml b/.github/workflows/deploy-to-control-plane-review.yml index 6f70c7e9..47250221 100644 --- a/.github/workflows/deploy-to-control-plane-review.yml +++ b/.github/workflows/deploy-to-control-plane-review.yml @@ -28,14 +28,14 @@ jobs: - name: Check out the repo uses: actions/checkout@v2 - - name: Get PR number run: | - echo "GITHUB_REPOSITORY: '$GITHUB_REPOSITORY'" - API_RESPONSE=$(curl --location --request GET 'https://api.github.com/repos/$GITHUB_REPOSITORY/pulls?state=open' \ + echo "GITHUB_REPOSITORY: \"$GITHUB_REPOSITORY\"" + API_RESPONSE=$(curl --location --request GET "https://api.github.com/repos/$GITHUB_REPOSITORY/pulls?state=open" \ --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}') echo "API_RESPONSE: $API_RESPONSE" PR_NUMBER=$(echo $API_RESPONSE | jq '.[] | select(.head.ref=="'${{ github.ref }}'") | .number') + echo "PR_NUMBER: $PR_NUMBER" if [ -z "$PR_NUMBER" ]; then echo "PR_NUMBER is not set. Aborting." exit 1 From 1c6d90b35a8c0dd8d741f660c163018a29f2d60e Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Mon, 15 Jan 2024 23:48:12 -1000 Subject: [PATCH 07/22] WIP --- .github/workflows/deploy-to-control-plane-review.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy-to-control-plane-review.yml b/.github/workflows/deploy-to-control-plane-review.yml index 47250221..e27b819a 100644 --- a/.github/workflows/deploy-to-control-plane-review.yml +++ b/.github/workflows/deploy-to-control-plane-review.yml @@ -31,6 +31,7 @@ jobs: - name: Get PR number run: | echo "GITHUB_REPOSITORY: \"$GITHUB_REPOSITORY\"" + echo "github.ref: \"$GITHUB_REF\"" API_RESPONSE=$(curl --location --request GET "https://api.github.com/repos/$GITHUB_REPOSITORY/pulls?state=open" \ --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}') echo "API_RESPONSE: $API_RESPONSE" From e043485bf9c0b99de5063bb31ed3f8cd0c30fa66 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Mon, 15 Jan 2024 23:55:29 -1000 Subject: [PATCH 08/22] WIP --- .github/workflows/deploy-to-control-plane-review.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-to-control-plane-review.yml b/.github/workflows/deploy-to-control-plane-review.yml index e27b819a..ce841490 100644 --- a/.github/workflows/deploy-to-control-plane-review.yml +++ b/.github/workflows/deploy-to-control-plane-review.yml @@ -31,11 +31,13 @@ jobs: - name: Get PR number run: | echo "GITHUB_REPOSITORY: \"$GITHUB_REPOSITORY\"" - echo "github.ref: \"$GITHUB_REF\"" + REF=${{ github.ref }} + REF=${REF#refs/heads/} # Remove 'refs/heads/' prefix + echo "REF: \"$REF\"" API_RESPONSE=$(curl --location --request GET "https://api.github.com/repos/$GITHUB_REPOSITORY/pulls?state=open" \ --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}') echo "API_RESPONSE: $API_RESPONSE" - PR_NUMBER=$(echo $API_RESPONSE | jq '.[] | select(.head.ref=="'${{ github.ref }}'") | .number') + PR_NUMBER=$(echo $API_RESPONSE | jq '.[] | select(.head.ref=="'$REF'") | .number') echo "PR_NUMBER: $PR_NUMBER" if [ -z "$PR_NUMBER" ]; then echo "PR_NUMBER is not set. Aborting." From ca100474ddc5b5dc9e127829323ae1e8253ccb81 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Sun, 21 Jan 2024 21:40:54 -1000 Subject: [PATCH 09/22] =?UTF-8?q?provision=20the=20app=CB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .controlplane/readme.md | 2 +- .github/actions/deploy-to-control-plane/action.yml | 10 +++++++++- .github/workflows/deploy-to-control-plane-review.yml | 7 ++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.controlplane/readme.md b/.controlplane/readme.md index c8aacfbd..a309bf6a 100644 --- a/.controlplane/readme.md +++ b/.controlplane/readme.md @@ -63,7 +63,7 @@ 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 +cpl setup-app -a $APP_NAME # Build and push docker image to Control Plane repository # Note, may take many minutes. Be patient. diff --git a/.github/actions/deploy-to-control-plane/action.yml b/.github/actions/deploy-to-control-plane/action.yml index 64a4336c..dc7c91dc 100644 --- a/.github/actions/deploy-to-control-plane/action.yml +++ b/.github/actions/deploy-to-control-plane/action.yml @@ -38,7 +38,6 @@ runs: shell: bash run: | cpln profile update default - # cpln profile update default --token ${CPLN_TOKEN} # Caching step - uses: actions/cache@v2 @@ -49,6 +48,15 @@ runs: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile', '**/package.json', '**/yarn.lock') }} ${{ runner.os }}-docker- + - name: cpl setup-app + shell: bash + run: | + if ! cpl exists -a ${{ inputs.app_name }} ; then + cpl setup-app -a ${{ inputs.app_name }} + fi + # Provision all infrastructure on Control Plane. + # app react-webpack-rails-tutorial will be created per definition in .controlplane/controlplane.yml + - name: cpl build-image shell: bash run: | diff --git a/.github/workflows/deploy-to-control-plane-review.yml b/.github/workflows/deploy-to-control-plane-review.yml index ce841490..54dfa2bc 100644 --- a/.github/workflows/deploy-to-control-plane-review.yml +++ b/.github/workflows/deploy-to-control-plane-review.yml @@ -45,7 +45,12 @@ jobs: fi echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV + - name: Get App Name + run: | + echo "APP_NAME=qa-react-webpack-rails-tutorial-pr-${{ env.PR_NUMBER }}" >> $GITHUB_ENV + echo "App Name: ${{ env.APP_NAME }}" + - uses: ./.github/actions/deploy-to-control-plane with: - app_name: qa-react-webpack-rails-tutorial-pr-${{ env.PR_NUMBER }} + app_name: ${{ env.APP_NAME }} org: ${{ secrets.CPLN_ORG_STAGING }} From 0021add5564672afd8069674c1d2848d4a558be6 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Sun, 21 Jan 2024 22:06:30 -1000 Subject: [PATCH 10/22] WIP --- .github/workflows/deploy-to-control-plane-review.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy-to-control-plane-review.yml b/.github/workflows/deploy-to-control-plane-review.yml index 54dfa2bc..7877566a 100644 --- a/.github/workflows/deploy-to-control-plane-review.yml +++ b/.github/workflows/deploy-to-control-plane-review.yml @@ -47,6 +47,7 @@ jobs: - name: Get App Name run: | + echo "PR_NUMBER: ${{ env.PR_NUMBER }}" echo "APP_NAME=qa-react-webpack-rails-tutorial-pr-${{ env.PR_NUMBER }}" >> $GITHUB_ENV echo "App Name: ${{ env.APP_NAME }}" From 0a905bd5a19a90ba094f5dfe93c0262b0bb81370 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Sun, 21 Jan 2024 22:11:42 -1000 Subject: [PATCH 11/22] WIP --- .controlplane/controlplane.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.controlplane/controlplane.yml b/.controlplane/controlplane.yml index f8f3a809..4037357a 100644 --- a/.controlplane/controlplane.yml +++ b/.controlplane/controlplane.yml @@ -56,5 +56,11 @@ apps: # `cpl setup gvc postgres redis rails -a qa-react-webpack-rails-tutorial-pr-1234` qa-react-webpack-rails-tutorial: <<: *common + setup_app_templates: + - daily-task + - postgres + - gvc + - redis + - rails # Prefix is used to identify these "qa" apps. prefix: true From 79ad9d581c8d7de9c5b4b3ef4d8d1b3d02e65cdf Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Fri, 22 Mar 2024 19:27:34 -1000 Subject: [PATCH 12/22] Updates for deployment --- .controlplane/templates/daily-task.yml | 3 +-- .controlplane/templates/gvc.yml | 10 ++++----- .controlplane/templates/postgres.yml | 5 +---- .controlplane/templates/rails.yml | 2 +- .../deploy-to-control-plane/action.yml | 21 +++++-------------- 5 files changed, 13 insertions(+), 28 deletions(-) diff --git a/.controlplane/templates/daily-task.yml b/.controlplane/templates/daily-task.yml index 9fdd8fa4..1137801d 100644 --- a/.controlplane/templates/daily-task.yml +++ b/.controlplane/templates/daily-task.yml @@ -20,7 +20,7 @@ spec: - rake - daily inheritEnv: true - image: "/org/APP_ORG/image/APP_IMAGE" + image: {{APP_IMAGE_LINK}} defaultOptions: autoscaling: minScale: 1 @@ -30,4 +30,3 @@ spec: external: outboundAllowCIDR: - 0.0.0.0/0 - identityLink: /org/APP_ORG/gvc/APP_GVC/identity/postgres-poc-identity diff --git a/.controlplane/templates/gvc.yml b/.controlplane/templates/gvc.yml index 93028630..86abdb61 100644 --- a/.controlplane/templates/gvc.yml +++ b/.controlplane/templates/gvc.yml @@ -1,15 +1,15 @@ # Template setup of the GVC, roughly corresponding to a Heroku app kind: gvc -name: APP_GVC +name: {{APP_NAME}} spec: # For using templates for test apps, put ENV values here, stored in git repo. # Production apps will have values configured manually after app creation. env: - name: DATABASE_URL - # Password does not matter because host postgres.APP_GVC.cpln.local can only be accessed + # Password does not matter because host postgres.{{APP_NAME}}.cpln.local can only be accessed # locally within CPLN GVC, and postgres running on a CPLN workload is something only for a # test app that lacks persistence. - value: 'postgres://the_user:the_password@postgres.APP_GVC.cpln.local:5432/APP_GVC' + value: 'postgres://the_user:the_password@postgres.{{APP_NAME}}.cpln.local:5432/{{APP_NAME}}' - name: RAILS_ENV value: production - name: NODE_ENV @@ -18,8 +18,8 @@ spec: value: 'true' - name: REDIS_URL # No password for GVC local Redis. See comment above for postgres. - value: 'redis://redis.APP_GVC.cpln.local:6379' + value: 'redis://redis.{{APP_NAME}}.cpln.local:6379' # Part of standard configuration staticPlacement: locationLinks: - - /org/APP_ORG/location/APP_LOCATION + - {{APP_LOCATION_LINK}} diff --git a/.controlplane/templates/postgres.yml b/.controlplane/templates/postgres.yml index 7291e37d..77e3497b 100644 --- a/.controlplane/templates/postgres.yml +++ b/.controlplane/templates/postgres.yml @@ -106,7 +106,7 @@ bindings: # - use # - view principalLinks: - - //gvc/APP_GVC/identity/postgres-poc-identity + - //gvc/{{APP_NAME}}/identity/postgres-poc-identity targetKind: secret targetLinks: - //secret/postgres-poc-credentials @@ -139,9 +139,6 @@ spec: args: - "-c" - "cat /usr/local/bin/cpln-entrypoint.sh >> ./cpln-entrypoint.sh && chmod u+x ./cpln-entrypoint.sh && ./cpln-entrypoint.sh postgres" - #command: "cpln-entrypoint.sh" - #args: - # - "postgres" ports: - number: 5432 protocol: tcp diff --git a/.controlplane/templates/rails.yml b/.controlplane/templates/rails.yml index 728b5a12..e559b8fe 100644 --- a/.controlplane/templates/rails.yml +++ b/.controlplane/templates/rails.yml @@ -14,7 +14,7 @@ spec: value: debug # Inherit other ENV values from GVC inheritEnv: true - image: '/org/APP_ORG/image/APP_IMAGE' + image: {{APP_IMAGE_LINK}} # 512 corresponds to a standard 1x dyno type memory: 512Mi ports: diff --git a/.github/actions/deploy-to-control-plane/action.yml b/.github/actions/deploy-to-control-plane/action.yml index dc7c91dc..c1b33f35 100644 --- a/.github/actions/deploy-to-control-plane/action.yml +++ b/.github/actions/deploy-to-control-plane/action.yml @@ -4,7 +4,6 @@ name: Deploy-To-Control-Plane description: 'Deploys both to staging and to review apps' inputs: - # The name of the app to deploy app_name: description: 'The name of the app to deploy' required: true @@ -27,8 +26,8 @@ runs: run: | sudo npm install -g @controlplane/cli cpln --version - gem install cpl -v 1.2.0 - + gem install cpl + cpl --version - name: Set Short SHA id: vars shell: bash @@ -56,23 +55,13 @@ runs: fi # Provision all infrastructure on Control Plane. # app react-webpack-rails-tutorial will be created per definition in .controlplane/controlplane.yml - - name: cpl 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}} - # --cache /tmp/.docker-cache - - - name: Run release script - shell: bash - run: | - # 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 - + BUILDKIT_PROGRESS=plain cpl build-image -a ${{ inputs.app_name }} --commit ${{steps.vars.outputs.sha_short}} --org ${{inputs.org}} + # --cache /tmp/.docker-cache - name: Deploy to Control Plane shell: bash run: | - cpl deploy-image -a ${{ inputs.app_name }} --org ${{inputs.org}} + cpl deploy-image -a ${{ inputs.app_name }} --run-release-phase --org ${{inputs.org}} From 34c16b61181ada281ab071bfd5ab3f25b68cae68 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Fri, 22 Mar 2024 19:38:15 -1000 Subject: [PATCH 13/22] Updates for deployment --- .controlplane/controlplane.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.controlplane/controlplane.yml b/.controlplane/controlplane.yml index 4037357a..52874f5a 100644 --- a/.controlplane/controlplane.yml +++ b/.controlplane/controlplane.yml @@ -34,6 +34,9 @@ aliases: # Configure the workload name used when maintenance mode is on (defaults to "maintenance"). maintenance_workload: maintenance + # Configure the script to run when releasing an app., either with deploy-image or promote-app-from-upstream + release_script: release_script.sh + apps: react-webpack-rails-tutorial: # Simulate Production Version @@ -47,7 +50,6 @@ apps: upstream: react-webpack-rails-tutorial-staging - release_script: release_script.sh react-webpack-rails-tutorial-staging: <<: *common From c5d3afb3cf1f4b3aa8a3032749e1c8e28f23e084 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Fri, 22 Mar 2024 19:59:09 -1000 Subject: [PATCH 14/22] Updates for deployment --- .controlplane/Dockerfile | 6 +++++- .github/actions/deploy-to-control-plane/action.yml | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.controlplane/Dockerfile b/.controlplane/Dockerfile index 20f3260a..f225747c 100644 --- a/.controlplane/Dockerfile +++ b/.controlplane/Dockerfile @@ -63,9 +63,13 @@ ENV RAILS_ENV=production \ RUN yarn res:build RUN bin/rails react_on_rails:locale -RUN bin/rails assets:precompile +# Precompile assets and remove build dependencies +# Note, if you have some Node.js programs, you need to install those in a different +# directory so you don't delete them here. +RUN bin/rails assets:precompile && rm -rf lib/bs && rm -rf node_modules + ENTRYPOINT ["./.controlplane/entrypoint.sh"] CMD ["./bin/rails", "server"] diff --git a/.github/actions/deploy-to-control-plane/action.yml b/.github/actions/deploy-to-control-plane/action.yml index c1b33f35..827a5234 100644 --- a/.github/actions/deploy-to-control-plane/action.yml +++ b/.github/actions/deploy-to-control-plane/action.yml @@ -59,7 +59,9 @@ runs: shell: bash run: | cpln image docker-login - BUILDKIT_PROGRESS=plain cpl build-image -a ${{ inputs.app_name }} --commit ${{steps.vars.outputs.sha_short}} --org ${{inputs.org}} + # Use BUILDKIT_PROGRESS=plain to get more verbose logging of the build + # BUILDKIT_PROGRESS=plain cpl build-image -a ${{ inputs.app_name }} --commit ${{steps.vars.outputs.sha_short}} --org ${{inputs.org}} + cpl build-image -a ${{ inputs.app_name }} --commit ${{steps.vars.outputs.sha_short}} --org ${{inputs.org}} # --cache /tmp/.docker-cache - name: Deploy to Control Plane shell: bash From 80f4707f6cdd26fd5695ef1893d3273ad66b2fc2 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Fri, 22 Mar 2024 20:13:46 -1000 Subject: [PATCH 15/22] Updates for deployment --- .controlplane/Dockerfile | 2 +- .github/actions/deploy-to-control-plane/action.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.controlplane/Dockerfile b/.controlplane/Dockerfile index f225747c..10805270 100644 --- a/.controlplane/Dockerfile +++ b/.controlplane/Dockerfile @@ -1,4 +1,4 @@ -# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile +# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile and actions.yml ARG RUBY_VERSION=3.1.2 FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base diff --git a/.github/actions/deploy-to-control-plane/action.yml b/.github/actions/deploy-to-control-plane/action.yml index 827a5234..f32202d5 100644 --- a/.github/actions/deploy-to-control-plane/action.yml +++ b/.github/actions/deploy-to-control-plane/action.yml @@ -19,7 +19,7 @@ runs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: '3.2' # Specify your Ruby version here + ruby-version: '3.1.2' # Specify your Ruby version here - name: Install Control Plane CLI shell: bash From 25d058f1dbbea432e968869fed08f3514ece59fa Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Fri, 22 Mar 2024 20:30:58 -1000 Subject: [PATCH 16/22] Updates for deployment --- .controlplane/controlplane.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.controlplane/controlplane.yml b/.controlplane/controlplane.yml index 52874f5a..692eb0f7 100644 --- a/.controlplane/controlplane.yml +++ b/.controlplane/controlplane.yml @@ -58,11 +58,12 @@ apps: # `cpl setup gvc postgres redis rails -a qa-react-webpack-rails-tutorial-pr-1234` qa-react-webpack-rails-tutorial: <<: *common + # Order matters! setup_app_templates: - - daily-task - - postgres - gvc + - postgres - redis + - daily-task - rails # Prefix is used to identify these "qa" apps. prefix: true From 3895a75571b58af38f2b7201bd8c56fef4001b20 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Sat, 23 Mar 2024 21:44:35 -1000 Subject: [PATCH 17/22] Updates for deployment --- .controlplane/controlplane.yml | 5 +++++ .controlplane/templates/daily-task.yml | 2 ++ .controlplane/templates/gvc.yml | 6 ++++++ .controlplane/templates/rails.yml | 2 ++ .controlplane/templates/secrets-policy.yml | 4 ++++ .controlplane/templates/secrets.yml | 23 ++++++++++++++++++++++ 6 files changed, 42 insertions(+) create mode 100644 .controlplane/templates/secrets-policy.yml create mode 100644 .controlplane/templates/secrets.yml diff --git a/.controlplane/controlplane.yml b/.controlplane/controlplane.yml index 692eb0f7..92f5b4b2 100644 --- a/.controlplane/controlplane.yml +++ b/.controlplane/controlplane.yml @@ -60,9 +60,14 @@ apps: <<: *common # Order matters! setup_app_templates: + # GVC template contains the identity - gvc + + # Resources - postgres - redis + + # Workloads, like Dynos types on Heroku - daily-task - rails # Prefix is used to identify these "qa" apps. diff --git a/.controlplane/templates/daily-task.yml b/.controlplane/templates/daily-task.yml index 1137801d..f6b8dd9f 100644 --- a/.controlplane/templates/daily-task.yml +++ b/.controlplane/templates/daily-task.yml @@ -30,3 +30,5 @@ spec: external: outboundAllowCIDR: - 0.0.0.0/0 + # Identity is used for binding workload to secrets + identityLink: {{APP_IDENTITY_LINK}} diff --git a/.controlplane/templates/gvc.yml b/.controlplane/templates/gvc.yml index 86abdb61..ea51f2b1 100644 --- a/.controlplane/templates/gvc.yml +++ b/.controlplane/templates/gvc.yml @@ -23,3 +23,9 @@ spec: staticPlacement: locationLinks: - {{APP_LOCATION_LINK}} + +--- + +# Identity is needed to access secrets +kind: identity +name: {{APP_IDENTITY}} diff --git a/.controlplane/templates/rails.yml b/.controlplane/templates/rails.yml index e559b8fe..9641165b 100644 --- a/.controlplane/templates/rails.yml +++ b/.controlplane/templates/rails.yml @@ -34,3 +34,5 @@ spec: # Could configure outbound for more security outboundAllowCIDR: - 0.0.0.0/0 + # Identity is used for binding workload to secrets + identityLink: {{APP_IDENTITY_LINK}} diff --git a/.controlplane/templates/secrets-policy.yml b/.controlplane/templates/secrets-policy.yml new file mode 100644 index 00000000..35bdd886 --- /dev/null +++ b/.controlplane/templates/secrets-policy.yml @@ -0,0 +1,4 @@ +# Policy is needed to allow identities to access secrets +kind: policy +name: {{APP_SECRETS_POLICY}} +targetKind: secret diff --git a/.controlplane/templates/secrets.yml b/.controlplane/templates/secrets.yml new file mode 100644 index 00000000..6616376d --- /dev/null +++ b/.controlplane/templates/secrets.yml @@ -0,0 +1,23 @@ +# Org level secrets are used to store sensitive information that is +# shared across multiple apps in the same organization. This is +# useful for storing things like API keys, database credentials, and +# other sensitive information that is shared across multiple apps +# in the same organization. + +# This is how you apply this once (not during CI) +# cpl apply-template secrets -a qa-react-webpack-rails-tutorial --org shakacode-open-source-examples-staging + +kind: secret +name: {{APP_SECRETS}} +type: dictionary +data: + SOME_ENV: "123456" + +--- + +# Policy is needed to allow identities to access secrets +kind: policy +name: {{APP_SECRETS_POLICY}} +targetKind: secret +targetLinks: + - //secret/{{APP_SECRETS}} From 7a67d1a23012ffd007e954af962a3b0dd76693f0 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Sat, 23 Mar 2024 22:05:27 -1000 Subject: [PATCH 18/22] Updates for deployment --- .github/actions/deploy-to-control-plane/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/deploy-to-control-plane/action.yml b/.github/actions/deploy-to-control-plane/action.yml index f32202d5..fbfa1b84 100644 --- a/.github/actions/deploy-to-control-plane/action.yml +++ b/.github/actions/deploy-to-control-plane/action.yml @@ -66,4 +66,5 @@ runs: - name: Deploy to Control Plane shell: bash run: | - cpl deploy-image -a ${{ inputs.app_name }} --run-release-phase --org ${{inputs.org}} + echo "Deploying to Control Plane" + cpl deploy-image -a ${{ inputs.app_name }} --run-release-phase --org ${{inputs.org}} --verbose From e1aa3fc7284165ac49f47479c33e3650644e10c3 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Sun, 24 Mar 2024 22:18:27 -1000 Subject: [PATCH 19/22] test error handling --- .controlplane/controlplane.yml | 2 +- .controlplane/release_script.sh | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.controlplane/controlplane.yml b/.controlplane/controlplane.yml index 92f5b4b2..26536ff4 100644 --- a/.controlplane/controlplane.yml +++ b/.controlplane/controlplane.yml @@ -14,7 +14,7 @@ aliases: # 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 - # cpln_org: shakacode-open-source-examples + cpln_org: shakacode-open-source-examples-staging # Example apps use only location. CPLN offers the ability to use multiple locations. default_location: aws-us-east-2 diff --git a/.controlplane/release_script.sh b/.controlplane/release_script.sh index 2d9e1c59..ff9616eb 100755 --- a/.controlplane/release_script.sh +++ b/.controlplane/release_script.sh @@ -1,8 +1,25 @@ #!/bin/bash -e -echo 'Running release_script.sh per controlplane.yml' -echo 'Run DB migrations' -./bin/rails db:prepare +log() { + echo "[`date +%Y-%m-%d:%H:%M:%S`]: $1" +} -echo 'Completed release_script.sh per controlplane.yml' +error_exit() { + log "$1" 1>&2 + exit 1 +} + +# Test error! +error_exit + +log 'Running release_script.sh per controlplane.yml' + +if [ -x ./bin/rails ]; then + log 'Run DB migrations' + ./bin/rails db:prepare || error_exit "Failed to run DB migrations" +else + error_exit "./bin/rails does not exist or is not executable" +fi + +log 'Completed release_script.sh per controlplane.yml' From 922f68bfc9918fe0234f6e252512d53d2c5f4a56 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Fri, 5 Apr 2024 10:48:05 -1000 Subject: [PATCH 20/22] Updates for deployment --- .controlplane/templates/{gvc.yml => app.yml} | 0 .controlplane/templates/{secrets.yml => org.yml} | 0 .controlplane/templates/secrets-policy.yml | 4 ---- 3 files changed, 4 deletions(-) rename .controlplane/templates/{gvc.yml => app.yml} (100%) rename .controlplane/templates/{secrets.yml => org.yml} (100%) delete mode 100644 .controlplane/templates/secrets-policy.yml diff --git a/.controlplane/templates/gvc.yml b/.controlplane/templates/app.yml similarity index 100% rename from .controlplane/templates/gvc.yml rename to .controlplane/templates/app.yml diff --git a/.controlplane/templates/secrets.yml b/.controlplane/templates/org.yml similarity index 100% rename from .controlplane/templates/secrets.yml rename to .controlplane/templates/org.yml diff --git a/.controlplane/templates/secrets-policy.yml b/.controlplane/templates/secrets-policy.yml deleted file mode 100644 index 35bdd886..00000000 --- a/.controlplane/templates/secrets-policy.yml +++ /dev/null @@ -1,4 +0,0 @@ -# Policy is needed to allow identities to access secrets -kind: policy -name: {{APP_SECRETS_POLICY}} -targetKind: secret From bea4da5ea87a74cd7b48c4fdb970c9acbf8b01be Mon Sep 17 00:00:00 2001 From: Ramez Weissa Date: Wed, 21 Aug 2024 12:45:14 +0300 Subject: [PATCH 21/22] chore: remove error test --- .controlplane/release_script.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/.controlplane/release_script.sh b/.controlplane/release_script.sh index ff9616eb..fe2ab785 100755 --- a/.controlplane/release_script.sh +++ b/.controlplane/release_script.sh @@ -10,9 +10,6 @@ error_exit() { exit 1 } -# Test error! -error_exit - log 'Running release_script.sh per controlplane.yml' if [ -x ./bin/rails ]; then From e00d59a314b37393d154fdf41b7b7df1f5aa94b7 Mon Sep 17 00:00:00 2001 From: Justin Gordon Date: Tue, 21 Jan 2025 17:54:05 -1000 Subject: [PATCH 22/22] 3.3.4 --- .ruby-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ruby-version b/.ruby-version index ef538c28..a0891f56 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.2 +3.3.4