-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into christina/move-frontend-off-aws
- Loading branch information
Showing
328 changed files
with
2,146 additions
and
900 deletions.
There are no files selected for viewing
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
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,36 @@ | ||
# How to do a Manual Deploy (to staging or prod). | ||
|
||
Note: All of the `yarn` scripts in this guide are in the root `package.json`. | ||
|
||
**This will deploy the current files as they are in your local repo**. They will be tagged with the local HEAD commit. | ||
|
||
If you don't want this, you'll need to run modified calls rather than the package.json scripts directly. | ||
|
||
## Prereqs: | ||
|
||
- Install Docker | ||
- Install the AWS CLI | ||
- Have an AWS Access Key ID and AWS Secret Access Key pair. | ||
- Run `aws configure`, and input those keys along with us-east-1 as the region. You can set the Default Output Format to json. | ||
|
||
## Steps: | ||
|
||
1. Run `yarn frontend:build` and/or `yarn backend:build` depending on what you want to build. | ||
2. Run `yarn frontend:run` and/or `yarn backend:run` to test that the image runs (the backend won't be able to connect to the database which is expected, and the frontend will not connect to the backend). | ||
3. You may have to run `yarn ecr:docker:auth` to reauthenticate Docker with AWS ECR. (There is no harm in running this command unnecessarily, so if you're unsure you can just run it). | ||
4. If the images run successfully, run `yarn frontend:push` and/or `yarn backend:push` to push the built images to AWS ECR. | ||
5. Run `./infrastructure/prod/redeploy.sh <environment> local-head <service>` | ||
|
||
`<environment>` is either `prod` or `staging`. | ||
`<service>` is one of `frontend`, `backend`, or `both`. | ||
|
||
# How to Manually Redeploy a Previously Deployed Commit | ||
|
||
If you know that a commit already has an image pushed to ECR (ex. the commit is in main, or you already pushed the image using the above steps) and you want to deploy that particular image to staging or prod, you can use the redeploy.sh script. | ||
|
||
1. Find the commit's hash (looks like this: 1445f9533c4ec9a7324c721f09fc5ccec1542d8d). | ||
2. Run `./infrastructure/prod/redeploy.sh <environment> <commit_hash> <service>` | ||
|
||
`<environment>` is either `prod` or `staging`. | ||
`<commit_hash>` is the hash of the commit you just found. | ||
`<service>` is one of `frontend`, `backend`, or `both`. |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#!/bin/sh | ||
|
||
cd packages/api-v2 | ||
cd packages/api | ||
echo "Running on commit: $COMMIT_HASH" | ||
yarn typeorm migration:run | ||
exec "$@" | ||
|
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,34 @@ | ||
if [[ $# != 2 ]]; then | ||
echo "Usage: get-ecr-image-name.sh <COMMIT_TAG | latest-main | local-head> <frontend | backend>" | ||
exit 1 | ||
fi | ||
|
||
# Accept a few different formats for the commit hash. | ||
if [[ ${#1} = 40 ]]; then | ||
ECR_IMAGE_COMMIT_HASH=$1 | ||
elif [[ $1 = "latest-main" ]]; then | ||
ECR_IMAGE_COMMIT_HASH=$(git ls-remote https://github.com/sandboxnu/graduatenu.git main | awk '{ print $1 }') | ||
elif [[ $1 = "local-head" ]]; then | ||
ECR_IMAGE_COMMIT_HASH=$(git rev-parse HEAD) | ||
else | ||
echo "ERROR: Invalid commit '$1'" | ||
exit 1 | ||
fi | ||
|
||
if [[ $2 = "frontend" ]]; then | ||
REPO="graduatenu-node" | ||
elif [[ $2 = "backend" ]]; then | ||
REPO="graduatenu-rails" | ||
else | ||
echo "Please choose a service to create an image name for: 'frontend' or 'backend'" | ||
exit 1 | ||
fi | ||
|
||
AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text) | ||
AWS_DEFAULT_REGION="us-east-1" | ||
|
||
ECR_REGISTRY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com" | ||
|
||
ECR_IMAGE_NAME="${ECR_REGISTRY}/${REPO}:${ECR_IMAGE_COMMIT_HASH}" | ||
|
||
echo $ECR_IMAGE_NAME |
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.