From 32b18948c41982cdec5a173f57cb3426506656ff Mon Sep 17 00:00:00 2001 From: Fred <10602047+freddieptf@users.noreply.github.com> Date: Tue, 29 Oct 2024 17:14:27 +0300 Subject: [PATCH 1/4] Fix form labels (#211) * replace header uses the place's contact type friendly name when available * 1.4.2 --- package-lock.json | 4 ++-- package.json | 2 +- src/liquid/app/form_switch.html | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 090e0990..7ff335fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cht-user-management", - "version": "1.4.1", + "version": "1.4.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cht-user-management", - "version": "1.4.1", + "version": "1.4.2", "license": "ISC", "dependencies": { "@bull-board/api": "^5.17.0", diff --git a/package.json b/package.json index e8629cd1..413728f8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cht-user-management", - "version": "1.4.1", + "version": "1.4.2", "main": "dist/index.js", "dependencies": { "@bull-board/api": "^5.17.0", diff --git a/src/liquid/app/form_switch.html b/src/liquid/app/form_switch.html index f4656a26..2a53fd24 100644 --- a/src/liquid/app/form_switch.html +++ b/src/liquid/app/form_switch.html @@ -11,7 +11,12 @@

- {{header_caption}} {{contactType.contact_friendly | default: contactType.friendly }} + {{header_caption}} + {% if op == "replace" %} + {{contactType.contact_friendly | default: contactType.friendly }} + {% else %} + {{contactType.friendly}} + {% endif %}

From 517b74e8a29ab7195bba28fc26e7bfca671cbf81 Mon Sep 17 00:00:00 2001 From: paulpascal Date: Wed, 30 Oct 2024 17:53:04 +0000 Subject: [PATCH 2/4] Update deployment values (#214) --- scripts/deploy/values/users-chis-civ.yaml | 53 ++++++++++++++++++++++- scripts/deploy/values/users-chis-ke.yaml | 53 ++++++++++++++++++++++- scripts/deploy/values/users-chis-tg.yaml | 53 ++++++++++++++++++++++- scripts/deploy/values/users-chis-ug.yaml | 53 ++++++++++++++++++++++- 4 files changed, 204 insertions(+), 8 deletions(-) diff --git a/scripts/deploy/values/users-chis-civ.yaml b/scripts/deploy/values/users-chis-civ.yaml index ea8a085f..378b435e 100644 --- a/scripts/deploy/values/users-chis-civ.yaml +++ b/scripts/deploy/values/users-chis-civ.yaml @@ -1,8 +1,28 @@ cht-user-management: + replicaCount: 1 + service: + port: 3000 + enabled: true image: - tag: 1.1.6 - env: + repository: public.ecr.aws/medic/cht-user-management + tag: "1.4.2" # Set this to the version of the docker image + + # Environment variablues to set in the pod, for example: + # env: + # CONFIG_NAME: changeme + + env: + NODE_ENV: production + CHT_DEV_HTTP: false CONFIG_NAME: chis-civ + REDIS_HOST: users-chis-civ-redis-master.users-chis-prod.svc.cluster.local + REDIS_PORT: 6379 + envSecrets: + # COOKIE/WORKER_PRIVATE_KEY will be automatically generated if it doesn't exist + - env: COOKIE_PRIVATE_KEY + secretName: "{{ .Release.Name }}-cht-user-management" + - env: WORKER_PRIVATE_KEY + secretName: "{{ .Release.Name }}-cht-user-management" # EKS prod ELB ingress: @@ -22,3 +42,32 @@ cht-user-management: paths: - path: / pathType: Prefix + +cht-user-management-worker: + # Our worker does not need any ports exposed, services, healtchecks, so we toggle this to false + # to prevent single-base-app from templating and creating those resources + service: + enabled: false + replicaCount: 1 + image: + repository: public.ecr.aws/medic/cht-user-management-worker + tag: "1.4.2" + env: + NODE_ENV: production + REDIS_HOST: users-chis-civ-redis-master.users-chis-prod.svc.cluster.local + REDIS_PORT: 6379 + envSecrets: + - env: WORKER_PRIVATE_KEY + secretName: "{{ .Release.Name }}-cht-user-management" + + +redis: + architecture: standalone + replica: + replicaCount: 1 + persistence: + enabled: true + storageClass: ebs-gp2 + size: 8Gi + auth: + enabled: false \ No newline at end of file diff --git a/scripts/deploy/values/users-chis-ke.yaml b/scripts/deploy/values/users-chis-ke.yaml index f38122cf..5bf73bdf 100644 --- a/scripts/deploy/values/users-chis-ke.yaml +++ b/scripts/deploy/values/users-chis-ke.yaml @@ -1,8 +1,28 @@ cht-user-management: + replicaCount: 1 + service: + port: 3000 + enabled: true image: - tag: 1.1.6 - env: + repository: public.ecr.aws/medic/cht-user-management + tag: "1.4.2" # Set this to the version of the docker image + + # Environment variablues to set in the pod, for example: + # env: + # CONFIG_NAME: changeme + + env: + NODE_ENV: production + CHT_DEV_HTTP: false CONFIG_NAME: chis-ke + REDIS_HOST: users-chis-ke-redis-master.users-chis-prod.svc.cluster.local + REDIS_PORT: 6379 + envSecrets: + # COOKIE/WORKER_PRIVATE_KEY will be automatically generated if it doesn't exist + - env: COOKIE_PRIVATE_KEY + secretName: "{{ .Release.Name }}-cht-user-management" + - env: WORKER_PRIVATE_KEY + secretName: "{{ .Release.Name }}-cht-user-management" # EKS prod ELB ingress: @@ -22,3 +42,32 @@ cht-user-management: paths: - path: / pathType: Prefix + +cht-user-management-worker: + # Our worker does not need any ports exposed, services, healtchecks, so we toggle this to false + # to prevent single-base-app from templating and creating those resources + service: + enabled: false + replicaCount: 1 + image: + repository: public.ecr.aws/medic/cht-user-management-worker + tag: "1.4.2" + env: + NODE_ENV: production + REDIS_HOST: users-chis-ke-redis-master.users-chis-prod.svc.cluster.local + REDIS_PORT: 6379 + envSecrets: + - env: WORKER_PRIVATE_KEY + secretName: "{{ .Release.Name }}-cht-user-management" + + +redis: + architecture: standalone + replica: + replicaCount: 1 + persistence: + enabled: true + storageClass: ebs-gp2 + size: 8Gi + auth: + enabled: false \ No newline at end of file diff --git a/scripts/deploy/values/users-chis-tg.yaml b/scripts/deploy/values/users-chis-tg.yaml index 8d1ae4b4..0dc80ced 100644 --- a/scripts/deploy/values/users-chis-tg.yaml +++ b/scripts/deploy/values/users-chis-tg.yaml @@ -1,8 +1,28 @@ cht-user-management: + replicaCount: 1 + service: + port: 3000 + enabled: true image: - tag: 1.1.6 - env: + repository: public.ecr.aws/medic/cht-user-management + tag: "1.4.2" # Set this to the version of the docker image + + # Environment variablues to set in the pod, for example: + # env: + # CONFIG_NAME: changeme + + env: + NODE_ENV: production + CHT_DEV_HTTP: false CONFIG_NAME: chis-tg + REDIS_HOST: users-chis-tg-redis-master.users-chis-prod.svc.cluster.local + REDIS_PORT: 6379 + envSecrets: + # COOKIE/WORKER_PRIVATE_KEY will be automatically generated if it doesn't exist + - env: COOKIE_PRIVATE_KEY + secretName: "{{ .Release.Name }}-cht-user-management" + - env: WORKER_PRIVATE_KEY + secretName: "{{ .Release.Name }}-cht-user-management" # EKS prod ELB ingress: @@ -22,3 +42,32 @@ cht-user-management: paths: - path: / pathType: Prefix + +cht-user-management-worker: + # Our worker does not need any ports exposed, services, healtchecks, so we toggle this to false + # to prevent single-base-app from templating and creating those resources + service: + enabled: false + replicaCount: 1 + image: + repository: public.ecr.aws/medic/cht-user-management-worker + tag: "1.4.2" + env: + NODE_ENV: production + REDIS_HOST: users-chis-tg-redis-master.users-chis-prod.svc.cluster.local + REDIS_PORT: 6379 + envSecrets: + - env: WORKER_PRIVATE_KEY + secretName: "{{ .Release.Name }}-cht-user-management" + + +redis: + architecture: standalone + replica: + replicaCount: 1 + persistence: + enabled: true + storageClass: ebs-gp2 + size: 8Gi + auth: + enabled: false \ No newline at end of file diff --git a/scripts/deploy/values/users-chis-ug.yaml b/scripts/deploy/values/users-chis-ug.yaml index 3ccc95a4..5cc19045 100644 --- a/scripts/deploy/values/users-chis-ug.yaml +++ b/scripts/deploy/values/users-chis-ug.yaml @@ -1,8 +1,28 @@ cht-user-management: + replicaCount: 1 + service: + port: 3000 + enabled: true image: - tag: 1.1.6 - env: + repository: public.ecr.aws/medic/cht-user-management + tag: "1.4.2" # Set this to the version of the docker image + + # Environment variablues to set in the pod, for example: + # env: + # CONFIG_NAME: changeme + + env: + NODE_ENV: production + CHT_DEV_HTTP: false CONFIG_NAME: chis-ug + REDIS_HOST: users-chis-ug-redis-master.users-chis-prod.svc.cluster.local + REDIS_PORT: 6379 + envSecrets: + # COOKIE/WORKER_PRIVATE_KEY will be automatically generated if it doesn't exist + - env: COOKIE_PRIVATE_KEY + secretName: "{{ .Release.Name }}-cht-user-management" + - env: WORKER_PRIVATE_KEY + secretName: "{{ .Release.Name }}-cht-user-management" # EKS prod ELB ingress: @@ -22,3 +42,32 @@ cht-user-management: paths: - path: / pathType: Prefix + +cht-user-management-worker: + # Our worker does not need any ports exposed, services, healtchecks, so we toggle this to false + # to prevent single-base-app from templating and creating those resources + service: + enabled: false + replicaCount: 1 + image: + repository: public.ecr.aws/medic/cht-user-management-worker + tag: "1.4.2" + env: + NODE_ENV: production + REDIS_HOST: users-chis-ug-redis-master.users-chis-prod.svc.cluster.local + REDIS_PORT: 6379 + envSecrets: + - env: WORKER_PRIVATE_KEY + secretName: "{{ .Release.Name }}-cht-user-management" + + +redis: + architecture: standalone + replica: + replicaCount: 1 + persistence: + enabled: true + storageClass: ebs-gp2 + size: 8Gi + auth: + enabled: false \ No newline at end of file From e1054955056875469ec94125b6eccdcc4e60c679 Mon Sep 17 00:00:00 2001 From: mrjones <8253488+mrjones-plip@users.noreply.github.com> Date: Fri, 1 Nov 2024 10:39:33 -0700 Subject: [PATCH 3/4] Standardize port 3500, add redis compose file, update .env to sane defualts (#216) * Standardize port 3500, add redis compose file, update .env to sane defualts #215 * move redis port to 6379 per feedback --- README.md | 14 ++++++++++---- docker-compose.redis.yml | 12 ++++++++++++ docker-compose.yml | 4 ++-- env.example | 30 +++++++++++++++++------------- src/index.ts | 2 +- 5 files changed, 42 insertions(+), 20 deletions(-) create mode 100644 docker-compose.redis.yml diff --git a/README.md b/README.md index 30e905f0..73f4975f 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ To use the User Management Tool with your CHT project, you'll need to create a n 2. Create a `config.json` file and specify the values as defined below. 3. Add reference to your configuration folder in `src/config/config-factory.ts`. -Property | Type | Description + Property | Type | Description -- | -- | -- `domains` | Array | Controls the list of instances which the user can login to `domains.friendly` | string | Friendly name for the instance (eg. "Migori") @@ -119,6 +119,12 @@ This tool is available via Docker by running `docker compose up`. Set the [Envir Create an environment file by `cp env.example .env`. Change `INTERFACE` to `127.0.0.1` and otherwise see [Environment Variables](#environment-variables) for more info. +If you don't have redis running locally, you can start it with: + +```shell +docker compose -f docker-compose.redis.yml up -d +``` + Then run: ``` @@ -153,15 +159,15 @@ The `env.example` file has example values. Here's what they mean: Variable | Description | Sample -- | -- | -- `CONFIG_NAME` | Name of the configuration to use | `chis-ke` -`EXTERNAL_PORT` | Port to use in docker compose when starting the web server | `3000` -`PORT` | For localhost development environment | `3000` +`EXTERNAL_PORT` | Port to use in docker compose when starting the web server | `3500` +`PORT` | For localhost development environment | `3500` `COOKIE_PRIVATE_KEY` | A string used to two-way encryption of main app cookies. Production values need to be a secret. Suggest `uuidgen` to generate | `589a7f23-5bb2-4b77-ac78-f202b9b6d5e3` `WORKER_PRIVATE_KEY` | A string used to two-way encryption sensitive data passed to workers. Recommend to be different from `COOKIE_PRIVATE_KEY`. Production values need to be a secret. Suggest `uuidgen` to generate | `2b57pd5e-f272-og90-8u97-89a7589a7f23` `INTERFACE` | Interface to bind to. Leave as '0.0.0.0' for prod, suggest '127.0.0.1' for development | `127.0.0.1` `CHT_DEV_URL_PORT` | CHT instance when in `NODE_ENV===dev`. Needs URL and port | `192-168-1-26.local-ip.medicmobile.org:10463` `CHT_DEV_HTTP` | 'false' for http 'true' for https | `false` `REDIS_HOST` | Redis server hostname use 'redis' for docker | `redis` -`REDIS_PORT` | Redis server port | `6378` +`REDIS_PORT` | Redis server port | `6379` `CHT_USER_MANAGEMENT_IMAGE` | docker image for cht-user-management service (local development), leave empty to use published one | `cht-user-management:local ` `CHT_USER_MANAGEMENT_WORKER_IMAGE` | docker image for cht-user-management service (local development), leave empty to use published one | `cht-user-management-worker:local` diff --git a/docker-compose.redis.yml b/docker-compose.redis.yml new file mode 100644 index 00000000..f5402bbe --- /dev/null +++ b/docker-compose.redis.yml @@ -0,0 +1,12 @@ +services: + redis: + image: redis:6.2-alpine + restart: always + volumes: + - redis-data:/data + ports: + - 6379:6379 + + +volumes: + redis-data: diff --git a/docker-compose.yml b/docker-compose.yml index 90e82a45..80966e4f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,7 +9,7 @@ services: image: ${CHT_USER_MANAGEMENT_IMAGE:-public.ecr.aws/medic/cht-user-management:latest} environment: - NODE_ENV=${NODE_ENV:-production} - - EXTERNAL_PORT=${EXTERNAL_PORT:-3000} + - EXTERNAL_PORT=${EXTERNAL_PORT:-3500} - COOKIE_PRIVATE_KEY=${COOKIE_PRIVATE_KEY} - WORKER_PRIVATE_KEY=${WORKER_PRIVATE_KEY} - CONFIG_NAME=${CONFIG_NAME} @@ -18,7 +18,7 @@ services: - REDIS_HOST=${REDIS_HOST:-redis} - REDIS_PORT=${REDIS_PORT:-6379} ports: - - '${EXTERNAL_PORT-3000}:${PORT:-3000}' + - '${EXTERNAL_PORT-3500}:${PORT:-3500}' restart: always command: npm start depends_on: diff --git a/env.example b/env.example index 69a90305..075c5df4 100644 --- a/env.example +++ b/env.example @@ -1,13 +1,17 @@ -NODE_ENV= # set to "dev" to use CHT_DEV_URL_PORT below, leave empty for production -COOKIE_PRIVATE_KEY= # unique random key, use uuidgen to populate -WORKER_PRIVATE_KEY= # unique random key, use uuidgen to populate. different from COOKIE_PRIVATE_KEY -CONFIG_NAME=chis-ke # Name of the configuration -PORT=3000 # for development environmentcontainer) -EXTERNAL_PORT=3000 # for docker -INTERFACE=0.0.0.0 # Leave as '0.0.0.0' for prod, suggest '127.0.0.1' for development -#REDIS_HOST=redis # Redis server hostname - only uncomment if you know what you're doing -#REDIS_PORT=6378 # Redis server port - only uncomment if you know what you're doing -CHT_DEV_HTTP=false # 'true' for http 'false' for https -CHT_DEV_URL_PORT=localhost:5984 # where your dev CHT instance is, hostname:port -#CHT_USER_MANAGEMENT_IMAGE=cht-user-management:local # docker image for cht-user-management service - uncomment to use with local development -#CHT_USER_MANAGEMENT_WORKER_IMAGE=cht-user-management-worker:local # docker image for worker service - uncomment to use with local development \ No newline at end of file +NODE_ENV= # set to "dev" to use CHT_DEV_URL_PORT below, leave empty for production +COOKIE_PRIVATE_KEY= # unique random key, use uuidgen to populate +WORKER_PRIVATE_KEY= # unique random key, use uuidgen to populate. different from COOKIE_PRIVATE_KEY +CONFIG_NAME=chis-ke # Name of the configuration +INTERFACE=0.0.0.0 # Leave as '0.0.0.0' for prod, suggest '127.0.0.1' for development +CHT_DEV_HTTP=false # 'true' for http 'false' for https +CHT_DEV_URL_PORT=localhost:5984 # where your dev CHT instance is, hostname:port + +# uncomment for local development ( `npm run dev`) +#REDIS_HOST=localhost # Redis server hostname +#REDIS_PORT=6379 # Redis server port + +# normally leave these commented out unless you know what you're doing: +#PORT=3500 # for development environment container +#EXTERNAL_PORT=3500 # for docker +#CHT_USER_MANAGEMENT_IMAGE=cht-user-management:local # docker image for cht-user-management service - uncomment to use with local development +#CHT_USER_MANAGEMENT_WORKER_IMAGE=cht-user-management-worker:local # docker image for worker service - uncomment to use with local development diff --git a/src/index.ts b/src/index.ts index af678aaf..95a599b7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,7 @@ const { INTERFACE } = process.env; -const port: number = env.PORT ? parseInt(env.PORT) : 3000; +const port: number = env.PORT ? parseInt(env.PORT) : 3500; (async () => { const loggerConfig = { From 786acef5e0d4cb48b348242e20315649e0f2dc65 Mon Sep 17 00:00:00 2001 From: mrjones <8253488+mrjones-plip@users.noreply.github.com> Date: Fri, 1 Nov 2024 13:18:06 -0700 Subject: [PATCH 4/4] change .env to use http by default (#219) --- env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/env.example b/env.example index 075c5df4..46a609a7 100644 --- a/env.example +++ b/env.example @@ -3,7 +3,7 @@ COOKIE_PRIVATE_KEY= # unique random key, use uuidgen to populate WORKER_PRIVATE_KEY= # unique random key, use uuidgen to populate. different from COOKIE_PRIVATE_KEY CONFIG_NAME=chis-ke # Name of the configuration INTERFACE=0.0.0.0 # Leave as '0.0.0.0' for prod, suggest '127.0.0.1' for development -CHT_DEV_HTTP=false # 'true' for http 'false' for https +CHT_DEV_HTTP=true # 'true' for http 'false' for https CHT_DEV_URL_PORT=localhost:5984 # where your dev CHT instance is, hostname:port # uncomment for local development ( `npm run dev`)