Skip to content

Commit

Permalink
Merge pull request #181 from grillazz/179-reflect-latest-and-greatest…
Browse files Browse the repository at this point in the history
…-fastapi-improvements

179 reflect latest and greatest fastapi improvements
  • Loading branch information
grillazz authored Oct 18, 2024
2 parents d28e6a6 + 3623268 commit 48cbb8c
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ POSTGRES_USER=user
POSTGRES_PASSWORD=secret

# Redis
REDIS_HOST=redis
REDIS_HOST=inmemory
REDIS_PORT=6379
REDIS_DB=2

Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,7 @@ model-generate: ## generate sqlalchemy models from database
.PHONY: docker-up-granian
docker-up-granian: ## Run project with compose and granian
docker compose -f granian-compose.yml up --remove-orphans

.PHONY: docker-up-valkey
docker-up-valkey: ## Run project with compose and valkey
docker compose -f valkey-compose.yml up --remove-orphans
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ I've included a few of my favorites to kick things off!
* [Connection pool for asyncpg](https://magicstack.github.io/asyncpg/current/usage.html#connection-pools)
* [Granian - A Rust HTTP server for Python applications](https://github.com/emmett-framework/granian)
* [APScheduler - In-process task scheduler with Cron-like capabilities](https://apscheduler.readthedocs.io/en/master/)
* [Valkey - A simple and fast key-value store](https://github.com/valkey-io/valkey)

<p align="right">(<a href="#readme-top">back to top</a>)</p>

Expand Down
4 changes: 2 additions & 2 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ services:
timeout: 5s
retries: 5

redis:
inmemory:
image: redis:latest
container_name: fsap_redis
container_name: fsap_inmemory
ports:
- "6379:6379"
env_file:
Expand Down
4 changes: 2 additions & 2 deletions granian-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ services:
timeout: 5s
retries: 5

redis:
inmemory:
image: redis:latest
container_name: fsap_redis
container_name: fsap_inmemory
ports:
- "6379:6379"
env_file:
Expand Down
57 changes: 57 additions & 0 deletions valkey-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
services:
app:
container_name: fsap_app
build: .
env_file:
- .env
- .secrets
command: bash -c "
uvicorn app.main:app
--log-config ./logging-uvicorn.json
--host 0.0.0.0 --port 8080
--lifespan=on --use-colors --loop uvloop --http httptools
--reload --log-level debug
"
volumes:
- .:/home/code
ports:
- "8080:8080"
depends_on:
- db
- valkey

db:
container_name: fsap_db
build:
context: ./db
dockerfile: Dockerfile
volumes:
- fastapi_postgres_data:/var/lib/postgresql/data
env_file:
- .env
ports:
- 5432:5432
environment:
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD?Variable not set}
- POSTGRES_USER=${POSTGRES_USER?Variable not set}
- POSTGRES_DB=${POSTGRES_DB?Variable not set}
healthcheck:
test:
[
"CMD-SHELL", "pg_isready -d $POSTGRES_DB -U $POSTGRES_USER"
]
interval: 5s
timeout: 5s
retries: 5

inmemory:
image: valkey/valkey:latest
container_name: fsap_inmemory
ports:
- "6379:6379"
env_file:
- .env
entrypoint: valkey-server --loglevel verbose

volumes:
fastapi_postgres_data: {}

0 comments on commit 48cbb8c

Please sign in to comment.