diff --git a/.env.lightning.example b/.env.lightning.example index 91eaf14..e92ea19 100644 --- a/.env.lightning.example +++ b/.env.lightning.example @@ -23,9 +23,10 @@ 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 +POSTGRES_HOST=lightning_db +POSTGRES_PORT=5433 POSTGRES_DB="lightning_${MIX_ENV}" @@ -49,8 +50,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/README.md b/README.md index 6044d18..b9e8e04 100644 --- a/README.md +++ b/README.md @@ -42,15 +42,15 @@ 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: * 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: diff --git a/docker-compose.lightning.yml b/docker-compose.lightning.yml index 0743ab2..25720eb 100644 --- a/docker-compose.lightning.yml +++ b/docker-compose.lightning.yml @@ -1,39 +1,47 @@ -version: "3" +version: "3.7" x-lightning: &default-app + platform: linux/amd64 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" + lightning_db: + container_name: ${PROJECT_NAME:-openimis}-lightning-db image: "postgres:14.2-alpine" - restart: "${DOCKER_RESTART_POLICY:-unless-stopped}" - stop_grace_period: "3s" + build: + target: ${INIT_MODE:-base} + environment: + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} + - POSTGRES_DB=${POSTGRES_DB} + - POSTGRES_USER=${POSTGRES_USER} + - POSTGRES_PORT + - PGPORT=${POSTGRES_PORT} volumes: - - "postgres:/var/lib/postgresql/data" - - web: + - lightning_database:/var/lib/postgresql/data + restart: always + networks: + - openimis-net + env_file: + - ".env.lightning" + lightning: <<: *default-app deploy: resources: @@ -46,12 +54,12 @@ services: timeout: "3s" start_period: "5s" retries: 3 - ports: - - "${LIGHTNING_EXTERNAL_PORT:-127.0.0.1:4000}:${URL_PORT}" + depends_on: + - lightning_db -volumes: - postgres: {} networks: openimis-net: - name: ${PROJECT_NAME}-openimis-net + +volumes: + lightning_database: \ No newline at end of file