-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
67 lines (58 loc) · 1.79 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
SHELL := /bin/bash
.PHONY: lint
lint:
uv sync --all-groups
# Static Typing
uv run mypy app
# Linting
uv run ruff check app
uv run pylint -r n app
# Formatting
uv run isort app --check-only
uv run black app --check
.PHONY: test
test:
uv sync --group test
export DESCRIPTION=$$(cat README.md) && \
uv run pytest -vv \
--cov=app --cov-branch --cov-report=xml \
--junitxml=junit.xml -o junit_family=legacy
.PHONY: dev
dev:
export DESCRIPTION=$$(cat README.md) && \
source ./envs/dev.env && \
uv run uvicorn app.main:app --host 0.0.0.0 --port $${PORT} \
--env-file ./envs/dev.env \
--proxy-headers --forwarded-allow-ips='*' \
--reload
.PHONY: prod
prod:
export DESCRIPTION=$$(cat README.md) && \
uv run uvicorn app.main:app --host 0.0.0.0 \
--env-file ./envs/prod.env \
--proxy-headers --forwarded-allow-ips='*'
.PHONY: k8s
k8s:
kubectl delete -n fastapi -f k8s/postgresql/dev.yaml 2> /dev/null || echo "Not deployed to the dev environment! 🌎"
kubectl apply -n fastapi -f k8s/postgresql/secrets.yaml
kubectl apply -n fastapi -f k8s/postgresql/dev.yaml
.PHONY: exec
exec:
kubectl exec -it -n fastapi deploy/fastapi-dev -- zsh
.PHONY: expose
expose:
kubectl expose -n fastapi po/postgresql-0 --port 5432 --type=NodePort
.PHONY: swagger
swagger:
curl https://unpkg.com/[email protected]/swagger-ui-bundle.js > static/swagger-ui-bundle.js
curl https://unpkg.com/[email protected]/swagger-ui.css > static/swagger-ui.css
npx prettier --write "static/*.{js,css}"
.PHONY: deploy
deploy:
echo $(tag)
sed -i 's|zerohertzkr/fastapi-cookbook:[^ ]*|zerohertzkr/fastapi-cookbook:$(tag)|' k8s/postgresql/fastapi.yaml
git add k8s/postgresql/fastapi.yaml
git commit -m ":ship: release: $(tag)"
git tag -a $(tag) -m ":ship: release: $(tag)"
git push origin main
git push origin $(tag)