This repository has been archived on 2024-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
rotini/backend/script/provision-db
Marc Cataford 52cef95493
build(backend): ensure that test scripting returns an error code if s… (#28)
* build(backend): ensure that test scripting returns an error code if steps fail

* build(backend): wait for database to be ready before running migrations

* build(backend): extra sleep after successful healthcheck

* fix(backend): ensure that ci environment expects same DB port as test

* build(backend): better error handling in test script

* build(backend): remove arbitrary sleep
2023-08-19 12:08:24 -04:00

25 lines
684 B
Bash

#!/bin/bash
# Provisions a Postgres database locally.
#
# This is useful if you are not hosting your database instance
# elsewhere or want a simple setup for development purposes.
CONTAINER_NAME=rotini_db
docker run \
--name $CONTAINER_NAME \
-e POSTGRES_PASSWORD=$DATABASE_PASSWORD \
-e POSTGRES_USER=$DATABASE_USER \
-e POSTGRES_DB=$DATABASE_NAME \
-v $DATABASE_STORAGE_PATH:/var/lib/postgresql/data \
-p 5432:5432 \
-d \
postgres:15.4
until [ -n "$(docker exec $CONTAINER_NAME pg_isready | grep accepting)" ]; do
echo "Waiting for DB to come alive..."
sleep 0.1;
done;
PYTHONPATH=rotini .venv/bin/python rotini/migrations/migrate.py up