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
cf8d3d0
commit 3920116
Showing
47 changed files
with
727 additions
and
592 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
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
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,10 @@ 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,12 +25,10 @@ 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 | ||
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:?Variable not set} | ||
- SECRET_KEY=${SECRET_KEY:?Variable not set} | ||
healthcheck: | ||
test: ["CMD", "pg_isready", "-q", "-d", "tad", "-U", "tad"] | ||
|
||
|
@@ -40,16 +38,15 @@ services: | |
ports: | ||
- 8080:8080 | ||
environment: | ||
- PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEFAULT_EMAIL:[email protected]} | ||
- PGADMIN_DEFAULT_PASSWORD=${PGADMIN_DEFAULT_PASSWORD:?Variable not set} | ||
- PGADMIN_LISTEN_PORT=${PGADMIN_LISTEN_PORT:-8080} | ||
env_file: | ||
- path: prod.env | ||
required: true | ||
depends_on: | ||
db: | ||
condition: service_healthy | ||
healthcheck: | ||
test: ["CMD", "wget", "-O", "-", "http://localhost:8080/misc/ping"] | ||
|
||
#TODO(berry): Traefik | ||
|
||
volumes: | ||
app-db-data: |
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" |
Oops, something went wrong.