version: '3.9'

services:
  db-init:
    image: postgres:17
    volumes:
      - ./blockscout-db-data:/var/lib/postgresql/data
    entrypoint:
      - sh
      - -c
      - |
        chown -R 2000:2000 /var/lib/postgresql/data

  db:
    image: postgres:17
    user: 2000:2000
    shm_size: 256m
    restart: always
    container_name: 'db'
    command: postgres -c 'max_connections=200' -c 'client_connection_check_interval=60000'
    environment:
        POSTGRES_DB: 'blockscout'
        POSTGRES_USER: 'blockscout'
        POSTGRES_PASSWORD: 'ceWb1MeLBEeOIfk65gU8EjF8'
    ports:
      - target: 5432
        published: 7432
    volumes:
      - ./blockscout-db-data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U blockscout -d blockscout"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 10s
