# Example of a full infrastructure stack
#
# Note, this file is not suitable for a production deployment. It is only an
# example of all the infrastructure components needed in a real production
# deployment.
#
# Usage::
#
#   $ docker-compose up -f docker-compose.full.yml -d
#
# Following services are included:
# - Frontend: Nginx (exposed ports: 40 and 443)
# - UI application: UWSGI (not exposed)
# - API application: UWSGI (not exposed)
# - Cache: Redis (exposed port: 6379)
# - DB: (PostgresSQL/MySQL) (exposed port: 5432 or 3306)
# - Message queue: RabbitMQ (exposed ports: 5672, 15672)
# - Search platform: (OpenSearch) (exposed ports: 9200, 9600)
# - OpenSearch Dashboard/Kibana (view OS/ES indexes) (exposed ports: 5601)
#
version: "2.2"
services:
    cache:
        extends:
            file: docker-services.yml
            service: cache
    db:
        extends:
            file: docker-services.yml
            service: db
    mq:
        extends:
            file: docker-services.yml
            service: mq
    search:
        extends:
            file: docker-services.yml
            service: search
    s3:
        extends:
            file: docker-services.yml
            service: s3
    # UI Application
    web-ui:
        extends:
            file: docker-services.yml
            service: app
        command: ["uwsgi /opt/invenio/var/instance/uwsgi_ui.ini"]
        image: am-d-model-data-repository:latest
        ports:
            - "5000"
        volumes:
            - static_data:/opt/invenio/var/instance/static

    # API Rest Application
    web-api:
        extends:
            file: docker-services.yml
            service: app
        command: ["uwsgi /opt/invenio/var/instance/uwsgi_rest.ini"]
        image: am-d-model-data-repository:latest
        ports:
            - "5000"

    # Worker
    worker:
        extends:
            file: docker-services.yml
            service: app
        command: ["celery -A invenio_app.celery worker --beat --loglevel=INFO"]
        image: am-d-model-data-repository:latest
        depends_on:
            search:
                condition: service_started
            cache:
                condition: service_started
            db:
                condition: service_started
            mq:
                condition: service_started
volumes:
    static_data:
    redis_data:
