Skip to content
Snippets Groups Projects
README.md 1.45 KiB
Newer Older
Ivan Procaccini's avatar
Ivan Procaccini committed
# Project Allocator
Ivan Procaccini's avatar
Ivan Procaccini committed

Ivan Procaccini's avatar
Ivan Procaccini committed
[![pipeline status](https://gitlab.doc.ic.ac.uk/edtech/project-allocator/badges/master/pipeline.svg)](https://gitlab.doc.ic.ac.uk/edtech/project-allocator/commits/master)
Ivan Procaccini's avatar
Ivan Procaccini committed

Ivan Procaccini's avatar
Ivan Procaccini committed
## Project Requirements
Ivan Procaccini's avatar
Ivan Procaccini committed

Ivan Procaccini's avatar
Ivan Procaccini committed
* **Python 3.10** and [Flask](http://flask.palletsprojects.com/)
* [Gunicorn](https://gunicorn.org/) - web server ("in front" of the API)
* **Postgres SQL** - databases
Ivan Procaccini's avatar
Ivan Procaccini committed

Ivan Procaccini's avatar
Ivan Procaccini committed
## Running the app
Ivan Procaccini's avatar
Ivan Procaccini committed

Ivan Procaccini's avatar
Ivan Procaccini committed
Via `docker-compose`:
Ivan Procaccini's avatar
Ivan Procaccini committed

Ivan Procaccini's avatar
Ivan Procaccini committed
```shell
docker compose up -f dev.docker-compose.yml [--build]
docker exec $(docker ps -qf "name=allocator" | head -n1) flask db upgrade
docker exec $(docker ps -qf "name=allocator" | head -n1) flask populate_dev
```
Ivan Procaccini's avatar
Ivan Procaccini committed

Ivan Procaccini's avatar
Ivan Procaccini committed
Alternatively, if you want to run the app locally (recommended for debugging):
Ivan Procaccini's avatar
Ivan Procaccini committed

Ivan Procaccini's avatar
Ivan Procaccini committed
```shell
# Terminal panel 1
docker run --rm --name project-allocator -p 2000:5432 -e POSTGRES_DB=project-allocator -e POSTGRES_USER=user -e POSTGRES_PASSWORD=pass postgres
Ivan Procaccini's avatar
Ivan Procaccini committed

Ivan Procaccini's avatar
Ivan Procaccini committed
# Terminal panel 2
export DB_OVERRIDE=postgresql://user:pass@localhost:2000/project-allocator
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
flask db upgrade
flask populate_dev
flask run
```
Ivan Procaccini's avatar
Ivan Procaccini committed

Ivan Procaccini's avatar
Ivan Procaccini committed
Then browse to <http://localhost:5000>.
Ivan Procaccini's avatar
Ivan Procaccini committed

Ivan Procaccini's avatar
Ivan Procaccini committed
## Running the tests
Ivan Procaccini's avatar
Ivan Procaccini committed

Ivan Procaccini's avatar
Ivan Procaccini committed
Via `docker-compose`, after *upping*:
Ivan Procaccini's avatar
Ivan Procaccini committed

Ivan Procaccini's avatar
Ivan Procaccini committed
```shell
docker exec $(docker ps -qf "name=allocator" | head -n1) pytest
Ivan Procaccini's avatar
Ivan Procaccini committed
```

Ivan Procaccini's avatar
Ivan Procaccini committed
Alternatively, if you want to run the test locally (Mac specific):
Ivan Procaccini's avatar
Ivan Procaccini committed

Ivan Procaccini's avatar
Ivan Procaccini committed
```shell
brew services start postgres
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
pytest
```