From 5a3d3875b2b785e68adc14695d082aa77e1b48df Mon Sep 17 00:00:00 2001 From: sarayourfriend Date: Wed, 25 Sep 2024 13:58:26 -0600 Subject: [PATCH] Use Elasticsearch configuration file to avoid tricky environment variable names (#4992) It appears that there is no way to pass allow-origin as an environment variable, as ES will not recognise the same option with an underscore, and provides no method to map hyphens. The configuration file is much more searchable against the docs anyway. --- docker-compose.yml | 9 +++++++-- docker/es/elasticsearch.yml | 12 ++++++++++++ docker/es/env.docker | 14 -------------- 3 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 docker/es/elasticsearch.yml delete mode 100644 docker/es/env.docker diff --git a/docker-compose.yml b/docker-compose.yml index 43b9f98889d..628b315b58a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -94,8 +94,12 @@ services: image: docker.elastic.co/elasticsearch/elasticsearch:8.8.2 ports: - "50292:9200" - env_file: - - docker/es/env.docker + environment: + # Elasticsearch will reserve 50-60% of available system memory + # if left to its own devices. Setting this to half a GB is sufficient + # for local testing and prevent ES from hogging such a significant + # amount of system memory. + ES_JAVA_OPTS: "-Xms512m -Xmx512m" healthcheck: test: [ @@ -111,6 +115,7 @@ services: hard: 65536 volumes: - es-data:/usr/share/elasticsearch/data + - ./docker/es/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml volumes: api-postgres: diff --git a/docker/es/elasticsearch.yml b/docker/es/elasticsearch.yml new file mode 100644 index 00000000000..a46c3750ab9 --- /dev/null +++ b/docker/es/elasticsearch.yml @@ -0,0 +1,12 @@ +# Disable XPack +# https://www.elastic.co/guide/en/elasticsearch/reference/5.3/docker.html#_security_note +xpack.security.enabled: false + +discovery.type: single-node + +network.host: 0.0.0.0 +network.bind_host: 0.0.0.0 +network.publish_host: 0.0.0.0 + +http.cors.enabled: true +http.cors.allow-origin: "/.*/" diff --git a/docker/es/env.docker b/docker/es/env.docker deleted file mode 100644 index 0b6f252e828..00000000000 --- a/docker/es/env.docker +++ /dev/null @@ -1,14 +0,0 @@ -# Disable XPack -# https://www.elastic.co/guide/en/elasticsearch/reference/5.3/docker.html#_security_note -xpack.security.enabled="false" - -discovery.type="single-node" - -http.cors.enabled="true" -http.cors.allow-origin="/.*/" - -# Elasticsearch will reserve 50-60% of available system memory -# if left to its own devices. Setting this to half a GB is sufficient -# for local testing and prevent ES from hogging such a significant -# amount of system memory. -ES_JAVA_OPTS="-Xms512m -Xmx512m"