wire postgres session repo, migrations, seed, and dev serve
This commit is contained in:
parent
02effe761a
commit
89b63cb9e9
8 changed files with 235 additions and 2 deletions
30
backend/bin/serve
Executable file
30
backend/bin/serve
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
||||
export PGDATA="${PGDATA:-$REPO_ROOT/.postgres}"
|
||||
export PGHOST="${PGHOST:-$PGDATA}"
|
||||
export PGUSER="${PGUSER:-postgres}"
|
||||
export PGDATABASE="${PGDATABASE:-rabbigerzi}"
|
||||
export DB_HOST="${DB_HOST:-127.0.0.1}"
|
||||
export DB_PORT="${DB_PORT:-5432}"
|
||||
export DB_NAME="${DB_NAME:-rabbigerzi}"
|
||||
export DB_USER="${DB_USER:-postgres}"
|
||||
export DB_PASSWORD="${DB_PASSWORD:-}"
|
||||
|
||||
echo "[serve] waiting for postgres..."
|
||||
until pg_isready -h "$PGHOST" -q 2>/dev/null; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "[serve] creating database if it does not exist..."
|
||||
createdb --no-password "$PGDATABASE" 2>/dev/null || echo "[serve] database already exists"
|
||||
|
||||
echo "[serve] running migrations..."
|
||||
php "$REPO_ROOT/backend/bin/migrate"
|
||||
|
||||
echo "[serve] seeding..."
|
||||
php "$REPO_ROOT/backend/bin/seed"
|
||||
|
||||
echo "[serve] starting PHP dev server..."
|
||||
exec php -S 127.0.0.1:8000 -t "$REPO_ROOT/backend/public/"
|
||||
Loading…
Add table
Add a link
Reference in a new issue