Skip to content

Commit

Permalink
Merge branch 'main' into 198_moh_mali_chw_config
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpascal authored Nov 19, 2024
2 parents 1e83bfa + 786acef commit ae582e8
Show file tree
Hide file tree
Showing 12 changed files with 255 additions and 32 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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:

```
Expand Down Expand Up @@ -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`

Expand Down
12 changes: 12 additions & 0 deletions docker-compose.redis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
redis:
image: redis:6.2-alpine
restart: always
volumes:
- redis-data:/data
ports:
- 6379:6379


volumes:
redis-data:
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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:
Expand Down
30 changes: 17 additions & 13 deletions env.example
Original file line number Diff line number Diff line change
@@ -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
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=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`)
#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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
53 changes: 51 additions & 2 deletions scripts/deploy/values/users-chis-civ.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
53 changes: 51 additions & 2 deletions scripts/deploy/values/users-chis-ke.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
53 changes: 51 additions & 2 deletions scripts/deploy/values/users-chis-tg.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
53 changes: 51 additions & 2 deletions scripts/deploy/values/users-chis-ug.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Loading

0 comments on commit ae582e8

Please sign in to comment.