services:
    extraction-api-api:
        image: public.ecr.aws/microblink/blinkereceipt-self-hosted-api:1.14.1
        container_name: extraction-api-api
        networks:
            - extraction-api
        volumes:
            - ~/.aws:/root/.aws:ro
        ports:
            - 4001:4001
        environment:
            ROLE: API
            DB_HOST: extraction-api-db
            REDIS_HOST: extraction-api-redis
            AWS_PROFILE: mb-dev
        env_file:
            - .env.client
        depends_on:
            - extraction-api-redis
            - extraction-api-rabbitmq
            - populate-db

    extraction-api-worker:
        image: public.ecr.aws/microblink/blinkereceipt-self-hosted-api:1.14.1
        container_name: extraction-api-worker
        networks:
            - extraction-api
        volumes:
            - ~/.aws:/root/.aws:ro
        ports:
            - 3001:3001
        environment:
            ROLE: WORKER
            DB_HOST: extraction-api-db
            REDIS_HOST: extraction-api-redis
            AWS_PROFILE: mb-dev
        env_file:
            - .env.client
        depends_on:
            - extraction-api-redis
            - extraction-api-rabbitmq
            - populate-db

    extraction-api-rabbitmq:
      container_name: extraction-api-rabbitmq
      image: rabbitmq:4-management
      networks:
          - extraction-api
      ports:
        - 5672:5672
        - 15672:15672

    extraction-api-db:
        image: postgres:16.2-alpine
        container_name: extraction-api-db
        environment:
            POSTGRES_DB: ereceipt_extraction
            POSTGRES_USER: postgres
            POSTGRES_PASSWORD: postgres
        networks:
            - extraction-api
        ports:
            - 5433:5432

    extraction-api-redis:
        image: redis:alpine
        container_name: extraction-api-redis
        networks:
            - extraction-api
        ports:
            - 6379:6379

    migrate-db:
        image: public.ecr.aws/microblink/blinkereceipt-self-hosted-api:1.14.1
        container_name: migrate-db
        environment:
            ROLE: MIGRATE_DB
            DB_HOST: extraction-api-db
        env_file:
            - .env.client
        networks:
            - extraction-api
        depends_on:
            - extraction-api-db

    populate-db:
        image: public.ecr.aws/microblink/blinkereceipt-self-hosted-api:1.14.1
        container_name: populate-db
        environment:
            ROLE: UPDATE_CRON
            DB_HOST: extraction-api-db
        env_file:
            - .env.client
        networks:
            - extraction-api
        volumes:
            - ~/.aws:/root/.aws:ro
        depends_on:
            - migrate-db

networks:
    extraction-api:
