diff --git a/scripts/run/engine-postgres.sh b/scripts/run/engine-postgres.sh new file mode 100755 index 0000000000..317263034a --- /dev/null +++ b/scripts/run/engine-postgres.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)" + +if ! command -v nc >/dev/null 2>&1; then + echo "error: required command 'nc' not found." + exit 1 +fi + +if ! nc -z localhost 5432 >/dev/null 2>&1; then + echo "Postgres is not reachable at localhost:5432." + echo "Hint: run scripts/dev/run-postgres.sh to start the local Postgres container." + exit 1 +fi + +cd "${REPO_ROOT}" + +RIVET__POSTGRES__URL=postgres://postgres:postgres@localhost:5432/postgres \ +RUST_LOG=debug \ +cargo run --bin rivet-engine -- start "$@" diff --git a/scripts/run/postgres.sh b/scripts/run/postgres.sh new file mode 100755 index 0000000000..30acd498f1 --- /dev/null +++ b/scripts/run/postgres.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +set -euo pipefail + +CONTAINER_NAME="rivet-engine-postgres" +POSTGRES_IMAGE="postgres:17" + +if docker ps --all --format '{{.Names}}' | grep -qw "${CONTAINER_NAME}"; then + if docker ps --format '{{.Names}}' | grep -qw "${CONTAINER_NAME}"; then + docker stop "${CONTAINER_NAME}" >/dev/null 2>&1 || true + fi + docker rm "${CONTAINER_NAME}" >/dev/null 2>&1 || true +fi + +docker run \ + --detach \ + --name "${CONTAINER_NAME}" \ + --publish 5432:5432 \ + --env POSTGRES_PASSWORD=postgres \ + --env POSTGRES_USER=postgres \ + --env POSTGRES_DB=postgres \ + "${POSTGRES_IMAGE}"