#!/bin/sh

# Starts a Postgres container using Apple's `container` tool:
# https://github.com/apple/container
#
# You'll need to use `container list` to find the new container's IP address in
# order to connect to it from the Phonograph server.

if ! (container volume ls | grep 'phono-pg'); then
  container volume create -s 2G phono-pg
fi
container run --name phono-pg \
  -e POSTGRES_USER=postgres \
  -e POSTGRES_PASSWORD=guest \
  -e PGDATA=/var/lib/postgresql/18/docker/pgdata \
  -v "$(realpath "$(dirname "$0")")/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d:ro" \
  -v phono-pg:/var/lib/postgresql/18/docker \
  postgres:18
