generated from MinBZK/python-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5347bf
commit fbb3e2c
Showing
40 changed files
with
471 additions
and
492 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,4 @@ __pypackages__/ | |
# tad tool | ||
tad.log* | ||
database.sqlite3 | ||
output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,11 @@ services: | |
db: | ||
condition: service_healthy | ||
env_file: | ||
- path: .env | ||
- path: prod.env | ||
required: true | ||
environment: | ||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:?Variable not set} | ||
- ENVIRONMENT=demo | ||
ports: | ||
- 8000:8000 | ||
healthcheck: | ||
|
@@ -25,7 +26,7 @@ services: | |
- app-db-data:/var/lib/postgresql/data/pgdata | ||
- ./database/:/docker-entrypoint-initdb.d/:cached | ||
env_file: | ||
- path: .env | ||
- path: prod.env | ||
required: true | ||
environment: | ||
- PGDATA=/var/lib/postgresql/data/pgdata | ||
|
@@ -40,7 +41,7 @@ services: | |
ports: | ||
- 8080:8080 | ||
environment: | ||
- PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEFAULT_EMAIL:-[email protected]} | ||
- PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEFAULT_EMAIL:-[email protected]} | ||
- PGADMIN_DEFAULT_PASSWORD=${PGADMIN_DEFAULT_PASSWORD:?Variable not set} | ||
- PGADMIN_LISTEN_PORT=${PGADMIN_LISTEN_PORT:-8080} | ||
depends_on: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env bash | ||
|
||
DATABASE_MIGRATE="" | ||
HOST="0.0.0.0" | ||
LOGLEVEL="warning" | ||
PORT="8000" | ||
|
||
while getopts "dh:l:p:" opt; do | ||
case $opt in | ||
d) | ||
DATABASE_MIGRATE="True" | ||
;; | ||
h) | ||
HOST=$OPTARG | ||
;; | ||
l) | ||
LOGLEVEL=$OPTARG | ||
;; | ||
p) | ||
PORT=$OPTARG | ||
;; | ||
:) | ||
echo "Option -${OPTARG} requires an argument." | ||
exit 1 | ||
;; | ||
|
||
?) | ||
echo "Invalid option: $OPTARG" | ||
|
||
echo "Usage: docker-entrypoint.sh [-d] [-h host] [-l loglevel]" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
echo "DATABASE_MIGRATE: $DATABASE_MIGRATE" | ||
echo "HOST: $HOST" | ||
echo "LOGLEVEL: $LOGLEVEL" | ||
echo "PORT: $PORT" | ||
|
||
|
||
if [ -z $DATABASE_MIGRATE ]; then | ||
echo "Upgrading database" | ||
if ! alembic upgrade head; then | ||
echo "Failed to upgrade database" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
echo "Starting server" | ||
python -m uvicorn --host "$HOST" tad.main:app --port "$PORT" --log-level "$LOGLEVEL" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -x | ||
|
||
docker build . -t ghcr.io/minbzk/tad:latest "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
set -x | ||
|
||
ruff format $@ | ||
ruff format "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -x | ||
|
||
ruff check --fix $@ | ||
ruff check --fix "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
from fastapi.templating import Jinja2Templates | ||
from jinja2 import Environment | ||
|
||
from tad.core.config import settings | ||
|
||
env = Environment( | ||
autoescape=True, | ||
) | ||
templates = Jinja2Templates(directory=settings.TEMPLATE_DIR, env=env) | ||
templates = Jinja2Templates(directory="tad/site/templates/", env=env) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,9 @@ | ||
from fastapi import APIRouter | ||
from fastapi.responses import FileResponse, RedirectResponse | ||
|
||
from tad.core.config import settings | ||
from fastapi.responses import RedirectResponse | ||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get("/") | ||
async def base() -> RedirectResponse: | ||
return RedirectResponse("/pages/") | ||
|
||
|
||
@router.get("/favicon.ico", include_in_schema=False) | ||
async def favicon(): | ||
return FileResponse(settings.STATIC_DIR + "/favicon.ico") |
Oops, something went wrong.