A production-ready template for deploying PostgREST on DigitalOcean App Platform. Automatically generates a RESTful API from your PostgreSQL database schema.
PostgREST transforms your PostgreSQL database directly into a RESTful API. The database schema and permissions define the API endpoints automatically - no backend code required.
Use Cases: Rapid API development, database-first architecture, lightweight data layer for microservices.
What's Included:
- PostgREST Server (automatic REST API generation)
- PostgreSQL Database (managed by App Platform)
- Sample
todostable with working endpoints (/welcome,/todos,/todos_stats)
Click the Deploy to DigitalOcean button above for instant deployment with sample data.
Development (includes dev database with sample data):
git clone https://github.com/AppPlatform-Templates/postgrest-appplatform.git
cd postgrest-appplatform
doctl apps create --spec .do/app.yamlProduction (uses your existing database with autoscaling):
# 1. Create a PostgreSQL database
doctl databases create postgrest-db --engine pg --version 16 --region nyc3 --size db-s-1vcpu-1gb
# 2. Deploy the app
doctl apps create --spec .do/production-app.yamlYour API will be immediately functional with example endpoints at /welcome, /todos, and /todos_stats.
Production features: Autoscaling (1-3 instances), dedicated api schema, anon role for security.
To customize: Fork this repo, update the repo reference in your chosen template (.do/ folder) to point to your fork, then deploy.
# Optional: Create .env file for custom credentials
cp .env.example .env
# Start services
docker-compose up
# Access API at http://127.0.0.1:3000See LOCAL_DEVELOPMENT.md for API examples and troubleshooting.
The template includes a db-init PRE_DEPLOY job that initializes your database with:
- Sample
todostable with example data - Sample
todos_statsview - Required permissions
Files: config/init.sql (dev) or config/init.production.sql (production)
To customize: Edit these files to add your own tables, views, and functions. The init script runs on every deployment.
The db-init job is optional. To use an existing database with your own schema:
- Remove the jobs section from
.do/app.yamlor.do/production-app.yaml - Update environment variables:
PGRST_DB_SCHEMAS- your schema name(s)PGRST_DB_ANON_ROLE- database role for API access
- Deploy - PostgREST auto-generates endpoints from your schema
Note: Production databases should use dedicated schemas (not public) and roles (not default user) for security.
- PostgREST Documentation
- DigitalOcean App Platform Documentation
- App Spec Reference
- Local Development Guide
- GitHub Issues: Report bugs or request features
- DigitalOcean Community: community.digitalocean.com
- Support: DigitalOcean Support