Repository for a simple web application.
Jenkins is running on: https://jenkins.gke.prod.bh7cw.me
-
Build the image
docker build -t webapp:1.0 .
-
Run webapp in local
Make sure you have MySQL database set uo in your local. You will need to pass in your MySQL
port
,schema
,username
andpassword
docker run -it \ -e MYSQL_DB_HOST=host.docker.internal \ -e MYSQL_DB_PORT=3306 \ -e MYSQL_DB_NAME=csye7125 \ -e MYSQL_DB_USERNAME=user \ -e MYSQL_DB_PASSWORD=password \ -p 8080:8080 \ webapp:1.0
-
Create kind cluster
kind create cluster CLUSTER_NAME kind create cluster local
-
Build the image
docker build -t IMAGE_NAME:TAG . docker build -t webapp:1.0 .
-
Push image to Docker Hub
Make sure you login with your docker hub account
You can check the Docker Desktop, or login using following command:
docker login --username USERNAME --password PASSWORD
Push image to docker hub
docker tag IMAGE_NAME:TAG DOCKER_HUB_USERNAME/IMAGE_NAME:TAG docker push DOCKER_HUB_USERNAME/IMAGE_NAME:TAG docker tag webapp:1.0 bboysticker/webapp:1.0 docker push bboysticker/webapp:1.0
-
Change values in
config-map.yml
andsecret.yml
Note: for
secret.yml
, you need to provide base64 encoded stringecho -n "INPUT_STRING" | base64
-
Create
docker-registry
secretkubectl create secret docker-registry docker-hub \ --docker-username=USERNAME \ --docker-password=PASSWORD \ --docker-email=EMAIL
-
Create K8s Objects
kubectl apply -f deploy/config-map.yml kubectl apply -f deploy/sceret.yml kubectl apply -f deploy/pod.yml
-
Port-forward
kubectl port-forward pod/POD_NAME LOCAL_PORT:CONTAINER_PORT kubectl port-forward pod/webapp 8080:8080
-
All API request/response payloads should be in JSON.
-
No UI should be implemented for the application.
-
As a user, I expect all APIs call to return with proper HTTP status code.
-
Your web application must only support Token-Based authentication and not Session Authentication.
-
As a user, I must provide basic authentication token when making a API call to
protected/authenticated
endpoint. -
Create a new user
- As a user, I want to create an account by providing following information.
- Email Address (username)
- Password
- First Name
- Last Name
account_created
field for the user should be set to current time when user creation is successful.- User should not be able to set values for
account_created
andaccount_updated
. Any value provided for these fields must be ignored. Password
field should never be returned in the response payload.- As a user, I expect to use my email address as my username.
- Application must return
400 Bad Request
HTTP response code when a user account with the email address already exists. - As a user, I expect my password to be stored securely using BCrypt password hashing scheme with salt.
- As a user, I want to create an account by providing following information.
-
Update user information
- As a user, I want to update my account information. I should only be allowed to update following fields.
- First Name
- Last Name
- Password
- Attempt to update any other field should return
400 Bad Request
HTTP response code. account_updated
field for the user should be updated when user update is successful.- A user can only update their own account information.
- As a user, I want to update my account information. I should only be allowed to update following fields.
-
Get user information
- As a user, I want to get my account information. Response payload should return all fields for the user except for
password
.
- As a user, I want to get my account information. Response payload should return all fields for the user except for
-
All configuration data for the web application should be passed through environment configuration.
- Sensitive configuration information must be passed using Secrets and non-sensitive configuration information should be provided using ConfigMap.
-
Create a top level directory called
deploy
and store all of you Kubernetes manifests in it.