Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mnah05-boiler-go-21-79.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Boiler-Go includes a production-ready Docker Compose configuration for running PostgreSQL and Redis. You can containerize your application or use Docker only for infrastructure services.

Docker Compose configuration

The included docker-compose.yml provides two essential services:
version: "3.9"

services:

  postgres:
    image: postgres:16-alpine
    container_name: go_postgres
    restart: always
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: appdb
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 5s
      timeout: 5s
      retries: 5

  redis:
    image: redis:7-alpine
    container_name: go_redis
    restart: always
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    command: redis-server --appendonly yes

volumes:
  postgres_data:
  redis_data:

Quick start

1

Start infrastructure services

make dev
# or
docker-compose up -d
2

Run database migrations

make migrate-up
3

Start application services

# Terminal 1: Start API server
make api

# Terminal 2: Start background worker
make worker

Infrastructure services

PostgreSQL

Image: postgres:16-alpinePort: 5432Features:
  • Persistent data storage
  • Health check monitoring
  • Automatic restart on failure

Redis

Image: redis:7-alpinePort: 6379Features:
  • AOF persistence enabled
  • Persistent data storage
  • Automatic restart on failure

Data persistence

Docker volumes ensure data survives container restarts:
  • postgres_data: PostgreSQL database files
  • redis_data: Redis persistence files (AOF)
Deleting volumes will permanently erase all data. Use docker-compose down -v with caution.

Health checks

The PostgreSQL service includes built-in health monitoring:
healthcheck:
  test: ["CMD-SHELL", "pg_isready -U postgres"]
  interval: 5s
  timeout: 5s
  retries: 5
This ensures the database is ready before dependent services start.

Production deployment

Containerizing the application

Create a Dockerfile for your application:
FROM golang:1.25-alpine AS builder

WORKDIR /app

# Copy dependency files
COPY go.mod go.sum ./
RUN go mod download

# Copy source code
COPY . .

# Build binaries
RUN CGO_ENABLED=0 GOOS=linux go build -o /api ./cmd/api
RUN CGO_ENABLED=0 GOOS=linux go build -o /worker ./cmd/worker

# Production stage
FROM alpine:latest

RUN apk --no-cache add ca-certificates

WORKDIR /root/

# Copy binaries from builder
COPY --from=builder /api .
COPY --from=builder /worker .

# Copy migrations (if needed)
COPY migrations ./migrations

# Expose API port
EXPOSE 8080

# Default to API server (override for worker)
CMD ["./api"]

Multi-container setup

Extend docker-compose.yml to include application services:
services:
  api:
    build: .
    container_name: go_api
    restart: always
    ports:
      - "8080:8080"
    environment:
      DATABASE_URL: postgres://postgres:postgres@postgres:5432/appdb?sslmode=disable
      REDIS_ADDR: redis:6379
      REDIS_PASSWORD: ""
      REDIS_DB: 0
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_started

  worker:
    build: .
    container_name: go_worker
    restart: always
    command: ["./worker"]
    environment:
      DATABASE_URL: postgres://postgres:postgres@postgres:5432/appdb?sslmode=disable
      REDIS_ADDR: redis:6379
      REDIS_PASSWORD: ""
      REDIS_DB: 0
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_started
Notice the service names (postgres, redis) replace localhost in connection URLs when running inside Docker.

Common operations

View logs

# All services
docker-compose logs -f

# Specific service
docker-compose logs -f postgres
docker-compose logs -f redis

Stop services

# Stop but keep data
docker-compose down

# Stop and remove volumes (deletes all data)
docker-compose down -v

Restart services

# Restart all
docker-compose restart

# Restart specific service
docker-compose restart postgres

Access database

# Using docker exec
docker exec -it go_postgres psql -U postgres -d appdb

# Using psql from host (requires PostgreSQL client)
psql -h localhost -U postgres -d appdb

Access Redis CLI

# Using docker exec
docker exec -it go_redis redis-cli

# Using redis-cli from host (requires Redis client)
redis-cli -h localhost -p 6379

Production considerations

Security

  • Use strong passwords
  • Enable SSL for PostgreSQL
  • Use Redis AUTH
  • Don’t expose ports publicly
  • Use secrets management

Performance

  • Tune connection pool sizes
  • Monitor resource usage
  • Use appropriate restart policies
  • Enable Redis persistence
  • Regular backups

Networking

  • Use custom networks
  • Implement service discovery
  • Configure DNS properly
  • Use internal communication
  • Limit external exposure

Monitoring

  • Container health checks
  • Resource limits
  • Log aggregation
  • Metrics collection
  • Alert on failures

Next steps

Environment variables

Configure your application settings

Production checklist

Ensure production readiness