services:
    minio:
        image: minio/minio:RELEASE.2025-04-22T22-12-26Z
        healthcheck:
            test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/ready"]
            interval: 1m30s
            timeout: 30s
            retries: 5
            start_period: 30s
            # just spam the shit out of the healthcheck to make sure it's ready
            start_interval: 1s
        restart: unless-stopped
        command: server --console-address ":9001" /data
        ports:
            - "9000:9000" # API
            - "9001:9001" # Console

    minio-init:
        image: minio/mc:latest
        # basically what this does:
        # - create the bucket
        # - allow public downloads for said bucket
        # - add a new user
        # - allow said user to upload
        # this sadly can't be done by just configuring some env vars for minio itself, very annoying, you need to use their mc client. I'm not sure this is the best way to go about doing this.
        entrypoint: >
            /bin/sh -c '
            /usr/bin/mc alias set myminio http://minio:9000 "$${MINIO_ROOT_USER}" "$${MINIO_ROOT_PASSWORD}";
            /usr/bin/mc mb --ignore-existing myminio/"$${ASSETS_BUCKET_NAME}";
            /usr/bin/mc anonymous set download myminio/"$${ASSETS_BUCKET_NAME}";
            /usr/bin/mc admin user add myminio "$${ASSETS_UPLOAD_KEY}" "$${ASSETS_UPLOAD_SECRET_KEY}";
            /usr/bin/mc admin policy attach myminio readwrite --user "$${ASSETS_UPLOAD_KEY}";'

    db:
        image: postgres:15
        restart: always

    inbucket:
        image: inbucket/inbucket:latest
        restart: always
        ports:
            - "54324:9000"
            - "54325:2500"

    # cache
    cache:
        image: valkey/valkey:8-alpine
        restart: always
