# Wikibase for Federated Properties
#
version: '3'

services:
  wikibase:
    image: wikibase/wikibase:1.33-base
    container_name: wikibase
    hostname: wikibase
    links:
      - mysql
    ports:
     - "80:80"
    volumes:
      - {{ MW_PATH }}:/var/www/html
      - mediawiki-images-data:/var/www/html/images
    depends_on:
    - mysql
    restart: unless-stopped
    networks:
      default:
        aliases:
         - wikibase.svc
         - {{ SERVER_NAME }}
    environment:
      - DB_SERVER=mysql.svc:3306
      - MW_INSTALL_PATH=/var/www/html
      - MW_ADMIN_NAME=WikibaseAdmin
      - MW_ADMIN_PASS=${WIKI_ADMIN_PASSWORD}
      - MW_ADMIN_EMAIL=admin@example.com
      - MW_WG_SECRET_KEY=secretkey
      - DB_USER=wikiuser
      - DB_PASS=${MYSQL_PASSWORD}
      - DB_NAME=my_wiki
      - QS_PUBLIC_SCHEME_HOST_AND_PORT=http://localhost:9191

  mysql:
    image: mariadb:10.3
    container_name: mysql
    hostname: mysql
    restart: unless-stopped
    volumes:
      - mediawiki-mysql-data:/var/lib/mysql
    environment:
      MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
      MYSQL_DATABASE: 'my_wiki'
      MYSQL_USER: 'wikiuser'
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
    networks:
      default:
        aliases:
         - mysql.svc

  wdqs-frontend:
    image: wikibase/wdqs-frontend:latest
    container_name: wdqs-frontend
    hostname: wdqs-frontend
    restart: unless-stopped
    ports:
     - "8834:80"
    depends_on:
    - wdqs-proxy
    environment:
      - WIKIBASE_HOST={{ SERVER_NAME }}
      - WDQS_HOST=wdqs-proxy

  wdqs:
    image: wikibase/wdqs:latest
    container_name: wdqs
    hostname: wdqs
    volumes:
      - query-service-data:/wdqs/data
    tmpfs: /tmp
    environment:
      - WIKIBASE_HOST={{ SERVER_NAME }}
      - WDQS_HOST=wdqs
      - WDQS_PORT=9999
      - WDQS_ENTITY_NAMESPACES=120,122
      - WIKIBASE_SCHEME={{ SCHEME }}
    restart: unless-stopped
    command: /runBlazegraph.sh
    expose:
      - 9999

  wdqs-updater:
    image: wikibase/wdqs:latest
    container_name: wdqs-updater
    hostname: wdqs-updater
    restart: unless-stopped
    command: /runUpdate.sh
    depends_on:
      - wdqs
      - wikibase
    environment:
      - WIKIBASE_HOST={{ SERVER_NAME }}
      - WDQS_HOST=wdqs
      - WDQS_PORT=9999
      - WDQS_ENTITY_NAMESPACES=120,122

  wdqs-proxy:
    image: wikibase/wdqs-proxy
    container_name: wdqs-proxy
    hostname: wdqs-proxy
    restart: unless-stopped
    environment:
      - PROXY_PASS_HOST=wdqs:9999
    ports:
      - "8835:80"
    depends_on:
      - wdqs

  elasticsearch:
    image: docker-registry.wikimedia.org/dev/stretch-elasticsearch:0.1.0
    volumes:
      - esdata:/usr/share/elasticsearch/data
    environment:
      - discovery.type=single-node
    ports:
      - 9200
      - 9300

volumes:
  mediawiki-mysql-data:
  mediawiki-images-data:
  query-service-data:
  esdata:
      driver: local
