From 7291096ef3168480f570e396f23e39548c51db79 Mon Sep 17 00:00:00 2001 From: Patrick Delcroix Date: Fri, 1 Nov 2024 16:03:11 +0100 Subject: [PATCH] updating ENV var --- .env.database.example | 0 .env.example | 6 ++---- .env.openSearch | 5 ----- .env.openSearch.example | 5 ++++- .env.redis | 4 ---- .env.redis.example | 2 +- compose.base.yml | 8 +++++++- compose.openSearch.yml | 11 ++++++++--- compose.yml | 9 ++++----- conf/redis/redis.conf | 0 deploy_openimis.sh | 21 +++++++++++---------- 11 files changed, 37 insertions(+), 34 deletions(-) create mode 100644 .env.database.example delete mode 100644 .env.openSearch delete mode 100644 .env.redis create mode 100644 conf/redis/redis.conf diff --git a/.env.database.example b/.env.database.example new file mode 100644 index 0000000..e69de29 diff --git a/.env.example b/.env.example index 6405fa9..5c20efa 100644 --- a/.env.example +++ b/.env.example @@ -4,6 +4,8 @@ PROJECT_NAME=demo # urls # url of openimis, FQDN DOMAIN=demo.openimis.org +# allowed host for CORS and CSFR, coma sepataed values +HOSTS=${DOMAIN} # http port for openimis HTTP_PORT=80 # https port for openimis @@ -50,7 +52,3 @@ DJANGO_LOG_HANDLER=debug-log # should the database be migrated at every container startup. Will be done anyway if $SITE_ROOT=api DJANGO_MIGRATE=True -OPENSEARCH_ADMIN=admin -OPENSEARCH_PASSWORD=B9wc9VrqX7pY -OPENSEARCH_HOSTS='http://opensearch:9200' -OPENSEARCH_DSL_AUTOSYNC=True \ No newline at end of file diff --git a/.env.openSearch b/.env.openSearch deleted file mode 100644 index bd5d921..0000000 --- a/.env.openSearch +++ /dev/null @@ -1,5 +0,0 @@ -DISCOVERY_TYPE=single-node -CLUSTER_NAME=my_opensearch_cluster -OPEN_SEARCH_HTTP_PORT=9200 -SLL_HTTP_ENABLED=false -OPENSEARCH_HOSTS='["http://opensearch:9200"]' diff --git a/.env.openSearch.example b/.env.openSearch.example index bd5d921..63a7dea 100644 --- a/.env.openSearch.example +++ b/.env.openSearch.example @@ -2,4 +2,7 @@ DISCOVERY_TYPE=single-node CLUSTER_NAME=my_opensearch_cluster OPEN_SEARCH_HTTP_PORT=9200 SLL_HTTP_ENABLED=false -OPENSEARCH_HOSTS='["http://opensearch:9200"]' +OPENSEARCH_ADMIN=admin +OPENSEARCH_PASSWORD=B9wc9VrqX7pY +OPENSEARCH_HOSTS='opensearch:9200' +OPENSEARCH_DSL_AUTOSYNC=True \ No newline at end of file diff --git a/.env.redis b/.env.redis deleted file mode 100644 index 88c34c7..0000000 --- a/.env.redis +++ /dev/null @@ -1,4 +0,0 @@ -REDIS_PASSWORD=redisUserPass123 -CACHE_BACKEND=django.core.cache.backends.redis.RedisCache -CACHE_URL=redis://:redisUserPass123@redis:6379 -CACHE_OPTIONS={} \ No newline at end of file diff --git a/.env.redis.example b/.env.redis.example index 88c34c7..c5498ba 100644 --- a/.env.redis.example +++ b/.env.redis.example @@ -1,4 +1,4 @@ REDIS_PASSWORD=redisUserPass123 CACHE_BACKEND=django.core.cache.backends.redis.RedisCache -CACHE_URL=redis://:redisUserPass123@redis:6379 +CACHE_URL=redis://:${REDIS_PASSWORD}@redis:6379 CACHE_OPTIONS={} \ No newline at end of file diff --git a/compose.base.yml b/compose.base.yml index 94887ff..6405567 100644 --- a/compose.base.yml +++ b/compose.base.yml @@ -12,7 +12,13 @@ x-api: &default-api - SITE_URL=${DOMAIN} - CELERY_BROKER_URL=amqp://rabbitmq - MODE=${MODE:-Prod} - - CSRF_TRUSTED_ORIGINS=https://${DOMAIN} + - HOSTS=${HOSTS} + - CACHE_BACKEND=${CACHE_BACKEND} + - CACHE_URL=${CACHE_URL} + - CACHE_OPTIONS=${CACHE_OPTIONS} + - OPENSEARCH_ADMIN=${OPENSEARCH_ADMIN} + - OPENSEARCH_PASSWORD=${OPENSEARCH_PASSWORD} + - OPENSEARCH_HOSTS=${OPENSEARCH_HOSTS} volumes: - photos:/openimis-be/openIMIS/images/insurees depends_on: diff --git a/compose.openSearch.yml b/compose.openSearch.yml index a4f0574..ff4f267 100644 --- a/compose.openSearch.yml +++ b/compose.openSearch.yml @@ -1,9 +1,8 @@ #version: '3.7' services: + opensearch: - build: - context: . - dockerfile: ./opensearch-configuration/Dockerfile-openSearch-dev- + image: opensearchproject/opensearch:latest env_file: - ".env.openSearch" environment: @@ -12,6 +11,12 @@ services: - "http.port=${OPEN_SEARCH_HTTP_PORT:-9200}" - "plugins.security.ssl.http.enabled=${SLL_HTTP_ENABLED:-false}" - "plugins.security.disabled=true" + - "OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_PASSWORD}" + options: >- + --health-cmd "curl -f -u admin:${OPENSEARCH_INITIAL_ADMIN_PASSWORD} http://localhost:9200/_cluster/health || exit 1" + --health-interval 10s + --health-timeout 5s + --health-retries 10 volumes: - "opensearch-data1:/usr/share/opensearch/data" networks: diff --git a/compose.yml b/compose.yml index 3985ad3..71b5863 100644 --- a/compose.yml +++ b/compose.yml @@ -2,15 +2,14 @@ include: - path: docker-compose.${DB_DEFAULT:-postgresql}.yml env_file: .env - path: docker-compose.base.yml - env_file: .env + env_file: + - .env + - .env.redis + - .env.openSearch - path: docker-compose.openSearch.yml env_file: - .env - .env.openSearch - - path: docker-compose.lightning.yml - env_file: - - .env - - .env.lightning - path: docker-compose.cache.yml env_file: - .env diff --git a/conf/redis/redis.conf b/conf/redis/redis.conf new file mode 100644 index 0000000..e69de29 diff --git a/deploy_openimis.sh b/deploy_openimis.sh index 57c4af6..1fc5dd4 100644 --- a/deploy_openimis.sh +++ b/deploy_openimis.sh @@ -6,8 +6,9 @@ echo "Using existing env files" else echo "creating env files from example" cp .env.example .env -cp .env.lightning.example .env.lightning +cp .env.redis.example .env.redis cp .env.openSearch.example .env.openSearch +cp .env.database.example .env.database fi @@ -18,15 +19,15 @@ else echo "initialisation" docker compose up -d db -#set -a # automatically export all variables -source .env -source .env.lightning -#set +a -docker compose run -e PGPASSWORD=${POSTGRES_PASSWORD} --rm db createdb -h db -U ${POSTGRES_USER} ${POSTGRES_DB} -set -e -docker compose run --rm web mix ecto.migrate -docker compose run --rm web mix run imisSetupScripts/imisSetup.exs -#TODO init OpenSearch dashboard with API/ manage command +# #set -a # automatically export all variables +# source .env +# source .env.lightning +# #set +a +# docker compose run -e PGPASSWORD=${POSTGRES_PASSWORD} --rm db createdb -h db -U ${POSTGRES_USER} ${POSTGRES_DB} +# set -e +# docker compose run --rm web mix ecto.migrate +# docker compose run --rm web mix run imisSetupScripts/imisSetup.exs +# #TODO init OpenSearch dashboard with API/ manage command echo "connect to https://{DOMAIN}" echo "then go to https://{DOMAIN}/opensearch" echo "then go in manage / saved object / import to import the OpenSearch dashboard"