|
1 | 1 | # InterviewPrep
|
2 | 2 |
|
3 |
| -This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 18.2.4. |
| 3 | +This project grew out of wanting to prepare for an interview for a job that would have focused on Angular. As I had been using React exclusively for several months, I needed to refresh my Angular skills. Then I began to add more things to make up for my focus on AWS Amplify. The result is in some ways the opposite of what I have in my previous videos: |
| 4 | + |
| 5 | +* Angular instead of React/NextJS |
| 6 | +* Angular Material instead of AWS Amplify's UI library. (I do, however, use Tailwind CSS in both.) |
| 7 | +* Postgres instead of DynamoDB (Sql vs NoSQL) |
| 8 | +* REST (using a NodeJS/Express backend) vs GraphQL (using Amplify and AppSync) |
| 9 | +* This project has nothing in regard to authentication (yet), while the Amplify project implemented authentication right at the beginning. |
| 10 | + |
| 11 | +Also, in the Amplify project I haven't yet implemented any automated testing but in this project I have unit and integration tests. I set up a GitHub Workflow with GitHub Actions to run the tests when there is a push to or a pull request on specified branches. |
| 12 | + |
| 13 | +This project is Dockerized, and I developed it in a devcontainer. |
| 14 | + |
| 15 | +You'll see some Terraform files in the project but I'll get to that in the next video. |
| 16 | + |
| 17 | +## Devcontainer |
| 18 | + |
| 19 | +I'm using the [Node.js & TypeScript (typescript-node)](https://github.com/devcontainers/templates/tree/main/src/typescript-node) devcontainer. The features I added are |
| 20 | + |
| 21 | +* [sshpass](https://github.com/hspaans/devcontainer-features/tree/master/src/sshpass): installs the GitHub CLI |
| 22 | +* [Angular CLI](https://github.com/devcontainers-extra/features/tree/main/src/angular-cli) |
| 23 | +* [docker-outside-of-docker](https://github.com/devcontainers/features/tree/main/src/docker-outside-of-docker): "Re-use the host docker socket, adding the Docker CLI to a container. Feature invokes a script to enable using a forwarded Docker socket within a container to run Docker commands." |
| 24 | +* [Prettier](https://github.com/devcontainers-community/npm-features/tree/main/src/prettier) |
| 25 | +* [AWS CLI](https://github.com/devcontainers/features/tree/main/src/aws-cli) |
| 26 | +* [Terraform](https://github.com/devcontainers/features/tree/main/src/terraform) |
| 27 | +* [PostgreSQL Client](https://github.com/robbert229/devcontainer-features/blob/main/src/postgresql-client/README.md) |
| 28 | + |
| 29 | +In devcontainer.json you'll see that I'm specifying a network. That's so the devcontainer and the Docker services can communicate with one another. For instance, from a shell within the devcontainer I can connect to the service running the Postgres test database. |
| 30 | + |
| 31 | +I also have some mounts so that |
| 32 | + |
| 33 | +* git can authenticate with GitHub using the SSH agent on my laptop (the host machine) |
| 34 | +* devcontainer can communicate with the host's Docker daemon |
| 35 | +* the AWS credentials and configuration are available within the devcontainer. |
| 36 | + |
4 | 37 |
|
5 |
| -## Development |
6 | 38 |
|
7 | 39 | ### Frontend
|
8 | 40 |
|
@@ -50,22 +82,18 @@ To get more help on the Angular CLI use `ng help` or go check out the [Angular C
|
50 | 82 | `ssh -f -i <PATH TO KEY-PAIR PEM> -L 5433:interviewprepdbinstance.c92egeoumrf1.us-east-1.rds.amazonaws.com:5432 ec2-user@107.22.66.121 -N`
|
51 | 83 | - To keep SSH tunnel alive: `ssh -f -i <PATH TO KEY-PAIR PEM> -L 5433:interviewprepdbinstance.c92egeoumrf1.us-east-1.rds.amazonaws.com:5432 ec2-user@107.22.66.121 -N -o ServerAliveInterval=60 -o ServerAliveCountMax=3`
|
52 | 84 |
|
53 |
| -## Flyway and Migrations |
| 85 | +## Migrations |
54 | 86 |
|
55 | 87 | DB credentials and URLs are in `.env.local` and `.env.development`. Set the environment to be used: `export NODE_ENV=local` or `export NODE_ENV=production`.
|
56 | 88 |
|
57 |
| -The migrations are run (if necessary) after the db container comes up. |
58 |
| - |
59 | 89 | Maybe obsolete:
|
60 | 90 |
|
61 |
| -You need an SSH tunnel to be able to run the Flyway migrations on the db in AWS. Check for a tunnel by using `ps aux | grep ssh`. It will look something like |
| 91 | +You need an SSH tunnel to be able to run the migrations on the db in AWS. Check for a tunnel by using `ps aux | grep ssh`. It will look something like |
62 | 92 |
|
63 | 93 | ```
|
64 | 94 | davidsilva 69319 0.0 0.0 410379280 1904 ?? Ss 12:34PM 0:00.01 ssh -f -i /Users/davidsilva/Downloads/OnyxKeyPair.pem -L 5433:interviewprepdbinstance.c92egeoumrf1.us-east-1.rds.amazonaws.com:5432 ec2-user@107.22.66.121 -N
|
65 | 95 | ```
|
66 | 96 |
|
67 |
| -To run migrations, run `./run-flyway.sh`. |
68 |
| - |
69 | 97 | # SSH into Bastion Host
|
70 | 98 |
|
71 | 99 | The security group only allows SSH connections from my VPN IP address.
|
@@ -201,3 +229,14 @@ Could run in the background or in separate shell to have HTML reports loaded (an
|
201 | 229 |
|
202 | 230 | Everything except the tests will run because frontend is dependent upon backend, which is dependent upon db.
|
203 | 231 | `docker-compose --env-file .env.local up --build frontend`
|
| 232 | + |
| 233 | +# Database |
| 234 | + |
| 235 | +With `interview-prep-db-1` up and running, you can access the db via psql using... |
| 236 | + |
| 237 | +`docker exec -it interview-prep-db-1 psql -U interviewprep_admin -d interviewprepdbinstance` |
| 238 | + |
| 239 | +## Run Migrations |
| 240 | + |
| 241 | +`docker-compose --env-file .env.local up migrate` |
| 242 | + |
0 commit comments