services:
  minio:
    image: "minio/minio:latest"
    ports:
      - "9000:9000"
      - "9001:9001"
    environment:
      MINIO_ROOT_USER: minio-user
      MINIO_ROOT_PASSWORD: minio-password
    entrypoint: >
      /bin/sh -c '
        isAlive() { curl -sf http://127.0.0.1:9000/minio/health/live; }    # check if Minio is alive
        minio $$0 "$$@" --quiet & echo $$! > /tmp/minio.pid                # start Minio in the background
        while ! isAlive; do sleep 0.1; done                                # wait until Minio is alive
        mc alias set minio http://127.0.0.1:9000 minio-user minio-password # setup Minio client
        mc mb minio/sendou || true                                         # create a test bucket
        mc anonymous set public minio/sendou                               # make the test bucket public
        kill -s INT $$(cat /tmp/minio.pid) && rm /tmp/minio.pid            # stop Minio
        while isAlive; do sleep 0.1; done                                  # wait until Minio is stopped
        exec minio $$0 "$$@"                                               # start Minio in the foreground
      '
    volumes:
      - ~/minio/data:/data
    command: server /data --console-address ":9001"

  skalop:
    image: ghcr.io/sendou-ink/skalop:latest
    pull_policy: always
    ports:
      - "5900:5900"
    environment:
      - REDIS_URL=${REDIS_URL}
      - SKALOP_TOKEN=${SKALOP_TOKEN}
      - SESSION_SECRET=${SESSION_SECRET}
      - PORT=5900
      - NODE_ENV=development
    depends_on:
      - redis
    restart: unless-stopped

  redis:
    image: redis:alpine
    restart: unless-stopped
