Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
language: minimal

services: docker

env:
- DOCKER_COMPOSE_VERSION=1.23.2

before_install:
- docker -v && docker-compose -v
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin
- curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
- chmod +x ./kubectl
- sudo mv ./kubectl /usr/local/bin/kubectl



install:
- docker-compose -f course-03/exercises/udacity-c3-deployment/docker/docker-compose-build.yaml build --parallel



53 changes: 53 additions & 0 deletions course-03/exercises/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Udagram Image Filtering Microservice

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 three parts:
1. [The Simple Frontend](/udacity-c3-frontend)
A basic Ionic client web application which consumes the RestAPI Backend.
2. [The RestAPI Feed Backend](/udacity-c3-restapi-feed), a Node-Express feed microservice.
3. [The RestAPI User Backend](/udacity-c3-restapi-user), a Node-Express user microservice.

## Getting Setup

> _tip_: this frontend is designed to work with the RestAPI backends). It is recommended you stand up the backend first, test using Postman, and then the frontend should integrate.

### 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**

### Setup Backend Node Environment
You'll need to create a new node server. Open a new terminal within the project directory and run:
1. Initialize a new project: `npm init`
2. Install express: `npm i express --save`
3. Install typescript dependencies: `npm i ts-node-dev tslint typescript @types/bluebird @types/express @types/node --save-dev`
4. Look at the `package.json` file from the RestAPI repo and copy the `scripts` block into the auto-generated `package.json` in this project. This will allow you to use shorthand commands like `npm run dev`


### Configure The Backend Endpoint
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.

***
### Running the Development Server
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:

```bash
ionic serve
```

### Building the Static Frontend Files
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:
```bash
ionic build
```
***
3 changes: 3 additions & 0 deletions course-03/exercises/udacity-c3-deployment/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM nginx:alpine

COPY nginx.conf /etc/nginx/nginx.conf
15 changes: 15 additions & 0 deletions course-03/exercises/udacity-c3-deployment/docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Udagram Image Filtering Microservice

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.



## Tasks

### Setup Docker Environment
You'll need to install docker https://docs.docker.com/install/. Open a new terminal within the project directory and run:

1. Build the images: `docker-compose -f docker-compose-build.yaml build --parallel`
2. Push the images: `docker-compose -f docker-compose-build.yaml push`
3. Run the container: `docker-compose up`

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "3"
services:
reverseproxy:
build:
context: .
image: scheele/reverseproxy
backend_user:
build:
context: ../../udacity-c3-restapi-user
image: scheele/udacity-restapi-user
backend_feed:
build:
context: ../../udacity-c3-restapi-feed
image: scheele/udacity-restapi-feed
frontend:
build:
context: ../../udacity-c3-frontend
image: scheele/udacity-frontend:local
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: "3"
services:
reverseproxy:
image: scheele/reverseproxy
ports:
- 8080:8080
restart: always
depends_on:
- backend-user
- backend-feed
backend-user:
image: scheele/udacity-restapi-user
environment:
POSTGRESS_USERNAME: $POSTGRESS_USERNAME
POSTGRESS_PASSWORD: $POSTGRESS_PASSWORD
POSTGRESS_DB: $POSTGRESS_DB
POSTGRESS_HOST: $POSTGRESS_HOST
AWS_REGION: $AWS_REGION
AWS_PROFILE: $AWS_PROFILE
AWS_BUCKET: $AWS_BUCKET
JWT_SECRET: $JWT_SECRET
URL: "http://localhost:8100"
backend-feed:
image: scheele/udacity-restapi-feed
volumes:
- $HOME/.aws:/root/.aws
environment:
POSTGRESS_USERNAME: $POSTGRESS_USERNAME
POSTGRESS_PASSWORD: $POSTGRESS_PASSWORD
POSTGRESS_DB: $POSTGRESS_DB
POSTGRESS_HOST: $POSTGRESS_HOST
AWS_REGION: $AWS_REGION
AWS_PROFILE: $AWS_PROFILE
AWS_BUCKET: $AWS_BUCKET
JWT_SECRET: $JWT_SECRET
URL: "http://localhost:8100"
frontend:
image: scheele/udacity-frontend:local
ports:
- "8100:80"
33 changes: 33 additions & 0 deletions course-03/exercises/udacity-c3-deployment/docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
worker_processes 1;

events { worker_connections 1024; }
error_log /dev/stdout debug;

http {

sendfile on;

upstream user {
server backend-user:8080;
}

upstream feed {
server backend-feed:8080;
}

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;

server {
listen 8080;
location /api/v0/feed {
proxy_pass http://feed;
}
location /api/v0/users {
proxy_pass http://user;
}
}

}
7 changes: 7 additions & 0 deletions course-03/exercises/udacity-c3-deployment/k8s/aws-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: aws-secret
type: Opaque
data:
credentials: ___INSERT_AWS_CREDENTIALS_FILE__BASE64____
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
service: backend-feed
name: backend-feed
spec:
replicas: 3
template:
metadata:
labels:
service: backend-feed
spec:
containers:
- image: scheele/udacity-restapi-feed
name: backend-feed
imagePullPolicy: Always
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "1024Mi"
cpu: "500m"
env:
- name: URL
valueFrom:
configMapKeyRef:
name: env-config
key: URL
- name: AWS_BUCKET
valueFrom:
configMapKeyRef:
name: env-config
key: AWS_BUCKET
- name: AWS_PROFILE
valueFrom:
configMapKeyRef:
name: env-config
key: AWS_PROFILE
- name: AWS_REGION
valueFrom:
configMapKeyRef:
name: env-config
key: AWS_REGION
- name: JWT_SECRET
valueFrom:
configMapKeyRef:
name: env-config
key: JWT_SECRET
- name: POSTGRESS_DB
valueFrom:
configMapKeyRef:
name: env-config
key: POSTGRESS_DB
- name: POSTGRESS_HOST
valueFrom:
configMapKeyRef:
name: env-config
key: POSTGRESS_HOST
- name: POSTGRESS_PASSWORD
valueFrom:
secretKeyRef:
name: env-secret
key: POSTGRESS_PASSWORD
- name: POSTGRESS_USERNAME
valueFrom:
secretKeyRef:
name: env-secret
key: POSTGRESS_USERNAME
volumeMounts:
- name: aws-secret
mountPath: "/root/.aws/"
readOnly: true
restartPolicy: Always
volumes:
- name: aws-secret
secret:
secretName: aws-secret
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
labels:
service: backend-feed
name: backend-feed
spec:
ports:
- name: "8080"
port: 8080
targetPort: 8080
selector:
service: backend-feed
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
service: backend-user
name: backend-user
spec:
replicas: 2
template:
metadata:
labels:
service: backend-user
spec:
containers:
- image: scheele/udacity-restapi-user
name: backend-user
imagePullPolicy: Always
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "1024Mi"
cpu: "500m"
env:
- name: URL
valueFrom:
configMapKeyRef:
name: env-config
key: URL
- name: JWT_SECRET
valueFrom:
configMapKeyRef:
name: env-config
key: JWT_SECRET
- name: POSTGRESS_DB
valueFrom:
configMapKeyRef:
name: env-config
key: POSTGRESS_DB
- name: POSTGRESS_HOST
valueFrom:
configMapKeyRef:
name: env-config
key: POSTGRESS_HOST
- name: POSTGRESS_PASSWORD
valueFrom:
secretKeyRef:
name: env-secret
key: POSTGRESS_PASSWORD
- name: POSTGRESS_USERNAME
valueFrom:
secretKeyRef:
name: env-secret
key: POSTGRESS_USERNAME
restartPolicy: Always


Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
labels:
service: backend-user
name: backend-user
spec:
ports:
- name: "8080"
port: 8080
targetPort: 8080
selector:
service: backend-user
13 changes: 13 additions & 0 deletions course-03/exercises/udacity-c3-deployment/k8s/env-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: ConfigMap
data:
AWS_BUCKET: ___INSERT_AWS_BUCKET___
AWS_PROFILE: ___INSERT_AWS_PROFILE___
AWS_REGION: ___INSERT_AWS_REGION___
JWT_SECRET: ___INSERT_JWT_SECRET___
POSTGRESS_DB: ___INSERT_POSTGRESS_DB___
POSTGRESS_HOST: ___INSERT_POSTGRESS_HOST___
URL: http://localhost:8100
metadata:
name: env-config

8 changes: 8 additions & 0 deletions course-03/exercises/udacity-c3-deployment/k8s/env-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: env-secret
type: Opaque
data:
POSTGRESS_USERNAME: ___INSERT_POSTGRESS_USERNAME__BASE64___
POSTGRESS_PASSWORD: ___INSERT_POSTGRESS_PASSWORD__BASE64___
Loading