version: '3.9'
services:
  postgresql_primary:
    image: postgres:16
    container_name: postgresql_primary
    environment:
      POSTGRES_PASSWORD: paperless123
      POSTGRES_DB: postgres
      POSTGRES_USER: postgres
    volumes:
      - pg_data:/var/lib/postgresql/data
    networks:
      - database-network
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 30s
      timeout: 10s
      retries: 5
      start_period: 60s
    restart: unless-stopped
    ports:
      - "5432:5432"

volumes:
  pg_data:
    driver: local

networks:
  database-network:
    external: true
