Skip to content

Commit

Permalink
Update template
Browse files Browse the repository at this point in the history
Bump dependencies, update README and Makefile.
  • Loading branch information
frimro committed Nov 26, 2024
1 parent 5d360c4 commit 571a4c4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*~
*.swp
*.py[co]
ve
25 changes: 15 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
@$(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
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.7"

services:
api:
image: seravo-api
Expand All @@ -11,4 +9,3 @@ services:
ports: ["8080:8000"]
volumes:
- "./seravo/:/app/seravo:rw"
- "./tests/:/app/tests:rw"
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
fastapi==0.108
pytest==7.4
httpx==0.26
fastapi==0.115.5
pytest==8.3.3
httpx==0.27.2

0 comments on commit 571a4c4

Please sign in to comment.