- Add docker-compose.sh wrapper script that auto-detects host IP - Update docker-compose.yml to use environment variable substitution - Update Supabase config.toml files to use HOST_SITE_URL and SUPABASE_API_URL env vars - Add scripts/get-host-ip.sh for IP detection - Add scripts/set-host-env.sh for environment setup - Add scripts/supabase-with-env.sh wrapper for Supabase CLI - Add documentation for Docker Compose environment setup - Update README.md with new usage instructions - Replace hardcoded URLs with dynamic environment variables
Supabase Database Module
This directory contains all Supabase configuration, migrations, and seed data for the USDA Vision project.
Structure
supabase/
├── config.toml # Supabase CLI configuration
├── migrations/ # Database migration files (run in order)
│ ├── 00001_extensions_and_utilities.sql
│ ├── 00002_users_and_roles.sql
│ └── ...
├── seed_01_users.sql # Initial user data
└── seed_02_phase2_experiments.sql # Initial experiment data
Usage
With Docker Compose (Recommended)
The Supabase containers are managed by the main docker-compose.yml at the project root. Migrations and seeds are automatically run on startup.
# From project root
docker compose up -d
With Supabase CLI
If you need to use Supabase CLI commands, run them from the project root (this directory's parent):
# From project root
cd /path/to/USDA-VISION
# Start Supabase (if not using docker-compose)
supabase start
# Run migrations manually
supabase db reset
# Generate types
supabase gen types typescript --local > management-dashboard-web-app/src/types/supabase.ts
Note: The Supabase CLI looks for the supabase/ directory in the current working directory. Since we've moved it to the root, you can now run Supabase commands from the project root instead of needing to cd into management-dashboard-web-app.
Migration Workflow
-
Create a new migration:
supabase migration new migration_name -
Apply migrations:
- Automatically via docker-compose on startup
- Manually:
supabase db reset(from project root)
-
Check migration status:
supabase migration list
Seed Data
Seed files are run automatically after migrations when using docker-compose. They populate the database with initial data:
seed_01_users.sql: Creates admin user and initial user profilesseed_02_phase2_experiments.sql: Creates initial experiment data
Configuration
The config.toml file contains all Supabase service configurations:
- Database port: 54322
- API port: 54321
- Studio port: 54323
- Inbucket (email testing): 54324
See config.toml for detailed configuration options.
Accessing Services
- Supabase Studio: http://localhost:54323
- API: http://localhost:54321
- Database:
postgresql://postgres:postgres@localhost:54322/postgres - Email Testing (Inbucket): http://localhost:54324
Best Practices
- Migrations are versioned: Always use numbered prefixes (e.g.,
00001_,00002_) - Migrations should be idempotent: Use
IF NOT EXISTSandCREATE OR REPLACEwhere possible - Test migrations locally: Always test migrations before committing
- Document breaking changes: Add notes in migration files for schema changes