To set up a development environment follow these simple steps.
- Clone this repo
- If not already installed, install the following packages locally: Docker, python 3.8 and git
- Create .env file with the following contents. Get secrets from another dev.
# .env
FLASK_ENV=development
FLASK_APP=__main__.py
FRONTEND_URL=http://localhost:19006/
# MONGO_URI not required for the app in dev
MONGO_URI=mongodb+srv://admin:<password>@data-cluster.tjzlp.mongodb.net/database?retryWrites=true&w=majority
MONGO_INITDB_DATABASE=database
MONGO_INITDB_ROOT_USERNAME=admin
MONGO_INITDB_ROOT_PASSWORD=<password>
MONGO_IP=172.19.199.3
MONGO_PORT=27017
# SECRET_KEY randomly generate, MUST be secure
SECRET_KEY=this-is-a-secret-key-keep-it-secret
[email protected]
GMAIL_PASSWORD=<password>
- Build docker containers. After building, api service is up and running on localhost:5000.
# build db and api containers
docker-compose up -d --build
# restore your local db from the backup file
script/restore_dev_db.sh
# if db exists, might need to drop the old db before restoring
rm -rf mongo_voume/
# all container logs
docker-compose logs -f --tail=100
# Stop containers
docker-compose down
- run python tests
pipenv run python -m pytest
Immediatley after a fresh rebuild of containers it is common that the api service is not connected to mongo database and the frontend will throw an error.
Workaround:
- add
print(db)
toapi/resource/culture.py
before line 38. - reload the web page
- error should be gone
- remove
print(db)
from culture.py and everything will work as expected
.github/workflows/deploy.yml
is automatically deploying the frontend and the backend to their respective environments. If the workflow fails, you may need to deploy manually.
The following command will deploy the latest main branch to the ec2 instance, if you want to deploy another branch, follow these instructions.
# redeploy api service
script/deploy_production_server.sh /path/to/key
Amazon Linux 2 free-tier image running gunicorn and nginx services. Contact @freeman91 for ssh credentials.
Gunicorn (Green Unicorn) is a Python WSGI HTTP Server for UNIX.
Using NginX as a HTTP and reverse proxy server, routing HTTP and HTTPS traffic to gunicorn through a socket file.
Listening for http/s requests on www.osumc-cultural-awareness.com.
For more information about how the AWS environment was set up refer to this documentation