Project has four parts:
- The RestAPI Feed Backend, a Node-Express feed microservice.
- The RestAPI User Backend, a Node-Express user microservice.
- A Nginx reverse proxy that dispatches requests to feed & user services
- The Simple Frontend A basic Ionic client web application which consumes the RestAPI Backend.
- Install Travis plugin to github
- Create Postgres DB in AWS
- Create S3 bucket and enable CORS
- Build Frontend and Backend services and push to docker hub
- Run images locally with: docker-compose up
- Create EKS cluster and config: aws eks --region update-kubeconfig --name
- Check EKS config: "kubectl get pod"
- Apply AWS secrets in profile file
- Deploy images to cluster: kubectl apply -f "config deploy yaml"
First, you need to configure your variables in the next three files on the deployments/k8s
directory:
- env-secret.yaml
- aws-secret.yaml
- env-configmap.yaml
To test the application in local with docker, you need to run the next commands:
docker-compose -f docker-compose-build.yaml build
docker-compose up
#This will build the necessary images and then it will mount the application in local. You need to define the next variables in local, in order to run it correctly:
- POSTGRESS_USERNAME
- POSTGRESS_PASSWORD
- POSTGRESS_DB
- POSTGRESS_HOST
- AWS_REGION
- AWS_PROFILE
- AWS_BUCKET
- JWT_SECRET
#you can get the images from my docker hub account:
- https://hub.docker.com/repository/docker/andreladeira/reverseproxy
- https://hub.docker.com/repository/docker/andreladeira/udagram-frontend
- https://hub.docker.com/repository/docker/andreladeira/udagram-user
- https://hub.docker.com/repository/docker/andreladeira/udagram-feed
###NOTES
# Installing Node and NPM
This project depends on Nodejs and Node Package Manager (NPM). Before continuing, you must download and install Node (NPM is included) from [https://nodejs.com/en/download](https://nodejs.org/en/download/).
# Installing Ionic Cli
The Ionic Command Line Interface is required to serve and build the frontend. Instructions for installing the CLI can be found in the [Ionic Framework Docs](https://ionicframework.com/docs/installation/cli).
# Installing project dependencies
This project uses NPM to manage software dependencies. NPM Relies on the package.json file located in the root of this repository. After cloning, open your terminal and run:
```bash
npm install
tip: npm i is shorthand for npm install
You'll need to create a new node server. Open a new terminal within the project directory and run:
- Initialize a new project:
npm init
- Install express:
npm i express --save
- Install typescript dependencies:
npm i ts-node-dev tslint typescript @types/bluebird @types/express @types/node --save-dev
- Look at the
package.json
file from the RestAPI repo and copy thescripts
block into the auto-generatedpackage.json
in this project. This will allow you to use shorthand commands likenpm run dev
Ionic uses enviornment files located in ./src/enviornments/enviornment.*.ts
to load configuration variables at runtime. By default environment.ts
is used for development and enviornment.prod.ts
is used for produciton. The apiHost
variable should be set to your server url either locally or in the cloud.
Ionic CLI provides an easy to use development server to run and autoreload the frontend. This allows you to make quick changes and see them in real time in your browser. To run the development server, open terminal and run:
ionic serve
Ionic CLI can build the frontend into static HTML/CSS/JavaScript files. These files can be uploaded to a host to be consumed by users on the web. Build artifacts are located in ./www
. To build from source, open terminal and run:
ionic build
Once you have connected to kubernetes cluster, you need to appy the configurations in the /deployments/k8s/
directory for all the deployments and services (remember to run first frontend, feed and user, before running reverseproxy):
- kubectl apply -f
- kubectl apply -f
- kubectl get pods
In the root directory of the github repository, there is a .travis.yml
that build all the containers and test that is working as expected.