Boop is a chat app under development by computer science students from The University of the West Indies along with their mentor David Fowler (Partner Software Architect at Microsoft).
- 🔻Downloading the project
- 🚀 Quick Start
- 🏃♂️ Quick resume
- 🗄 Setting up the server
- 💻 Using the client
- 🐋 Building a docker image
- ☸ Deploying to Kubernetes Digital Ocean
- ☸ Redeploying to Kubernetes Digital Ocean
This GitHub guide can walk you through cloning the repo.
-
Make a .env file at the root of the server directory, with your values for the variables in server/env.sample
-
Start docker desktop. Let it run in the background.
-
From the root directory run the following to install all dependencies and create the database:
npm run dev-quick-setup
-
After it is complete wait a few seconds for your database container to start running
-
From the root run the following to run the migrations and seed the database (it will be cleared first):
npm run dev-quick-server
-
Run the application in development mode:
npm run dev
Assuming you've already installed all dependencies, created the database, run all migrations and seeded the database:
-
Start the database container and run the app in development mode:
npm run dev-quick-resume
OR
-
If the database container is already running, start the app in development mode:
npm run dev
Database structure
The ERD for the database can be found here and in the boop-db.png image in the project root.
- Make a .env file at the root of the server directory, with your values for the variables in server/env.sample.
- Make a .env.production file at the root of the server directory, with your values for the variables in server/env.production.sample
-
Docker
-
If you don't have docker desktop download it here. Make sure it's running.
-
Create your container and database:
-
From the root:
npm run server-docker-compose
OR
-
From the server sub directory:
docker-compose up -d
-
-
-
Run database migrations to create your tables in the database in docker (container MUST be running) using:
-
Make sure you have all needed dependencies:
In the project root run:
npm run install-all-deps
-
Run the migrations:
-
from root:
npm run server-migration
OR
-
from server sub-dir
npx sequelize-cli db:migrate
-
-
-
Run the application in development mode using (in the root):
npm run dev
-
(Optional) Use the Thunder Client VSCode extension to test the routes. Here's a JSON file with some sample queries.
-
Installing Dependencies
In the project root run:
npm run install-all-deps
-
Setting up Enviroment Variables
Create a .env file at the root of the server directory if it does not already exist.
Add the following variables to the .env file:
GOOGLE_CLIENT_ID = < Google client Id goes here > GOOGLE_CLIENT_SECRET = < Google client secret goes here > TOKEN_SECRET = < random secret string goes here >
Replace "< random secret string goes here >" with a random string of your choice. You can use env.sample file as a reference.
-
Getting Google App credentials
Sign in to Google's Cloud Console here
From the side menu select "Credetials" then "+ CREATE CREDENTIALS" option.
Select the "OAuth client ID" option.
Fill out the Form as follows:
Set the "Application type" to "Web application". Name : "Boop chat login" (You can use any name for this. Only you will be able to see this in your google console) Under Authorized JavaScript origins ADD URI "http://localhost:3000" Under Authorized redirect URIs ADD URI "http://localhost:5000/api/login/auth/google/callback"
Create
You will be given you Client ID and Client secret.
-
Setting client ID and client Secret.
In the .env file
replace < Google client Id goes here > with the acquired Goolge client ID. e.g GOOGLE_CLIENT_ID = asdjkh489ajhkajshdjh389380.app.googlecontent.com replace < Google client secret goes here > with the acquired Goolge client sercret. e.g GOOGLE_CLIENT_SECRET = ajhasjdhjh48978387jkhfjkhzx
-
Setting up Enviroment Variables
Add the following variables to the .env file:
FACEBOOK_CLIENT_ID = < Facebook client Id goes here > FACEBOOK_CLIENT_SECRET = < Facebook client secret goes here >
-
Getting Facebook app credentials
-
While logged into facebook, navigate to the Facebook for developers website.
-
Click "Get Started" in the top right corner of the webage OR MyApps and skip to step 3.
"Register" by clicking Continue. "Verify account" by adding a cell phone number (e.g 2468435599) and entering the verfication number sent via sms. Confirm email address. Select an option which decribes you and complete registration.
-
Click Create App. Select Consumer. Enter the App display name and create the app.
-
On the left, next to the App display name you chose, click the down arrow. create test app. click create test app again.
-
Under the "Facebook Login" card option, click setup. Select "www". Under site URL enter "http://localhost:3000" and click save. No need to click continue.
-
Go to settings on the left and select basic. Copy the app ID into the .env file in the FACEBOOK_CLIENT_ID variable. Click show next to the App secret. Copy the app secret into the .env file in the FACEBOOK_CLIENT_SECRET variable.
-
-
Ensure you've followed all previous setup instructions.
-
Ensure the database container is running:
-
Start your container in the docker desktop app
OR
-
In the project root run:
npm run docker-start
-
-
Run the server and client in development mode:
In the project root run:
npm run dev
To build the docker image yourself you can use docker build -t boop:0.1.0 .
while in the root of the project. This will read and perform the actions described in the Dockerfile. Ensure you have all the appropriate env vars set.
Once the image is built, a container can be created from the image with the docker-compose file located in the root of the project. You will need to pass docker-compose the required env vars for each container (boop app and postgres). For example: docker-compose -f docker-compose.yml --env-file server/.env up -d
.
The app should then be accessible on port 8080. From here you will need to run the database migration before you can login to the app.
-
Make sure your env variables in server/.env.production have the correct values.
-
Obtain your yaml key for
kubectl
from DigitalOcean in Kubernetes overview section, with the download config file button. This is required if your are using kubectl to manage the kubernetes cluster; this is not required fordoctl
.If you are using a *nix system, the deploy-script.bash script can run the following commands automatically. Simply pass the path to the yaml key for kubectl as the first arg (in project root:
./deploy-script.bash <path to yaml key>
). -
Use
npm run make-yaml-secrets
in the project root to create a secret yaml file (./boop-secret.yaml). The secrets can be pushed to DigitalOcean with kubectl using the commandkubectl --kubeconfig="/path/to/your/yaml/key" apply -f /path/to/your/secret.yaml
. -
The HOME_URL var in the boop-deployment.yaml file needs to be filled in with the url to be used for the app. You can then push the deployment to DigitalOcean using
kubectl --kubeconfig="/path/to/your/yaml/key" create -f ../path/to/boop-deployment.yaml
. -
To create the service to expose the created pods to the outside world, use the boop-service.yaml. The command to push is
kubectl --kubeconfig="/path/to/your/yaml/key" apply -f /path/to/boop-service.yaml
.
If you want to update the env variables used after previously deploying to Kubernetes Digital Ocean:
-
Update the env values in your server/.env.production file
If you are using a *nix system, the redeploy-script.bash script can run the following commands automatically. Simply pass the path to the yaml key for kubectl as the first arg (in project root:
./redeploy-script.bash <path to yaml key>
). -
Delete the current deployment using
kubectl --kubeconfig="/path/to/your/yaml/key" delete deployment boop-deployment
-
Use
npm run make-yaml-secrets
in the project root to create a secret yaml file (./boop-secret.yaml) with the updated env values. The secrets can be pushed to DigitalOcean with kubectl using the commandkubectl --kubeconfig="/path/to/your/yaml/key" apply -f /path/to/your/secret.yaml
. -
The HOME_URL var in the boop-deployment.yaml file needs to be filled in with the url to be used for the app. You can then push the deployment to DigitalOcean using
kubectl --kubeconfig="/path/to/your/yaml/key" create -f ../path/to/boop-deployment.yaml
. -
To create the service to expose the created pods to the outside world, use the boop-service.yaml. The command to push is
kubectl --kubeconfig="/path/to/your/yaml/key" apply -f /path/to/boop-service.yaml
.