diff --git a/docker/conf/search-memory.yml b/docker/conf/search-memory.yml new file mode 100644 --- /dev/null +++ b/docker/conf/search-memory.yml @@ -0,0 +1,2 @@ +search: + cls: memory diff --git a/docker/conf/web-keycloak.yml b/docker/conf/web-keycloak.yml --- a/docker/conf/web-keycloak.yml +++ b/docker/conf/web-keycloak.yml @@ -60,7 +60,12 @@ limiter_rate: default: 120/h -search: {} +search: + cls: remote + url: http://swh-search:5010/ + +search_config: + metadata_backend: swh-search keycloak: server_url: http://keycloak:8080/keycloak/auth/ diff --git a/docker/conf/web-mirror.yml b/docker/conf/web-mirror.yml --- a/docker/conf/web-mirror.yml +++ b/docker/conf/web-mirror.yml @@ -40,4 +40,12 @@ name: swh-web user: postgres password: testpassword + +search: + cls: remote + url: http://swh-search:5010/ + +search_config: + metadata_backend: swh-search + instance_name: archive-docker.softwareheritage.org diff --git a/docker/conf/web-read-replica.yml b/docker/conf/web-read-replica.yml --- a/docker/conf/web-read-replica.yml +++ b/docker/conf/web-read-replica.yml @@ -66,5 +66,11 @@ exempted_networks: - 0.0.0.0/0 -search: {} +search: + cls: remote + url: http://swh-search:5010/ + +search_config: + metadata_backend: swh-search + instance_name: archive-docker.softwareheritage.org diff --git a/docker/conf/web-search.yml b/docker/conf/web-search.yml deleted file mode 100644 --- a/docker/conf/web-search.yml +++ /dev/null @@ -1,76 +0,0 @@ -storage: - cls: remote - url: http://swh-storage:5002/ - timeout: 5 - -indexer_storage: - cls: remote - url: http://swh-idx-storage:5007/ - -scheduler: - cls: remote - url: http://swh-scheduler:5008/ - -vault: - cls: remote - url: http://swh-vault:5005/ - -deposit: - private_api_url: http://swh-deposit:5006/1/private/ - private_api_user: swhworker - private_api_password: "" - -allowed_hosts: - - "*" - -debug: yes - -serve_assets: yes - -development_db: /tmp/swh/web.sqlite3 - -production_db: - name: postgresql:///?service=swh-web - -throttling: - cache_uri: memcache:11211 - scopes: - swh_api: - limiter_rate: - default: 120/h - exempted_networks: - - 0.0.0.0/0 - swh_api_origin_search: - limiter_rate: - default: 70/m - exempted_networks: - - 0.0.0.0/0 - swh_api_origin_visit_latest: - limiter_rate: - default: 700/m - exempted_networks: - - 0.0.0.0/0 - swh_vault_cooking: - limiter_rate: - default: 120/h - exempted_networks: - - 0.0.0.0/0 - swh_save_origin: - limiter_rate: - default: 120/h - exempted_networks: - - 0.0.0.0/0 -instance_name: archive-docker.softwareheritage.org - -search: - cls: remote - url: http://swh-search:5010/ - -search_config: - metadata_backend: swh-search - -counters: - cls: remote - url: http://swh-counters:5011/ -counters_backend: swh-counters -history_counters_url: http://swh-counters:5011/counters_history/history.json diff --git a/docker/conf/web.yml b/docker/conf/web.yml --- a/docker/conf/web.yml +++ b/docker/conf/web.yml @@ -63,7 +63,12 @@ instance_name: archive-docker.softwareheritage.org -search: {} +search: + cls: remote + url: http://swh-search:5010/ + +search_config: + metadata_backend: swh-search counters: cls: remote diff --git a/docker/docker-compose.search.yml b/docker/docker-compose.search.yml --- a/docker/docker-compose.search.yml +++ b/docker/docker-compose.search.yml @@ -14,54 +14,10 @@ - elasticsearch-data:/usr/share/elasticsearch/data swh-search: - image: swh/stack - build: ./ - entrypoint: /entrypoint.sh - ports: - - 5010:5010 depends_on: - elasticsearch - environment: - SWH_CONFIG_FILENAME: /search.yml - env_file: - - ./env/common_python.env volumes: - "./conf/search.yml:/search.yml:ro" - - "./services/swh-search/entrypoint.sh:/entrypoint.sh:ro" - - swh-search-journal-client-objects: - image: swh/stack - build: ./ - entrypoint: /entrypoint.sh - depends_on: - kafka: - condition: service_healthy - swh-search: - condition: service_started - volumes: - - "./conf/search_journal_client_objects.yml:/etc/softwareheritage/search/journal_client.yml:ro" - - "./services/swh-search-journal-client/entrypoint.sh:/entrypoint.sh:ro" - - swh-search-journal-client-indexed: - image: swh/stack - build: ./ - entrypoint: /entrypoint.sh - depends_on: - kafka: - condition: service_healthy - swh-search: - condition: service_started - volumes: - - "./conf/search_journal_client_indexed.yml:/etc/softwareheritage/search/journal_client.yml:ro" - - "./services/swh-search-journal-client/entrypoint.sh:/entrypoint.sh:ro" - - swh-web: - depends_on: - - swh-search - environment: - SWH_CONFIG_FILENAME: /web-search.yml - volumes: - - "./conf/web-search.yml:/web-search.yml:ro" volumes: elasticsearch-data: diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -348,6 +348,7 @@ - swh-scheduler - swh-storage - swh-web-db + - swh-search - memcache env_file: - ./env/common_python.env @@ -657,6 +658,48 @@ - "./conf/counters_journal_client.yml:/etc/softwareheritage/counters/journal_client.yml:ro" - "./services/swh-counters-journal-client/entrypoint.sh:/entrypoint.sh:ro" + # Search related + + swh-search: + image: swh/stack + build: ./ + entrypoint: /entrypoint.sh + ports: + - 5010:5010 + environment: + SWH_CONFIG_FILENAME: /search.yml + env_file: + - ./env/common_python.env + volumes: + - "./conf/search-memory.yml:/search.yml:ro" + - "./services/swh-search/entrypoint.sh:/entrypoint.sh:ro" + + swh-search-journal-client-objects: + image: swh/stack + build: ./ + entrypoint: /entrypoint.sh + depends_on: + kafka: + condition: service_healthy + swh-search: + condition: service_started + volumes: + - "./conf/search_journal_client_objects.yml:/etc/softwareheritage/search/journal_client.yml:ro" + - "./services/swh-search-journal-client/entrypoint.sh:/entrypoint.sh:ro" + + swh-search-journal-client-indexed: + image: swh/stack + build: ./ + entrypoint: /entrypoint.sh + depends_on: + kafka: + condition: service_healthy + swh-search: + condition: service_started + volumes: + - "./conf/search_journal_client_indexed.yml:/etc/softwareheritage/search/journal_client.yml:ro" + - "./services/swh-search-journal-client/entrypoint.sh:/entrypoint.sh:ro" + volumes: redis-data: storage-data: diff --git a/docker/services/swh-search/entrypoint.sh b/docker/services/swh-search/entrypoint.sh --- a/docker/services/swh-search/entrypoint.sh +++ b/docker/services/swh-search/entrypoint.sh @@ -11,14 +11,17 @@ ;; *) echo Starting the swh-search API server - wait-for-it elasticsearch:9200 -s --timeout=0 - echo "Waiting for ElasticSearch cluster to be up" - cat << EOF | python3 + if grep -q elasticsearch $SWH_CONFIG_FILENAME; + then + wait-for-it elasticsearch:9200 -s --timeout=0 + echo "Waiting for ElasticSearch cluster to be up" + cat << EOF | python3 import elasticsearch es = elasticsearch.Elasticsearch(['elasticsearch:9200']) es.cluster.health(wait_for_status='yellow') EOF - echo "ElasticSearch cluster is up" + echo "ElasticSearch cluster is up" + fi swh search -C $SWH_CONFIG_FILENAME initialize exec gunicorn --bind 0.0.0.0:5010 \ --reload \