mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2026-01-17 11:40:39 +03:00
bump project deps
This commit is contained in:
59
Makefile
59
Makefile
@@ -1,9 +1,21 @@
|
||||
# Set the default goal to "help" so that running "make" without arguments will display the help message.
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
# ====================================================================================
|
||||
# HELP
|
||||
# ====================================================================================
|
||||
# This target uses a combination of egrep, sort, and awk to parse the Makefile itself
|
||||
# and generate a formatted help message. It looks for lines containing '##' and
|
||||
# uses the text that follows as the help description for the target.
|
||||
.PHONY: help
|
||||
help: ## Show this help
|
||||
@egrep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
# ====================================================================================
|
||||
# DOCKER COMPOSE MANAGEMENT
|
||||
# ====================================================================================
|
||||
.PHONY: docker-build
|
||||
docker-build: ## Build project with compose
|
||||
docker-build: ## Build project Docker images using compose
|
||||
docker compose build
|
||||
|
||||
.PHONY: docker-up
|
||||
@@ -11,46 +23,61 @@ docker-up: ## Run project with compose
|
||||
docker compose up --remove-orphans
|
||||
|
||||
.PHONY: docker-clean
|
||||
docker-clean: ## Clean Reset project containers and volumes with compose
|
||||
docker-clean: ## Clean and reset project containers and volumes
|
||||
docker compose down -v --remove-orphans | true
|
||||
docker compose rm -f | true
|
||||
docker volume rm panettone_postgres_data | true
|
||||
|
||||
# ====================================================================================
|
||||
# DATABASE MIGRATIONS
|
||||
# ====================================================================================
|
||||
.PHONY: docker-apply-db-migrations
|
||||
docker-apply-db-migrations: ## apply alembic migrations to database/schema
|
||||
docker-apply-db-migrations: ## Apply alembic migrations to the database schema
|
||||
docker compose run --rm api1 alembic upgrade head
|
||||
|
||||
.PHONY: docker-create-db-migration
|
||||
docker-create-db-migration: ## Create new alembic database migration aka database revision. Example: make docker-create-db-migration msg="add users table"
|
||||
docker-create-db-migration: ## Create a new alembic database migration. Example: make docker-create-db-migration msg="add users table"
|
||||
docker compose up -d postgres | true
|
||||
docker compose run --no-deps api1 alembic revision --autogenerate -m "$(msg)"
|
||||
|
||||
# ====================================================================================
|
||||
# TESTING
|
||||
# ====================================================================================
|
||||
.PHONY: docker-test
|
||||
docker-test: ## Run project tests
|
||||
docker compose -f compose.yml -f test-compose.yml run --rm api1 pytest tests --durations=0 -vv
|
||||
|
||||
.PHONY: docker-test-snapshot
|
||||
docker-test-snapshot: ## Run project tests with inline snapshot
|
||||
docker-test-snapshot: ## Run project tests and update snapshots
|
||||
docker compose -f compose.yml -f test-compose.yml run --rm api1 pytest tests --inline-snapshot=fix
|
||||
|
||||
# ====================================================================================
|
||||
# CODE QUALITY & LINTING
|
||||
# ====================================================================================
|
||||
.PHONY: safety
|
||||
safety: ## Check project and dependencies with safety https://github.com/pyupio/safety
|
||||
safety: ## Check for insecure dependencies
|
||||
docker compose run --rm api1 safety check
|
||||
|
||||
.PHONY: py-upgrade
|
||||
py-upgrade: ## Upgrade project py files with pyupgrade library for python version 3.10
|
||||
py-upgrade: ## Upgrade Python syntax to a newer version
|
||||
pyupgrade --py313-plus `find api1 -name "*.py"`
|
||||
|
||||
.PHONY: lint
|
||||
lint: ## Lint project code.
|
||||
lint: ## Lint and format project code
|
||||
uv run ruff check --fix .
|
||||
|
||||
# ====================================================================================
|
||||
# DOCKER IMAGE BUILDING
|
||||
# ====================================================================================
|
||||
.PHONY: slim-build
|
||||
slim-build: ## with power of docker-slim build smaller and safer images
|
||||
slim-build: ## Build smaller and more secure Docker images with docker-slim
|
||||
docker-slim build --compose-file docker-compose.yml --target-compose-svc api1 --dep-include-target-compose-svc-deps true --http-probe-exec api1 fastapi-sqlalchemy-asyncpg_api1:latest
|
||||
|
||||
# ====================================================================================
|
||||
# DATABASE SEEDING
|
||||
# ====================================================================================
|
||||
.PHONY: docker-feed-database
|
||||
docker-feed-database: ## create database objects and insert data
|
||||
docker-feed-database: ## Create database objects and insert seed data
|
||||
docker compose exec postgres psql devdb devdb -f /home/gx/code/shakespeare_work.sql | true
|
||||
docker compose exec postgres psql devdb devdb -f /home/gx/code/shakespeare_chapter.sql | true
|
||||
docker compose exec postgres psql devdb devdb -f /home/gx/code/shakespeare_wordform.sql | true
|
||||
@@ -58,14 +85,20 @@ docker-feed-database: ## create database objects and insert data
|
||||
docker compose exec postgres psql devdb devdb -f /home/gx/code/shakespeare_paragraph.sql | true
|
||||
docker compose exec postgres psql devdb devdb -f /home/gx/code/shakespeare_character_work.sql
|
||||
|
||||
# ====================================================================================
|
||||
# MODEL GENERATION
|
||||
# ====================================================================================
|
||||
.PHONY: model-generate
|
||||
model-generate: ## generate sqlalchemy models from database
|
||||
model-generate: ## Generate SQLAlchemy models from the database schema
|
||||
poetry run sqlacodegen --generator declarative postgresql://devdb:secret@0.0.0.0/devdb --outfile models.py --schemas shakespeare --options nobidi
|
||||
|
||||
# ====================================================================================
|
||||
# ALTERNATIVE RUNTIMES
|
||||
# ====================================================================================
|
||||
.PHONY: docker-up-granian
|
||||
docker-up-granian: ## Run project with compose and granian
|
||||
docker-up-granian: ## Run project with compose and the Granian web server
|
||||
docker compose -f granian-compose.yml up --remove-orphans
|
||||
|
||||
.PHONY: docker-up-valkey
|
||||
docker-up-valkey: ## Run project with compose and valkey
|
||||
docker-up-valkey: ## Run project with compose and Valkey
|
||||
docker compose -f valkey-compose.yml up --remove-orphans
|
||||
|
||||
Reference in New Issue
Block a user