networks:
  medicine-network:
    external: true

volumes:
  postgres-data:
    name: medicine-postgres-data

services:
  postgres:
    image: postgres:15
    container_name: service-postgres
    restart: always
    shm_size: 1gb
    command: >
      postgres 
      -c shared_buffers=512MB 
      -c work_mem=4MB 
      -c max_connections=200
    networks:
      - medicine-network
    environment:
      POSTGRES_USER: ${MEDICINE_POSTGRES_USER:-postgres}
      POSTGRES_PASSWORD: ${MEDICINE_POSTGRES_PASSWORD:-password}
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready -U postgres" ]
      interval: 10s
      timeout: 5s
      retries: 5
    volumes:
      - postgres-data:/var/lib/postgresql/data
    logging:
      driver: "json-file"
      options:
        max-size: "5m"
        max-file: "5"
