services:
  postgres:    
    image: postgres:latest
    container_name: postgres
    restart: always
    ports:
      - 5432:5432
    environment:
      POSTGRES_DB: ${POSTGRES_DB:-xiezhu} 
      POSTGRES_USER: ${POSTGRES_USER:-meta}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-Meta815899}
      TZ: Asia/Shanghai
      PGTZ: Asia/Shanghai
    volumes:
      - /var/lib/docker/volumes/postgresql:/var/lib/postgresql
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres -d ${POSTGRES_DB:-xiezhu}"]
      interval: 5s
      timeout: 5s
      retries: 10
      start_period: 10s

  pgadmin:
    image: dpage/pgadmin4
    container_name: pgadmin_container
    restart: always
    environment:
      PGADMIN_DEFAULT_EMAIL: admin@xiezhu.me
      PGADMIN_DEFAULT_PASSWORD: Meta815899
    ports:
      - 8081:80
    depends_on:
      - postgres