Skip to main content
The Daily Tracker API is designed to be deployed using Docker. This guide covers deployment to Render, but the Docker configuration can be used with any container platform.

Prerequisites

1

PostgreSQL Database

A PostgreSQL database must be provisioned before deployment. Recommended options:
2

Environment Variables

Prepare all required environment variables. See the Environment Variables guide for details.
3

Google OAuth Credentials

Set up OAuth 2.0 credentials in Google Cloud Console:
  1. Create a project
  2. Enable Google+ API
  3. Create OAuth 2.0 Client ID
  4. 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 stage
FROM eclipse-temurin:21-jdk-alpine AS build
WORKDIR /app
COPY pom.xml .
COPY .mvn ./.mvn
COPY mvnw .
RUN chmod +x mvnw && ./mvnw dependency:go-offline -q
COPY src ./src
RUN ./mvnw clean package -DskipTests -q

# Runtime stage
FROM eclipse-temurin:21-jre-alpine
WORKDIR /app
COPY --from=build /app/target/*.jar app.jar
EXPOSE 3000
ENTRYPOINT ["java", "-jar", "app.jar"]

Build and Run Locally

# Build the Docker image
docker build -t dailytracker-api .

Deploy to Render

Render provides a simple platform for deploying Docker-based applications.
1

Create Web Service

  1. Go to Render Dashboard
  2. Click New + > Web Service
  3. Connect your Git repository
  4. Select the repository containing your Daily Tracker API
2

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
3

Set Environment Variables

Add all required environment variables in the Render dashboard:
DATABASE_URL=your_postgres_connection_string
JWT_SECRET=your_secure_jwt_secret_32_chars
FRONTEND_URL=https://your-frontend-domain.com
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
AES_SECRET=your_aes_encryption_key
PORT=3000
4

Configure Health Check

Set the health check path to /healthz
  • Health Check Path: /healthz
  • Expected Response: 200 OK with body OK
5

Deploy

Click Create Web Service. Render will:
  1. Build your Docker image
  2. Run database migrations (Flyway)
  3. Start your application
  4. Expose it at https://your-service.onrender.com

Health Check Endpoint

The API includes a health check endpoint for monitoring:
GET /healthz
Response:
OK
This endpoint:
  • 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:
  1. Flyway connects to the database
  2. Creates the flyway_schema_history table if it doesn’t exist
  3. Runs any pending migrations from src/main/resources/db/migration/
  4. Marks migrations as complete
Migrations run automatically on deployment. No manual intervention is needed.
If a migration fails, the application will not start. Check logs for details.

Production Configuration

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
Adjust based on instance size and concurrent users.

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

DATABASE_URL=postgresql://localhost:5432/daily_scrum
JWT_SECRET=dev_secret_min_32_characters
FRONTEND_URL=http://localhost:5173
GOOGLE_CLIENT_ID=dev_client_id
GOOGLE_CLIENT_SECRET=dev_client_secret
AES_SECRET=dev_aes_secret
PORT=3000

Troubleshooting

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
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>
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_history table for failed migrations
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

Build docs developers (and LLMs) love