Skip to main content
Budgetron provides a production-ready Docker image with a multi-stage build process that includes automated database migrations and health checks.

Quick Start

Building the Image

Build the Docker image from the project root:
To override the default port (3000) during build:

Running the Container

Run Budgetron with the minimum required environment variables:

Docker Architecture

Multi-Stage Build

The Dockerfile uses a four-stage build process for optimal image size and security:

Stage 0: Base Image

The base stage installs:
  • gcompat for compatibility with certain Node.js native modules
  • postgresql-client for the pg_isready health check utility

Stage 1: Dependencies

Installs all dependencies using pnpm with locked versions.

Stage 2: Builder

Builds the Next.js application in standalone mode and the Drizzle migration tooling, then removes dev dependencies.

Stage 3: Runtime

Creates the minimal runtime image with only production assets.

Container Startup Process

When the container starts, the entrypoint script (entrypoint.sh) performs the following sequence:

1. Database Health Check

Waits up to 30 seconds (configurable via MAX_WAIT environment variable) for the database to be ready.

2. Database Migration

Automatically applies all pending Drizzle ORM migrations.

3. Server Start

Starts the Next.js standalone server.

Port Configuration

Budgetron exposes port 3000 by default. You can customize this in two ways:

Build-time Configuration

Runtime Port Mapping

Map the container’s port 3000 to any host port.

Volume Mounts

Budgetron is stateless and doesn’t require persistent volumes. All data is stored in PostgreSQL. For local development with file watching, you can mount the source directory:

Environment Variables

See the complete list of environment variables in the configuration section.

Essential Variables

These must be provided at runtime:

Optional Variables

Configure additional features:

Docker Compose Example

While Budgetron doesn’t include a docker-compose.yml file, here’s a recommended setup:
Start the stack:
Pull the LLM model (if using Ollama):

Health Checks

Implement Docker health checks for better orchestration:
Add this to your Dockerfile or docker-compose.yml:

Image Registry

Budgetron publishes official Docker images to GitHub Container Registry:
Available tags:
  • latest - Latest stable release
  • v0.1.0 - Specific version
  • master - Latest commit on master branch

Troubleshooting

Container Exits Immediately

Check the database connection:
Look for database connection errors. Ensure DB_URL is correct and the database is accessible.

Migration Failures

If migrations fail, you can run them manually:

Permission Issues

The container runs as root by default. For better security, create a non-root user:
Add this before the CMD instruction in your Dockerfile.

Increase Database Wait Time

If your database takes longer to start:

Next Steps