-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db5758a
commit a0586e5
Showing
4 changed files
with
69 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,49 @@ | |
|
||
## Migrations | ||
|
||
### Generate | ||
Typeorm will use .env file. Make sure you are going to connect to the correct DB by checking .env file. | ||
|
||
`npm run typeorm -- migration:generate apps/api/src/migrations/NameOfTheMigration` | ||
- To generate a new migration: | ||
|
||
### Run | ||
- `npm run typeorm -- migration:generate apps/api/src/migrations/NameOfTheMigration` | ||
|
||
`npm run typeorm -- migration:run` | ||
- To run the migrations: | ||
- `npm run typeorm -- migration:run` | ||
|
||
## Instructions to deploy to ECS | ||
|
||
- Setup ECS cluster | ||
- Setup RDS and Elasticache | ||
- Update api_secrets in Secrets Manager | ||
- Change ELB target to ECS | ||
- Use conditions to redirect to correct service | ||
- Uncomment ECS deployment step in github workflows | ||
|
||
## Commands to deploy to EC2 | ||
|
||
- Change ELB target to EC2 | ||
- You don't need to specify any redirects as there is an Nginx server handling routing. | ||
- Comment out ECS deployment step in github workflows | ||
- Connect to EC2 instance via ssh | ||
- `ssh -i ./attendance.pem [email protected]` | ||
- Install docker and docker compose | ||
- Check internet for this step | ||
- If needed, update image tags in `docker-compose.yml` file | ||
- When you push a new version, github workflows builds and pushes new image tags to ECR using commit hash. You can use commit hash a few minutes after pushing. | ||
- Copy required files from repository to EC2 | ||
- `scp -i ./attendance.pem ./docker-compose.yml nginx-compose.conf [email protected]:~` | ||
- In EC2, retrieve secrets from secrets manager to .env file | ||
- `aws secretsmanager get-secret-value --secret-id api_secrets| jq --raw-output '.SecretString' | jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' > .env` | ||
- In EC2, login to ECR | ||
- `aws ecr get-login-password | docker login --username AWS --password-stdin 123456789010.dkr.ecr.eu-central-1.amazonaws.com` | ||
- In EC2, start the containers | ||
- `docker-compose up` | ||
|
||
## How to connect to EC2 postgres | ||
|
||
- Create SSH tunnel | ||
- `ssh -i ./attendance.pem -L 5433:localhost:5432 [email protected]` | ||
- Connect to postgres with following inputs | ||
- host = localhost | ||
- port = 5433 | ||
- Refer to secrets manager for username, password and database 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