matimh.eu

Docker Compose Generator

app

db

db

docker-compose.yml

services:
  app:
    build: .
    restart: unless-stopped
    ports:
      - 3000:3000
    environment:
      NODE_ENV: production
      DATABASE_URL: postgres://app:change-me@db:5432/app
    depends_on:
      - db
  db:
    image: postgres:17-alpine
    restart: unless-stopped
    environment:
      POSTGRES_USER: app
      POSTGRES_PASSWORD: change-me
      POSTGRES_DB: app
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test:
        - CMD-SHELL
        - pg_isready -U app
      interval: 30s
      timeout: 5s
      retries: 3
volumes:
  pgdata:

change every change-me before starting; docker compose up -d. A volume name without ./ becomes a named volume, declared at the bottom.