To install React packages:
cd stod-frontend/
yarn
To install Python packages:
Create a virtual environment within stod-backend (https://docs.python-guide.org/dev/virtualenvs/)
Then:
source venv/bin/activate
pip install -r requirements.txt
Remeber to do:
pip freeze > requirements.txt
After installing a python package
To start
(For good measure, run restart.db.sh afterwards as well)
cd into chat-server/ and run:
docker-compose up --build
cd into stod-backend/ and run:
docker-compose up --build
You only need to use --build
once or if python requirements change, otherwise run it without the flag (faster to start). You can also use -d
like this:
docker-compose up -d --build
or
docker-compose up -d
which will run the container in detached mode as a background process.
docker-compose down --volumes
Interact with postgres through terminal:
psql -h localhost -p 5433 -d hello_django_dev -U hello_django
Or through GUI: Get pgAdmin for your machine: https://www.pgadmin.org/download/
Click add new server and use these credentials:
- Name: hello_django_dev
- Host: localhost
- Port: 5433
- Username: hello_django
- Password: hello_django
The backend server is running on ip: 159.89.88.112 and on domain "stod.backend.app" (no www). Backend is accessed through port 443 and the chat server sockets are accessed through port 4000, both using HTTPS. Postgress/Django environment variables are stored in .env.prod and added to the .gitignore. Docker compose files are stored as docker-compose.prod.yml. SSL certificates are stored in a local path and added to docker volumes.
To allow for local development, all backend-production code is stored in branch "backend-prod".
Build docker containers on server:
To reset the database, run in chat-server and stod-backend:
docker-compose down -v
Chat server should always be run first. Cd into chat server and run:
docker-compose -f docker-compose.prod.yml up --build
Then cd into stod-backend and run:
docker-compose -f docker-compose.prod.yml up --build
Use -it
to run in shell and -d
to run in background
Front end is running on Netlify server using the "prod" branch. Simply push to prod branch to build and deploy front end. Domain is running on "www.stod.app".
To add an admin user, enter docker container by running:
docker exec -it [stodbackend_web ID] /bin/sh
Enter /stod/ and run:
python3 manage.py createsuperuser
POST request
{
"id": "string",
"username": "string",
"email": "string",
"password": "string"
}
Response
{
"user": {
"id": "string",
"username": "string",
"email": "string"
},
"token": "string"
}
POST request
{
"email": "string",
"password": "string"
}
Response
{
"user": {
"id": "string",
"username": "string",
"email": "string"
},
"token": "string"
}
GET request
Must provide Token header.
Response
{
"id": "string",
"username": "string",
"email": "string"
}
Logout is a view provided by the knox library.
POST request
{
"email": "string"
}
Response
{
"success": "We have sent you a link to reset your password"
}
React would grab the uidb64 and token and send a request to accounts/password-reset-complete/
POST request
{
"password": "string",
"token": "string",
"uidb64": "string"
}
Response (on success)
{
"success": "True",
"message": "Password reset success"
}