From 76d5e3aa450bc7bf8552398ed87926f0e5884536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Sat, 19 Oct 2024 15:35:20 +0200 Subject: [PATCH 1/7] Add dotenv support for ddev 1.23.5 Add the following variables: - OPENSEARCH_TAG -> defines the tag of the used opensearch image - INSTALL_PLUGIN_ANALYSIS_PHONETIC: boolean var - INSTALL_PLUGIN_ANALYSIS_ICU: boolean var docker-compose is now passing the args to the used Dockerfile --- docker-compose.opensearch.yaml | 8 +++++++- opensearch/Dockerfile | 15 +++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/docker-compose.opensearch.yaml b/docker-compose.opensearch.yaml index 4482911..8dd321a 100644 --- a/docker-compose.opensearch.yaml +++ b/docker-compose.opensearch.yaml @@ -2,7 +2,13 @@ services: opensearch: container_name: ddev-${DDEV_SITENAME}-opensearch - build: ./opensearch + build: + context: ./opensearch + dockerfile: Dockerfile + args: + OPENSEARCH_TAG: ${OPENSEARCH_TAG:-latest} + INSTALL_PLUGIN_ANALYSIS_PHONETIC: ${INSTALL_PLUGIN_ANALYSIS_PHONETIC:-true} + INSTALL_PLUGIN_ANALYSIS_ICU: ${INSTALL_PLUGIN_ANALYSIS_ICU:-true} expose: - 9200 environment: diff --git a/opensearch/Dockerfile b/opensearch/Dockerfile index 406b6c8..fa3f518 100644 --- a/opensearch/Dockerfile +++ b/opensearch/Dockerfile @@ -1,6 +1,13 @@ #ddev-generated -FROM opensearchproject/opensearch:latest +ARG OPENSEARCH_TAG=latest + +FROM opensearchproject/opensearch:${OPENSEARCH_TAG} + +ARG INSTALL_PLUGIN_ANALYSIS_PHONETIC=true +ARG INSTALL_PLUGIN_ANALYSIS_ICU=true + WORKDIR /usr/share/opensearch - -RUN bin/opensearch-plugin install analysis-phonetic -RUN bin/opensearch-plugin install analysis-icu + +# Install plugins +RUN if [ "${INSTALL_PLUGIN_ANALYSIS_PHONETIC}" = "true" ]; then bin/opensearch-plugin install analysis-phonetic; fi +RUN if [ "${INSTALL_PLUGIN_ANALYSIS_ICU}" = "true" ]; then bin/opensearch-plugin install analysis-icu; fi From 6c332285b7aa6879b65546dafc7ab5521fb8240d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Sat, 19 Oct 2024 15:58:13 +0200 Subject: [PATCH 2/7] Update readme and allow to define the dashboards version --- README.md | 22 +++++++++++++++++++++- docker-compose.opensearch.yaml | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f75baa4..f3eaa5b 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,29 @@ Update the file `.ddev/docker-compose.opensearch.yaml` for a compatible Dashboar ## Installation -1. Run `ddev get ddev/ddev-opensearch` to install the addon in your exiting DDEV project. +1. Run `ddev add-on get ddev/ddev-opensearch` to install the addon in your exiting DDEV project. 2. `ddev restart` to restart your project. +## Configuration + +To modify the build of the used OpenSearch image for the container there are dotenv variables available. + +- `OPENSEARCH_TAG` - The version of the OpenSearch image to use. Default: `latest` +- `OPENSEARCH_DASHBOARDS_TAG` - The version of the OpenSearch Dashboards image to use. Default: `latest` +- `INSTALL_PLUGIN_ANALYSIS_PHONETIC` - Install the analysis-phonetic plugin. Default: `true` +- `INSTALL_PLUGIN_ANALYSIS_ICU` - Install the analysis-icu plugin. Default: `true` + +Use the `ddev dotenv` command to set these variables. + +Example: + +```bash +ddev dotenv set .ddev/.env.opensearch \ + --opensearch-tag=2.15.0 \ + --opensearch-dashboards-tag=2.15.0 \ + --install-plugin-analytics-phonetic=false \ --install-plugin-analytics-icu=false +``` + ## Usage After installation, you can access the OpenSearch instance by visiting `https://.ddev.site:9201` (encrypted) or `http://.ddev.site:9200`. diff --git a/docker-compose.opensearch.yaml b/docker-compose.opensearch.yaml index 8dd321a..1b1af6e 100644 --- a/docker-compose.opensearch.yaml +++ b/docker-compose.opensearch.yaml @@ -36,7 +36,7 @@ services: test: ["CMD-SHELL", "curl --fail -s localhost:9200"] opensearch-dashboards: - image: opensearchproject/opensearch-dashboards:latest + image: opensearchproject/opensearch-dashboards:${OPENSEARCH_DASHBOARDS_TAG:-latest} container_name: 'ddev-${DDEV_SITENAME}-opensearch-dashboards' environment: - VIRTUAL_HOST=$DDEV_HOSTNAME From bc6937cec0946b0b3b012c052a4a58d9eda08331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Sat, 19 Oct 2024 16:12:21 +0200 Subject: [PATCH 3/7] Use new "ddev add-on" command in tests --- tests/test.bats | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test.bats b/tests/test.bats index b8343b6..7fbf67a 100644 --- a/tests/test.bats +++ b/tests/test.bats @@ -20,7 +20,7 @@ setup() { health_checks() { set +u # bats-assert has unset variables so turn off unset check - # ddev restart is required because we have done `ddev get` on a new service + # ddev restart is required because we have done `ddev add-on get` on a new service ddev restart # For debugging purposes @@ -43,8 +43,8 @@ teardown() { @test "install from directory" { set -eu -o pipefail cd ${TESTDIR} - echo "# ddev get ${DIR} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3 - ddev get ${DIR} + echo "# ddev add-on get ${DIR} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3 + ddev add-on get ${DIR} health_checks } From e4de43fbbfa8822b34de3b209d7845225124487f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Sat, 19 Oct 2024 16:12:39 +0200 Subject: [PATCH 4/7] chore: format bash code sample --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f3eaa5b..7db4449 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,8 @@ Example: ddev dotenv set .ddev/.env.opensearch \ --opensearch-tag=2.15.0 \ --opensearch-dashboards-tag=2.15.0 \ - --install-plugin-analytics-phonetic=false \ --install-plugin-analytics-icu=false + --install-plugin-analytics-phonetic=false \ + --install-plugin-analytics-icu=false ``` ## Usage From 9640623facf7850b6e1c2b8ed7847d0aa3952e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Sat, 19 Oct 2024 16:20:59 +0200 Subject: [PATCH 5/7] Use add-on get also in release test --- tests/test.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test.bats b/tests/test.bats index 7fbf67a..e7bedeb 100644 --- a/tests/test.bats +++ b/tests/test.bats @@ -51,7 +51,7 @@ teardown() { @test "install from release" { set -eu -o pipefail cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 ) - echo "# ddev get ${ADDON_PATH} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3 + echo "# ddev add-on get ${ADDON_PATH} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3 ddev get ${ADDON_PATH} health_checks } From e327589808fc48597f176d419c322989a0e9f2e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Sat, 19 Oct 2024 16:23:40 +0200 Subject: [PATCH 6/7] Add # bats test_tags=release --- tests/test.bats | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test.bats b/tests/test.bats index e7bedeb..dd19458 100644 --- a/tests/test.bats +++ b/tests/test.bats @@ -48,6 +48,7 @@ teardown() { health_checks } +# bats test_tags=release @test "install from release" { set -eu -o pipefail cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 ) From f253ff16415787c303439288f2ba6bf50dae9982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCnch?= Date: Sat, 19 Oct 2024 16:34:05 +0200 Subject: [PATCH 7/7] Update README.md Co-authored-by: Stanislav Zhuk --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 7db4449..3556e7c 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,16 @@ ddev dotenv set .ddev/.env.opensearch \ --opensearch-dashboards-tag=2.15.0 \ --install-plugin-analytics-phonetic=false \ --install-plugin-analytics-icu=false + +# rebuild opensearch image (required step) +ddev debug rebuild -s opensearch + +# remove old opensearch volume (if this is downgrade) +ddev stop +docker volume rm ddev-$(ddev status -j | docker run -i --rm ddev/ddev-utilities jq -r '.raw.name')_opensearch + +# and restart the project +ddev restart ``` ## Usage