services:
    platform:
        image: PLATFORM_IMAGE
        environment:
            POSTGRES_USER: preview
            POSTGRES_PASSWORD: preview
            POSTGRES_DB: preview
            MINIO_ROOT_USER: minioadmin
            MINIO_ROOT_PASSWORD: minioadmin
            ASSETS_UPLOAD_KEY: preview-different
            ASSETS_UPLOAD_SECRET_KEY: preview-different123
            ASSETS_STORAGE_ENDPOINT: https://${PULLPREVIEW_PUBLIC_DNS}/a
            FLAGS: uploads:off,invites:off,disabled-actions:http+email
            ENV_NAME: sandbox
            DATACITE_API_URL: https://api.test.datacite.org
            DATACITE_REPOSITORY_ID: DATACITE_REPOSITORY_ID
            DATACITE_PASSWORD: DATACITE_PASSWORD

    minio-init:
        restart: on-failure
        environment:
            MINIO_ROOT_USER: minioadmin
            MINIO_ROOT_PASSWORD: minioadmin
            ASSETS_UPLOAD_KEY: preview-different
            ASSETS_UPLOAD_SECRET_KEY: preview-different123

    minio:
        environment:
            MINIO_ROOT_USER: minioadmin
            MINIO_ROOT_PASSWORD: minioadmin
            MINIO_BROWSER_REDIRECT_URL: https://${PULLPREVIEW_PUBLIC_DNS}/assets-ui
        # volumes:
        #     - ./minio:/data
    platform-jobs:
        image: JOBS_IMAGE
    platform-migrations:
        image: MIGRATIONS_IMAGE
        restart: on-failure
        command: pnpm --filter core reset
    site-builder:
        image: SITE_BUILDER_IMAGE
        depends_on:
            - platform
            - platform-jobs
            - minio
        ports:
            - "4000:4000"
        restart: on-failure
        networks:
            - app-network
        environment:
            - PUBPUB_URL=http://platform:3000
            - S3_ENDPOINT=http://minio:9000
            - S3_REGION=us-east-1
            - S3_ACCESS_KEY=preview-different
            - S3_SECRET_KEY=preview-different123
            - S3_BUCKET_NAME=assets
            - PORT=4000

    caddy:
        image: caddy:latest
        restart: on-failure
        depends_on:
            - platform
            - platform-jobs
            - minio
        env_file: .env
        ports:
            - "443:443"
        volumes:
            - ./caddy:/etc/caddy
            - caddy-data:/data
            - caddy-config:/config
        networks:
            - app-network
