name: fastproof

services:
  postgres:
    image: docker.io/library/postgres:18.7-trixie
    environment:
      POSTGRES_USER: fastproof
      POSTGRES_PASSWORD: fastproof
      POSTGRES_DB: fastproof
    volumes:
      - postgres:/var/lib/postgresql
    healthcheck:
      test: ["CMD", "pg_isready", "-U", "fastproof"]
      interval: 5s
      timeout: 5s
      retries: 20

  garage:
    image: docker.io/dxflrs/garage:v2.5.0
    command: ["/garage", "server", "--single-node", "--default-bucket"]
    environment:
      GARAGE_CONFIG_FILE: /etc/garage/garage.toml
      GARAGE_RPC_SECRET: ${GARAGE_RPC_SECRET:?set GARAGE_RPC_SECRET in .env}
      GARAGE_DEFAULT_ACCESS_KEY: ${S3_ACCESS_KEY:?set S3_ACCESS_KEY in .env}
      GARAGE_DEFAULT_SECRET_KEY: ${S3_SECRET_KEY:?set S3_SECRET_KEY in .env}
      GARAGE_DEFAULT_BUCKET: fastproof
    volumes:
      - ./garage.toml:/etc/garage/garage.toml:ro
      - garage:/var/lib/garage

  fastproof:
    image: docker.io/franshub/fastproof:0.1.0-dev1
    depends_on:
      postgres:
        condition: service_healthy
      garage:
        condition: service_started
    ports:
      - "127.0.0.1:8080:8080"
      - "127.0.0.1:9090:9090"
    environment:
      FASTPROOF_PUBLIC_URL: http://localhost:8080
      FASTPROOF_DATABASE_URL: postgres://fastproof:fastproof@postgres:5432/fastproof
      FASTPROOF_BLOB_BACKEND: s3
      FASTPROOF_S3_ENDPOINT: http://garage:3900
      FASTPROOF_S3_REGION: garage
      FASTPROOF_S3_BUCKET: fastproof
      FASTPROOF_S3_ACCESS_KEY: ${S3_ACCESS_KEY}
      FASTPROOF_S3_SECRET_KEY: ${S3_SECRET_KEY}
      FASTPROOF_ADMIN_TOKENS_FILE: /run/secrets/admin-tokens
      FASTPROOF_LOG_FORMAT: text
    secrets:
      - admin-tokens

secrets:
  admin-tokens:
    file: ./admin-tokens

volumes:
  postgres:
  garage:
