This document explains how to set up and manage the local development environment for the COC-API project.
- Docker & Docker Compose: Ensure you have Docker installed and running.
- PostgreSQL Client (
pg_dump): Optional. The current local setup prefers loading a localseed/dump.sqlfile.pg_dumpis only required if you want to create a fresh dump from a remote database manually.
Copy the .env.example file to .env and fill in the required values:
cp .env.example .envKey variables for the setup script:
SESSION_POOLER: The direct connection string to your Supabase project (Session Pooler / IPv4).- Format:
postgresql://postgres.PROJECT_REF:PASSWORD@aws-0-us-east-1.pooler.supabase.com:5432/postgres
- Format:
The scripts/setup-local.sh script automates the local environment bring-up. By default it will load the local seed/dump.sql into the local Postgres instance.
bun run local- Starts Postgres: Launches the
dbcontainer. - Installs Extensions: Pre-installs
pgcrypto,uuid-ossp, andpg_stat_statementsinto thepublicschema. - Loads Local Seed: The script will attempt to load
seed/dump.sqlinto the DB only when there are no existing user tables present in the database. If the database already contains tables (non-system tables), the seed step will be skipped to avoid accidentally overwriting existing data. This is the default and recommended local flow. - Starts the API: Launches the
apicontainer and waits for it to be healthy.
Flags:
--skip-dump: reuse existingseed/dump.sql(no remote dump step)--skip-seed: skip loading the seed and just start containers
- Start environment:
bash scripts/setup-local.sh - Skip dump (reuse existing
seed/dump.sql):bash scripts/setup-local.sh --skip-dump - Skip seeding (just start containers):
bash scripts/setup-local.sh --skip-seed - View logs:
docker compose logs -f - Stop containers:
docker compose down - Wipe local data (force re-seed):
docker compose down -v
The script automatically patches the dump to ensure tables are placed in the public schema. If you manually imported a dump, ensure you've installed the required extensions first.