-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split up Server into Renderer/API for Staging (#9827)
* API docker file stage * add api to ecs task definition * add api image to workflow * add API_ONLY config changes * add API Only infra * add healthcheck to routes * change route order * fix gh action * use a different way to check this to allow for multiple labels * make a separate service for the api server * fix image nnot being pushed to the right repo * don't set_local on api requests * fix healthcheck * move API help to static page controller * render errors as json for api requests * enable back session store in api_only * don't set API only for api server * run rubocop * add API deployment to other Workflows
- Loading branch information
1 parent
b662106
commit 19d74c5
Showing
16 changed files
with
333 additions
and
19 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
.github/workflows/deploy-main-to-staging-from-tagged-prs.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: Deploy Main to Staging From Tagged PRs | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
jobs: | ||
build: | ||
if: contains(github.event.pull_request.labels.*.name, 'deploy-staging') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-access-key-id: ${{ secrets.CI_CD_AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.CI_CD_AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ secrets.AWS_DEFAULT_REGION }} | ||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
- name: Get the SHA of the current branch/fork | ||
shell: bash | ||
run: | | ||
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV" | ||
- name: Build and Push Sidekiq image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: true | ||
target: sidekiq | ||
tags: | | ||
${{ steps.login-ecr.outputs.registry }}/wca-on-rails:sidekiq-staging | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
build-args: | | ||
BUILD_TAG=${{ env.SHORT_SHA }} | ||
WCA_LIVE_SITE=false | ||
SHAKAPACKER_ASSET_HOST=https://assets-staging.worldcubeassociation.org | ||
- name: Build and push Staging API Image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: true | ||
target: monolith-api | ||
tags: | | ||
${{ steps.login-ecr.outputs.registry }}/wca-on-rails:staging-api | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
build-args: | | ||
BUILD_TAG=${{ env.SHORT_SHA }} | ||
WCA_LIVE_SITE=false | ||
SHAKAPACKER_ASSET_HOST=https://assets-staging.worldcubeassociation.org | ||
- name: Build and push Staging Image | ||
id: build-staging | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: true | ||
load: true | ||
target: monolith | ||
tags: | | ||
${{ steps.login-ecr.outputs.registry }}/wca-on-rails:staging | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
build-args: | | ||
BUILD_TAG=${{ env.SHORT_SHA }} | ||
WCA_LIVE_SITE=false | ||
SHAKAPACKER_ASSET_HOST=https://assets-staging.worldcubeassociation.org | ||
# We build assets in docker and copy it out so we don't have to install all the dependencies in the GH Action | ||
- name: Copy assets out of the container and push to S3 | ||
run: | | ||
id=$(docker create ${{steps.build-staging.outputs.imageid }}) | ||
docker cp $id:/rails/public/ ./assets | ||
aws s3 sync ./assets s3://assets-staging.worldcubeassociation.org/assets/${{ env.SHORT_SHA }} | ||
# There is no pipeline for staging so we manually force to update the image | ||
- name: Deploy staging | ||
run: | | ||
aws ecs update-service --cluster wca-on-rails --service wca-on-rails-staging --force-new-deployment | ||
aws ecs update-service --cluster wca-on-rails --service wca-on-rails-staging-API --force-new-deployment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
class ApiErrorsController < ApplicationController | ||
skip_before_action :set_locale | ||
skip_before_action :store_user_location! | ||
def show | ||
exception = request.env["action_dispatch.exception"] | ||
status_code = ActionDispatch::ExceptionWrapper.new(request.env, exception).status_code | ||
request_id = request.env["action_dispatch.request_id"] | ||
render json: { error_code: status_code, request_id: request_id, contact_url: Rails.application.routes.url_helpers.contact_url(contactRecipient: 'wst', requestId: request_id) }, status: status_code | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,9 @@ def score_tools | |
def logo | ||
end | ||
|
||
def api_help | ||
end | ||
|
||
def robots | ||
respond_to :txt | ||
end | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,11 @@ class Application < Rails::Application | |
end | ||
|
||
config.default_from_address = "[email protected]" | ||
config.site_name = "World Cube Association" | ||
config.site_name = if EnvConfig.API_ONLY? | ||
"World Cube Association API" | ||
else | ||
"World Cube Association" | ||
end | ||
|
||
config.middleware.insert_before 0, Rack::Cors, debug: false, logger: (-> { Rails.logger }) do | ||
allow do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.