From 9ece756ee370d0227f7d883f1890dc16581b0bb7 Mon Sep 17 00:00:00 2001 From: "byte[]" <byteslice@airmail.cc> Date: Sat, 18 Mar 2023 16:13:39 -0400 Subject: [PATCH] Migrate to OpenSearch --- config/runtime.exs | 6 +++++- docker-compose.yml | 12 ++++++------ docker/app/run-development | 6 +++--- lib/philomena/elasticsearch.ex | 2 +- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/config/runtime.exs b/config/runtime.exs index 2c434e0b..7dcf8fbd 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -14,7 +14,7 @@ config :philomena, anonymous_name_salt: System.fetch_env!("ANONYMOUS_NAME_SALT"), hcaptcha_secret_key: System.fetch_env!("HCAPTCHA_SECRET_KEY"), hcaptcha_site_key: System.fetch_env!("HCAPTCHA_SITE_KEY"), - elasticsearch_url: System.get_env("ELASTICSEARCH_URL", "http://localhost:9200"), + opensearch_url: System.get_env("OPENSEARCH_URL", "https://admin:admin@localhost:9200"), advert_file_root: System.fetch_env!("ADVERT_FILE_ROOT"), avatar_file_root: System.fetch_env!("AVATAR_FILE_ROOT"), badge_file_root: System.fetch_env!("BADGE_FILE_ROOT"), @@ -90,6 +90,10 @@ config :philomena, :s3_secondary_options, config :philomena, :s3_secondary_bucket, System.get_env("ALT_S3_BUCKET") +# Don't bail on OpenSearch's self-signed certificate +config :elastix, + httpoison_options: [ssl: [verify: :verify_none]] + config :ex_aws, :hackney_opts, timeout: 180_000, recv_timeout: 180_000, diff --git a/docker-compose.yml b/docker-compose.yml index 0abee80f..7f859825 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '3' volumes: postgres_data: {} - elastic_data: {} + opensearch_data: {} services: app: @@ -27,7 +27,7 @@ services: - IMAGE_URL_ROOT=/img - BADGE_URL_ROOT=/badge-img - TAG_URL_ROOT=/tag-img - - ELASTICSEARCH_URL=http://elasticsearch:9200 + - OPENSEARCH_URL=https://admin:admin@opensearch:9200 - REDIS_HOST=redis - DATABASE_URL=ecto://postgres:postgres@postgres/philomena_dev - CDN_HOST=localhost @@ -46,7 +46,7 @@ services: - .:/srv/philomena depends_on: - postgres - - elasticsearch + - opensearch - redis postgres: @@ -58,10 +58,10 @@ services: logging: driver: "none" - elasticsearch: - image: elasticsearch:7.9.3 + opensearch: + image: opensearchproject/opensearch:2.6.0 volumes: - - elastic_data:/usr/share/elasticsearch/data + - opensearch_data:/usr/share/opensearch/data logging: driver: "none" environment: diff --git a/docker/app/run-development b/docker/app/run-development index 4e03fab9..73ec4f26 100755 --- a/docker/app/run-development +++ b/docker/app/run-development @@ -34,11 +34,11 @@ npm install # Always install mix dependencies (cd /srv/philomena && mix deps.get) -# Sleep to allow Elasticsearch to finish initializing +# Sleep to allow OpenSearch to finish initializing # if it's not done doing whatever it does yet -echo -n "Waiting for Elasticsearch" +echo -n "Waiting for OpenSearch" -until wget -qO - elasticsearch:9200; do +until wget --no-check-certificate -qO - https://admin:admin@opensearch:9200; do echo -n "." sleep 2 done diff --git a/lib/philomena/elasticsearch.ex b/lib/philomena/elasticsearch.ex index 68bf92e5..a85bfc50 100644 --- a/lib/philomena/elasticsearch.ex +++ b/lib/philomena/elasticsearch.ex @@ -30,7 +30,7 @@ defmodule Philomena.Elasticsearch do defp index_for(Filter), do: FilterIndex defp elastic_url do - Application.get_env(:philomena, :elasticsearch_url) + Application.get_env(:philomena, :opensearch_url) end def create_index!(module) do