Udagram is a simple cloud application developed alongside the Udacity Cloud Engineering Nanodegree. It allows users to register and log into a web client, post photos to the feed, and process photos using an image filtering microservice.
The project is split into two parts:
- Frontend - Angular web application built with Ionic Framework
- Backend RESTful API - Node-Express application
To run the application you will need:
- Docker
- AWS CLI
- Kubectl
- An AWS account
- A Docker Hub account
The application uses the following services:
- S3 Bucket to store images
- RDS with a PostgreSQL Database
- Elastic Kubernetes Service (Amazon EKS) to orchestrate our containers
Clone the repository on your local machine:
git clone [email protected]:nass59/udagram.git
Once installed you will have to set your environment variables in udagram-api-feed
and udagram-api-user
cp udagram-api-feed/.env.dist udagram-api-feed/.env
cp udagram-api-user/.env.dist udagram-api-user/.env
A file named set_env.sh can be used to help you configure these variables on your local development environment.
Create a PostgreSQL database either locally or on AWS RDS. Set the config values for environment variables prefixed with POSTGRES_
in set_env.sh
.
Create an AWS S3 bucket. Set the config values for environment variables prefixed with AWS_
in set_env.sh
.
Add this following configuration for CORS
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<AllowedMethod>HEAD</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
tip: You can run application from this parent directtory or from each projects.
- Build Docker images:
make build-images
- Run Docker images:
make run
- You can visit
http://localhost:8100
in your web browser to verify that the application is running.
You can push images to the Docker Hub
make push-images
You will have the following results on your Docker Hub
The project uses Travis as CI/CD tool.
The project uses Kubernetes as a CD Tool to orchestrate our docker containers.
Before deploying on k8s you will have to set secrets variables. You can run:
make k8s-set-env // Set Env Variables
make k8s-env // Add Env Variables to k8s
Now you can deploy on k8s using the command:
make k8s-deploy
Once deployed you can check if everything is correct by running the following commands:
kubectl get pods
kubectl get services
kubectl describe hpa
tip: You can enable autoscale by running the command
make k8s-autoscale
on the project you want.
If everything looks good, you should be able to use the application on your browser. You can go to http://localhost:8100
or to your EKS Endpoint (Load Balancer).
To check that the backend API pod logs user activity that is logged when an API call is made you can run the command:
kubectl log YOUR_USER_API_POD -f
-
It's useful to "lint" your code so that changes in the codebase adhere to a coding standard. This helps alleviate issues when developers use different styles of coding.
eslint
has been set up for TypeScript in the codebase for you. To lint your code, run the following:npx eslint --ext .js,.ts src/
To have your code fixed automatically, run
npx eslint --ext .js,.ts src/ --fix
-
Over time, our code will become outdated and inevitably run into security vulnerabilities. To address them, you can run:
npm audit fix