diff --git a/.gitignore b/.gitignore index c3ba83f..b520ed7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *~ *.swp *.py[co] +ve \ No newline at end of file diff --git a/Makefile b/Makefile index b12c67e..5a78348 100644 --- a/Makefile +++ b/Makefile @@ -1,28 +1,33 @@ APT_PROXY ?= SUDO ?= +PYTHON3 ?= python3.10 all: purge: - $(SUDO) docker-compose down -v --remove-orphans + $(SUDO) docker compose down -v --remove-orphans stop: - $(SUDO) docker-compose down + $(SUDO) docker compose down build: - $(SUDO) docker-compose build + $(SUDO) docker compose build run: build - $(SUDO) docker-compose up -d + $(SUDO) docker compose up -d develop: run - $(SUDO) docker-compose logs --follow - -test: - @$(SUDO) docker-compose exec api pytest tests -vv + $(SUDO) docker compose logs --follow reload: - @$(SUDO) docker-compose exec api reload-gunicorn + @$(SUDO) docker compose exec api reload-gunicorn exec: - @$(SUDO) docker-compose exec api bash \ No newline at end of file + @$(SUDO) docker compose exec api bash + +ve: + ${PYTHON3} -m venv ve + ve/bin/pip install -r requirements.txt + +unittest: ve + ve/bin/pytest -v tests diff --git a/README.md b/README.md index 31884fc..0204fb0 100644 --- a/README.md +++ b/README.md @@ -18,23 +18,19 @@ Run `make reload` to reload the gunicorn workers. If you think that your changes Run `make purge` to remove the container. +### Virtual environment + +Run `make ve` to create the virtual environment. + ### Tests -You can use `make test` to execute tests inside the container. +You can use `make unittest` to execute tests inside the virtual environment. ## Running FastAPI from the terminal Alternatively, you can also run the application from your terminal with `uvicorn`. See [FastAPI docs](https://fastapi.tiangolo.com/#installation) on how to install the required packages. -Remember to also install the dependencies defined in `requirements.txt`! - -```console -pip install -r requirements.txt -``` - -Finally, run `uvicorn seravo.main:app --reload` to start our base application. - -You can run the tests with `pytest -vv tests`, granted you have `pytest` installed. +You can then run `./ve/bin/uvicorn seravo.main:app --reload` to start our base application. ## The tasks diff --git a/docker-compose.yml b/docker-compose.yml index 2135346..a13bb56 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3.7" - services: api: image: seravo-api @@ -11,4 +9,3 @@ services: ports: ["8080:8000"] volumes: - "./seravo/:/app/seravo:rw" - - "./tests/:/app/tests:rw" diff --git a/requirements.txt b/requirements.txt index 8c25c5e..0d9af12 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -fastapi==0.108 -pytest==7.4 -httpx==0.26 \ No newline at end of file +fastapi==0.115.5 +pytest==8.3.3 +httpx==0.27.2 \ No newline at end of file