Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Without move contact feature #210

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Docker build and publish

on:
push:
branches: main
branches: main_without_move_contact_feature

env:
ECR_REPO: 'public.ecr.aws/s5s3h4s7'
Expand Down Expand Up @@ -39,9 +39,4 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: 20.x

- name: Build and push cht-user-management image
run: npm run publish:cht-user-management

- name: Build and push cht-user-management-worker image
run: npm run publish:cht-user-management-worker
- run: npm run publish
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
FROM node:20-alpine

ENV EXTERNAL_PORT 3500
ENV PORT 3500
ENV NODE_ENV production
ENV EXTERNAL_PORT 3000
ENV PORT 3000

WORKDIR /app

HEALTHCHECK --interval=30s --timeout=3s \
CMD wget --spider http://127.0.0.1:${PORT}/_healthz || exit 1

COPY package*.json ./
RUN apk add git
RUN npm ci --omit=dev

COPY src ./src
Expand Down
13 changes: 0 additions & 13 deletions Dockerfile.worker

This file was deleted.

24 changes: 1 addition & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ lineage | Has the attributes from `hierarchy.property_name`
This tool is available via Docker by running `docker compose up`. Set the [Environment Variables](#environment-variables).

## Development

### NodeJs with reloading code

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.

Then run:
Expand All @@ -132,20 +129,6 @@ npm run build
npm start
```

### Docker with static code

To build the Docker images and run Docker Compose locally, run:

```bash
./docker-local-setup.sh build
```

If you just need to run the development environment without rebuilding the images run:

```bash
./docker-local-setup.sh
```

## Environment Variables

The `env.example` file has example values. Here's what they mean:
Expand All @@ -155,15 +138,10 @@ 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`
`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`
`COOKIE_PRIVATE_KEY` | A string used to two-way encryption of cookies. Production values need to be a secret. Suggest `uuidgen` to generate | `589a7f23-5bb2-4b77-ac78-f202b9b6d5e3`
`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`
`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`

## Publishing new docker images

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

cht-user-management:
image: ${CHT_USER_MANAGEMENT_IMAGE:-public.ecr.aws/medic/cht-user-management:latest}
image: public.ecr.aws/medic/cht-user-management:latest
environment:
- NODE_ENV=${NODE_ENV:-production}
- EXTERNAL_PORT=${EXTERNAL_PORT:-3000}
- COOKIE_PRIVATE_KEY=${COOKIE_PRIVATE_KEY}
- WORKER_PRIVATE_KEY=${WORKER_PRIVATE_KEY}
- CONFIG_NAME=${CONFIG_NAME}
- CHT_DEV_HTTP=${CHT_DEV_HTTP}
- CHT_DEV_URL_PORT=${CHT_DEV_URL_PORT}
- REDIS_HOST=${REDIS_HOST:-redis}
- REDIS_PORT=${REDIS_PORT:-6379}
ports:
- '${EXTERNAL_PORT-3000}:${PORT:-3000}'
restart: always
command: npm start
depends_on:
- redis

cht-user-management-worker:
image: ${CHT_USER_MANAGEMENT_WORKER_IMAGE:-public.ecr.aws/medic/cht-user-management-worker:latest}
restart: always
command: npm run start:worker
environment:
- NODE_ENV=${NODE_ENV:-production}
- REDIS_HOST=${REDIS_HOST:-redis}
- REDIS_PORT=${REDIS_PORT:-6379}
- WORKER_PRIVATE_KEY=${WORKER_PRIVATE_KEY}
depends_on:
- redis

volumes:
redis-data:
27 changes: 0 additions & 27 deletions docker-local-setup.sh

This file was deleted.

19 changes: 7 additions & 12 deletions env.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
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
COOKIE_PRIVATE_KEY=
CONFIG_NAME=chis-ke
PORT=3000 # for development environment
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
CHT_DEV_URL_PORT=localhost:5984 # where your dev CHT instance is, hostname:port
CHT_DEV_HTTP=true # 'false' for http 'true' for https
Loading
Loading