services:
  bangumi-vault:
    image: git.stdm.moe/stardream/bangumi-vault:latest
    # To build from source instead: comment out image above and uncomment below
    # build: .
    container_name: bangumi-vault
    depends_on:
      bangumi-vault-db:
        condition: service_healthy
    ports:
      - "8080:3000"
    volumes:
      - ./data/files:/data/files
    environment:
      PORT: "3000"
      TZ: Asia/Shanghai
      BANGUMI_VAULT_FILES_DIR: /data/files
      DATABASE_URL: postgres://bangumi_vault:bangumi_vault@bangumi-vault-db:5432/bangumi_vault
    restart: unless-stopped

  bangumi-vault-db:
    image: postgres:16-alpine
    container_name: bangumi-vault-db
    environment:
      POSTGRES_DB: bangumi_vault
      POSTGRES_USER: bangumi_vault
      POSTGRES_PASSWORD: bangumi_vault
    volumes:
      - ./data/postgres:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U bangumi_vault -d bangumi_vault"]
      interval: 5s
      timeout: 5s
      retries: 20
    restart: unless-stopped
