Prerequisites
PostgreSQL Database
A PostgreSQL database must be provisioned before deployment. Recommended options:
- Neon (serverless PostgreSQL)
- Render PostgreSQL
- Supabase
- Any managed PostgreSQL service
Environment Variables
Prepare all required environment variables. See the Environment Variables guide for details.
Google OAuth Credentials
Set up OAuth 2.0 credentials in Google Cloud Console:
- Create a project
- Enable Google+ API
- Create OAuth 2.0 Client ID
- Add authorized redirect URI:
https://your-domain.com/auth/google/callback
Docker Configuration
The project includes a multi-stage Dockerfile optimized for production deployment.Dockerfile
Build and Run Locally
Deploy to Render
Render provides a simple platform for deploying Docker-based applications.Create Web Service
- Go to Render Dashboard
- Click New + > Web Service
- Connect your Git repository
- Select the repository containing your Daily Tracker API
Configure Service
Set the following configuration:
- Name:
dailytracker-api(or your preferred name) - Region: Choose closest to your users
- Branch:
main(or your production branch) - Runtime: Docker
- Instance Type: Starter or higher
Set Environment Variables
Add all required environment variables in the Render dashboard:
Required Variables
Required Variables
Optional Variables
Optional Variables
Configure Health Check
Set the health check path to
/healthz- Health Check Path:
/healthz - Expected Response: 200 OK with body
OK
Health Check Endpoint
The API includes a health check endpoint for monitoring:- Returns 200 status code when the application is running
- Does not require authentication
- Can be used by load balancers and monitoring tools
Database Migrations
The application automatically runs Flyway migrations on startup:- Flyway connects to the database
- Creates the
flyway_schema_historytable if it doesn’t exist - Runs any pending migrations from
src/main/resources/db/migration/ - Marks migrations as complete
Migrations run automatically on deployment. No manual intervention is needed.
Production Configuration
Recommended Settings
Instance Type
Minimum: 512 MB RAM, 0.5 CPURecommended: 1 GB RAM, 1 CPUScale based on traffic patterns.
Database Connection Pool
Default configuration:
- Max pool size: 5
- Min idle: 1
Auto-Deploy
Enable auto-deploy from your main branch for continuous deployment.
Monitoring
Use Render’s built-in metrics or integrate with:
- New Relic
- Datadog
- Custom APM solution
Environment-Specific Configuration
- Development
- Staging
- Production
Troubleshooting
Build Fails
Build Fails
Problem: Docker build fails during Maven compilationSolutions:
- Ensure Java 21 is specified in
pom.xml - Check for compilation errors in source code
- Verify all dependencies are available in Maven Central
Application Won't Start
Application Won't Start
Problem: Container starts but application crashesSolutions:
- Check environment variables are set correctly
- Verify database connection string format
- Ensure database is accessible from the container
- Check logs:
docker logs <container-id>
Migration Failures
Migration Failures
Problem: Flyway migrations fail on startupSolutions:
- Check database permissions (needs CREATE, ALTER, INSERT)
- Verify migration files are in
src/main/resources/db/migration/ - Ensure migrations follow naming convention:
V{version}__{description}.sql - Check
flyway_schema_historytable for failed migrations
Health Check Fails
Health Check Fails
Problem:
/healthz endpoint returns 404 or 500Solutions:- Verify application has fully started
- Check logs for startup errors
- Ensure port 3000 is exposed and mapped correctly
- Test locally:
curl http://localhost:3000/healthz
Next Steps
Environment Variables
Complete reference of all configuration options
Database Setup
Learn about the database schema and migrations
API Reference
Explore available endpoints
Authentication
Understand JWT and OAuth2 flows