feat: add configurability
This commit is contained in:
parent
89ea0995bb
commit
8257255dc2
10 changed files with 1406 additions and 26 deletions
|
|
@ -15,6 +15,9 @@ if ! [ -x "$(command -v sqlx)" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# instead of podman, docker could also be used instead
|
||||
CONTAINER_MANAGER="${CONTAINERIZER:=podman}"
|
||||
|
||||
DB_USER=${POSTGRES_USER:=postgres}
|
||||
DB_PASSWORD="${POSTGRES_PASSWORD:=password}"
|
||||
DB_NAME="${POSTGRES_DB:=newsletter}"
|
||||
|
|
@ -23,7 +26,7 @@ DB_PORT="${POSTGRES_PORT:=5432}"
|
|||
# Allow to skip container run if a containerized Postgres database is already running
|
||||
if [[ -z "${SKIP_DB_RUN}" ]]
|
||||
then
|
||||
podman run \
|
||||
${CONTAINER_MANAGER} run \
|
||||
-e POSTGRES_USER=${DB_USER} \
|
||||
-e POSTGRES_PASSWORD=${DB_PASSWORD} \
|
||||
-e POSTGRES_DB=${DB_NAME} \
|
||||
|
|
@ -39,7 +42,9 @@ done
|
|||
|
||||
>&2 echo "Postgres is up and running on port ${DB_PORT} - running migrations now!"
|
||||
|
||||
export DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@localhost:${DB_PORT}/${DB_NAME}
|
||||
DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@localhost:${DB_PORT}/${DB_NAME}
|
||||
|
||||
export DATABASE_URL
|
||||
sqlx database create
|
||||
sqlx migrate run
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue