# 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
    networks:
      - am-d-model-repo-network
  db:
    extends:
      file: docker-services.yml
      service: db
    networks:
      - am-d-model-repo-network
  mq:
    extends:
      file: docker-services.yml
      service: mq
  search:
    extends:
      file: docker-services.yml
      service: search
    networks:
      - am-d-model-repo-network
  s3:
    extends:
      file: docker-services.yml
      service: s3
    networks:
      - am-d-model-repo-network
  # Frontend
  frontend:
    extends:
      file: docker-services.yml
      service: frontend
    volumes:
      - static_data:/opt/invenio/var/instance/static
    depends_on:
      - web-ui
      - web-api
    # ports:
    #   - "80:80"
    #   - "443:443"
    networks:
      - am-d-model-repo-network
  # 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
    networks:
      - am-d-model-repo-network

  # 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"
    networks:
      - am-d-model-repo-network

  # 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
    networks:
      - am-d-model-repo-network
networks:
    am-d-model-repo-network:
        name: am-d-model-repo-network
volumes:
    static_data:
    data:
    redis_data:
