From 3335b46eafdb5f061c453e11e2371c66392a7576 Mon Sep 17 00:00:00 2001 From: Damian Borowiecki Date: Mon, 25 Sep 2023 12:15:58 +0200 Subject: [PATCH 1/7] Restore previous lightning setup --- .env.lightning.example | 9 ++++---- docker-compose.lightning.yml | 40 ++++++++++++------------------------ 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/.env.lightning.example b/.env.lightning.example index 91eaf14..11aef90 100644 --- a/.env.lightning.example +++ b/.env.lightning.example @@ -23,7 +23,7 @@ MAX_RUN_DURATION=20000 # Those postgres credentials should match ones in .env for imis database -POSTGRES_USER=IMISUser +POSTGRES_USER=IMISuser POSTGRES_PASSWORD=IMISuserP@s POSTGRES_HOST=db @@ -49,8 +49,9 @@ IMIS_USER_FIRST_NAME=IMISUser IMIS_USER_LAST_NAME=IMISUser IMIS_USER_PASSWORD=IMISUserPassword IMIS_USER_EMAIL=IMISUser@openimis.com + IMIS_DB_HOST=db -IMIS_DB_PORT=5439 +IMIS_DB_PORT=5432 IMIS_DB_DATABASE=IMIS -IMIS_DB_USER=IMISUser -IMIS_DB_PASSWORD=IMISUserPassword +IMIS_DB_USER=IMISuser +IMIS_DB_PASSWORD=IMISuserP@s diff --git a/docker-compose.lightning.yml b/docker-compose.lightning.yml index 0743ab2..37487cb 100644 --- a/docker-compose.lightning.yml +++ b/docker-compose.lightning.yml @@ -1,39 +1,28 @@ -version: "3" +version: "2.4" x-lightning: &default-app build: dockerfile: Dockerfile-dev- context: "https://github.com/openimis/openimis-lightning_dkr.git#develop" - target: "${MIX_ENV:-dev}" args: - "MIX_ENV=${MIX_ENV:-dev}" - "NODE_ENV=${NODE_ENV:-development}" - depends_on: - - "postgres" + ports: + - "4000:4000" env_file: - - ".env" + - ".env.lightning" restart: "${DOCKER_RESTART_POLICY:-unless-stopped}" stop_grace_period: "3s" - tty: ${TTY:-false} + tty: false volumes: - "${LIGHTNING_VOLUME:-./priv/static:/app/priv/static}" + networks: + openimis-net: -services: - postgres: - deploy: - resources: - limits: - cpus: "${DOCKER_POSTGRES_CPUS:-0}" - memory: "${DOCKER_POSTGRES_MEMORY:-0}" - env_file: - - ".env" - image: "postgres:14.2-alpine" - restart: "${DOCKER_RESTART_POLICY:-unless-stopped}" - stop_grace_period: "3s" - volumes: - - "postgres:/var/lib/postgresql/data" - web: + +services: + lightning: <<: *default-app deploy: resources: @@ -46,12 +35,9 @@ services: timeout: "3s" start_period: "5s" retries: 3 - ports: - - "${LIGHTNING_EXTERNAL_PORT:-127.0.0.1:4000}:${URL_PORT}" - -volumes: - postgres: {} + depends_on: + - db networks: openimis-net: - name: ${PROJECT_NAME}-openimis-net + name: ${PROJECT_NAME:-openimis}-net From ad9c31a176a47168e3501083d350d2e31b80fc98 Mon Sep 17 00:00:00 2001 From: Damian Borowiecki Date: Mon, 25 Sep 2023 12:44:20 +0200 Subject: [PATCH 2/7] Added extra service for lightnign engine --- .env.example | 55 ------------------------------------ README.md | 6 ++-- docker-compose.lightning.yml | 23 ++++++++++++++- 3 files changed, 25 insertions(+), 59 deletions(-) delete mode 100644 .env.example diff --git a/.env.example b/.env.example deleted file mode 100644 index c15f2bb..0000000 --- a/.env.example +++ /dev/null @@ -1,55 +0,0 @@ -# docker-compose parameters -# docker compose project name -PROJECT_NAME=demo -# urls -# url of openimis, FQDN -NEW_OPENIMIS_HOST=demo.openimis.org -# http port for openimis -HTTP_PORT=80 -# https port for openimis -HTTPS_PORT=443 - -# Uncomment the line below to intiate the database with the DEMO dataset, it will create an empty openIMIS database otherwise -#INIT_MODE=demo -DB_PASSWORD=IMISuserP@s -DB_USER=IMISuser -DB_NAME=IMIS -#MSSQL configuration comment DB_ENGINE=django.db.backends.postgresql and DB_PORT=5432, uncomment DB_ENGINE=mssql and ACCEPT_EULA (= y if you accept MS EULA) DB_PORT=1433 -# database parameters -DB_HOST=db -# msssql port -#DB_PORT=1433 -# psql port -DB_PORT=5432 -#psql engine -DB_ENGINE=django.db.backends.postgresql -#mssql engine -#DB_ENGINE=mssql -#ACCEPT_EULA= -GATEWAY_PORT_S=443 -# site root for backend -SITE_ROOT=api - -# github branches to use -# Database, you can use develop branch too -DB_TAG=23.04 -# BE assembly image tag -BE_TAG=23.04 -#FE assembly, image tag -FE_TAG=23.04 -# REST API, image tag -RESTAPI_TAG=23.04 -# rest API flavours -RESTAPI_BUILD_FLAVOR=Release - -#one-liner json config for the FE (to override the openimis.json from the FE assembly) -#OPENIMIS_FE_CONF_JSON= -#one-liner json config for the FE (to overright the openimis.json from the FE assembly) -#OPENIMIS_FE_CONF_JSON= - -# django log level -DJANGO_LOG_LEVEL=WARNING -# django log handler (currently: degub-log (default), db-queries, console) -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 diff --git a/README.md b/README.md index 6044d18..7c0cbdc 100644 --- a/README.md +++ b/README.md @@ -42,9 +42,9 @@ Lightning is not by default enabled in dockerized instance. To make it work it's * Copy `.env.lightning.example` to `.env.lightning` and make adjustments * Create `lightning_dev` database in db container * Run container build `docker compose -f docker-compose.yml -f docker-compose.lightning.yml build lightning` - * Run migrations `docker compose -f docker-compose.yml -f docker-compose.lightning.yml run --rm lightning mix ecto.migrate` - * Run imis demo setup `docker compose -f docker-compose.yml -f docker-compose.lightning.yml run --rm lightning ./imisSetup.sh` - * Run service `docker compose -f docker-compose.yml -f docker-compose.lightning.yml up lightning` + * Run migrations `docker compose -f docker-compose.yml -f docker-compose.lightning.yml --env-file=.env.lightning run --rm lightning mix ecto.migrate` + * Run imis demo setup `docker compose -f docker-compose.yml -f docker-compose.lightning.yml --env-file=.env.lightning run --rm lightning ./imisSetup.sh` + * Run service `docker compose -f docker-compose.yml -f docker-compose.lightning.yml --env-file=.env.lightning up lightning` ## OpenSearch/OpenSearch Dashboards setup Both OpenSearch and OpenSearch Dashboards are not by default enabled in dockerized instance. To make them work it's required to: diff --git a/docker-compose.lightning.yml b/docker-compose.lightning.yml index 37487cb..082416a 100644 --- a/docker-compose.lightning.yml +++ b/docker-compose.lightning.yml @@ -22,6 +22,24 @@ x-lightning: &default-app services: + lightning_db: + container_name: ${PROJECT_NAME:-openimis}-lightning-db + image: "postgres:14.2-alpine" + build: + target: ${INIT_MODE:-base} + environment: + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} + - POSTGRES_DB=${POSTGRES_DB} + - POSTGRES_USER=${POSTGRES_USER} + - POSTGRES_PORT + - PGPORT=${POSTGRES_PORT} + volumes: + - lightning_database:/var/lib/postgresql/data + restart: always + networks: + openimis-net: + env_file: + - ".env.lightning" lightning: <<: *default-app deploy: @@ -36,8 +54,11 @@ services: start_period: "5s" retries: 3 depends_on: - - db + - lightning_db networks: openimis-net: name: ${PROJECT_NAME:-openimis}-net + +volumes: + lightning_database: \ No newline at end of file From 00097a8d34ff6d4cf7f6df5aec4a0e77103c4060 Mon Sep 17 00:00:00 2001 From: Damian Borowiecki Date: Mon, 25 Sep 2023 12:46:20 +0200 Subject: [PATCH 3/7] Updated initial setup data --- .env.lightning.example | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.env.lightning.example b/.env.lightning.example index 11aef90..e92ea19 100644 --- a/.env.lightning.example +++ b/.env.lightning.example @@ -25,7 +25,8 @@ MAX_RUN_DURATION=20000 # Those postgres credentials should match ones in .env for imis database POSTGRES_USER=IMISuser POSTGRES_PASSWORD=IMISuserP@s -POSTGRES_HOST=db +POSTGRES_HOST=lightning_db +POSTGRES_PORT=5433 POSTGRES_DB="lightning_${MIX_ENV}" From 4472ff493060ab4f7390717214cc70ccf07adbaa Mon Sep 17 00:00:00 2001 From: Damian Borowiecki Date: Mon, 25 Sep 2023 13:43:28 +0200 Subject: [PATCH 4/7] Change network for lightnign --- docker-compose.lightning.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker-compose.lightning.yml b/docker-compose.lightning.yml index 082416a..0513a0c 100644 --- a/docker-compose.lightning.yml +++ b/docker-compose.lightning.yml @@ -1,4 +1,4 @@ -version: "2.4" +version: "3.7" x-lightning: &default-app build: @@ -17,7 +17,7 @@ x-lightning: &default-app volumes: - "${LIGHTNING_VOLUME:-./priv/static:/app/priv/static}" networks: - openimis-net: + - openimis-net @@ -37,7 +37,7 @@ services: - lightning_database:/var/lib/postgresql/data restart: always networks: - openimis-net: + - openimis-net env_file: - ".env.lightning" lightning: @@ -56,9 +56,9 @@ services: depends_on: - lightning_db + networks: openimis-net: - name: ${PROJECT_NAME:-openimis}-net volumes: lightning_database: \ No newline at end of file From 3bf3fd528511fde998f99647ced55d20b55f9e00 Mon Sep 17 00:00:00 2001 From: Damian Borowiecki Date: Mon, 25 Sep 2023 14:05:45 +0200 Subject: [PATCH 5/7] Fixed opensearch readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7c0cbdc..b9e8e04 100644 --- a/README.md +++ b/README.md @@ -49,8 +49,8 @@ Lightning is not by default enabled in dockerized instance. To make it work it's ## OpenSearch/OpenSearch Dashboards setup Both OpenSearch and OpenSearch Dashboards are not by default enabled in dockerized instance. To make them work it's required to: * Copy `.env.openSearch.example` to `.env.openSearch` and make adjustments - * Run container build `docker compose -f docker-compose.yml -f docker-compose.openSearch.yml build opensearch opensearch-dashboards nginx` - * Run service `docker compose -f docker-compose.yml -f docker-compose.openSearch.yml up opensearch opensearch-dashboards nginx` + * Run container build `docker compose -f docker-compose.yml -f docker-compose.openSearch.yml build opensearch opensearch-dashboards` + * Run service `docker compose -f docker-compose.yml -f docker-compose.openSearch.yml up opensearch opensearch-dashboards` This build provides also additional nginx proxy server in order to handle openSearch Dashboard application on frontend level. To run on a Dockerized instance (database, backend, and frontend of openIMIS), please follow the steps below: From 6a2e42ca43c0489fee30dfb6d5dfaabcb9a1bd8c Mon Sep 17 00:00:00 2001 From: Damian Borowiecki Date: Wed, 11 Oct 2023 17:09:12 +0200 Subject: [PATCH 6/7] Restore .env example --- .env.example | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..c15f2bb --- /dev/null +++ b/.env.example @@ -0,0 +1,55 @@ +# docker-compose parameters +# docker compose project name +PROJECT_NAME=demo +# urls +# url of openimis, FQDN +NEW_OPENIMIS_HOST=demo.openimis.org +# http port for openimis +HTTP_PORT=80 +# https port for openimis +HTTPS_PORT=443 + +# Uncomment the line below to intiate the database with the DEMO dataset, it will create an empty openIMIS database otherwise +#INIT_MODE=demo +DB_PASSWORD=IMISuserP@s +DB_USER=IMISuser +DB_NAME=IMIS +#MSSQL configuration comment DB_ENGINE=django.db.backends.postgresql and DB_PORT=5432, uncomment DB_ENGINE=mssql and ACCEPT_EULA (= y if you accept MS EULA) DB_PORT=1433 +# database parameters +DB_HOST=db +# msssql port +#DB_PORT=1433 +# psql port +DB_PORT=5432 +#psql engine +DB_ENGINE=django.db.backends.postgresql +#mssql engine +#DB_ENGINE=mssql +#ACCEPT_EULA= +GATEWAY_PORT_S=443 +# site root for backend +SITE_ROOT=api + +# github branches to use +# Database, you can use develop branch too +DB_TAG=23.04 +# BE assembly image tag +BE_TAG=23.04 +#FE assembly, image tag +FE_TAG=23.04 +# REST API, image tag +RESTAPI_TAG=23.04 +# rest API flavours +RESTAPI_BUILD_FLAVOR=Release + +#one-liner json config for the FE (to override the openimis.json from the FE assembly) +#OPENIMIS_FE_CONF_JSON= +#one-liner json config for the FE (to overright the openimis.json from the FE assembly) +#OPENIMIS_FE_CONF_JSON= + +# django log level +DJANGO_LOG_LEVEL=WARNING +# django log handler (currently: degub-log (default), db-queries, console) +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 From 58dc8b45bf7c63e526e0f0c95ce0aa34edc03ce5 Mon Sep 17 00:00:00 2001 From: Damian Borowiecki Date: Thu, 12 Oct 2023 10:01:04 +0200 Subject: [PATCH 7/7] Added platform for lightning --- docker-compose.lightning.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.lightning.yml b/docker-compose.lightning.yml index 0513a0c..25720eb 100644 --- a/docker-compose.lightning.yml +++ b/docker-compose.lightning.yml @@ -1,6 +1,7 @@ version: "3.7" x-lightning: &default-app + platform: linux/amd64 build: dockerfile: Dockerfile-dev- context: "https://github.com/openimis/openimis-lightning_dkr.git#develop"