This is a Diet Managment web application that produce diet recommendations and weight tracking. Here is a demo of the app: https://www.loom.com/share/e2496cdb1e734657a7ca7c3e65dd9542
The project has two branches:
Main
: easier deploymentDeployment
: deploying using docker and multiple containersWe recommend using the docker deployment to not have interference between environments.
Main
BranchVirtual environment is a key component in ensuring that the application is configured in the right environment
brew install python3
Pip3 is installed with Python3
To install virtualenv via pip run:
pip3 install virtualenv
Creation of virtualenv:
virtualenv -p python3 venv
If the above code does not work, you could also do
python3 -m venv venv
To activate the virtualenv:
source venv/bin/activate
Or, if you are using Windows - reference source:
venv\Scripts\activate
To deactivate the virtualenv (after you finished working):
deactivate
Install dependencies in virtual environment:
pip3 install -r requirements.txt
Start the server by running:
python3 run.py
if you are on windows:
for only one time of initializing the db
python3 insert_meals.py
Then:
python3 server.py
Deployment
branchThis branch uses Docker containers to deploy the application. You have firstly to checkout to the branch using git.
git checkout deployment
To run the application you should have docker installed and then run the following commands:
docker build -t diet .
docker swarm init
docker stack deploy -c docker-compose.yml diet-swarm
For turning the application off:
docker stack rm diet-swarm
docker swarm leave --force
To run the integration tests:
docker-compose -f docker-compose-test.yml up --build --abort-on-container-exit test
docker-compose -f docker-compose-test.yml down
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
All environment variables are stored within the .env
file and loaded with dotenv package.
Never commit your local settings to the Github repository!
To run the unit tests use the following commands:
python3 -m venv venv_unit
source venv_unit/bin/activate
pip install -r requirements.txt
pytest unit_test
For windows:
python3 -m venv venv_unit
venv_unit/scripts/activate
pip install -r requirements.txt
pytest unit_test