src/services/api/boilerplate
GETon/{endpoint}/healthreturns a health check for the service endpointGETon/{endpoint}/docsreturns the documentation for the service endpoint ( https://editor.swagger.io )
pnpm startlaunches of the Services in local development mode.pnpm testlaunches all test runners using .env file.pnpm run functional-testsstart functional tests using newman through Postman collectionspnpm run unit-testsstart unit tests using mochapnpm run buildbuilds all of the Services for production mode.pnpm run service-authstarts the Auth API Service in production (built) mode.pnpm run service-patientstarts the Patient API Service in production (built) mode.pnpm run service-variantstarts the Variant API Service in production (built) mode.pnpm run service-genestarts the Gene API Service in production (built) mode.pnpm run service-metastarts the Meta API Service in production (built) mode.pnpm run dev-service-xyzlaunches specified service in docker development mode.
Install Node.js LTS 10.14.1 using nvm and run
cp -p development.env .env
npm install -g pnpm
pnpm install
pnpm start
If you haven't done so already, generate self-signed certificates for the dev.chusj-clin-dev.org domain: https://github.com/cr-ste-justine/devops/tree/dev/certificates
Run the following to launch:
./launch-docker-local.sh
Run the following to tear down:
./teardown-docker-local.sh
- Install Docker
- Use
docker-composeas described in this repository - Log into Keycloak as
admin - Add a Realm named
clin- Enable
Login with email
- Enable
- Create a client called
clin-proxy-api- Disable
Standard Flow Enabledin Settings - Enable
Authorization Enabledin Settings - Enable
Direct Access Grantsin Settings - Enable
Service Accountsin Settings - Enable
Exclude Session State From Authentication Responsein Settings under OpenID Connect Compatibility Modes - Set
Access Token Lifespanto X minutes in Settings > Advanced Settings - Disable
OAuth 2.0 Mutual TLS Certificate Bound Access Tokens Enabledin Settings > Advanced Settings
- Disable
- Find your
secretunder Client > Credentials and update the.envfile - Create an Identity Provider
- Enable
Trust Emailin Settings - Set the Client ID to
clin-proxy-apiin Settings under OpenID Connect Config - Set the Client Secret to found
secretunder Client > Credentials - Set Prompt to
nonein Settings under OpenID Connect Config
- Enable
- Create a User
- Set an email
- Set a non-temporary password under Credentials > Manage Password
To create the 'statement' and 'profile' indices, run the following command line where ElasticSearch is available (ssh -L or ssh thru environment)
The delete is because the devops have decided to own elasticsearch and pre-configure settings which make the creation of the index crash
curl -XDELETE "http://localhost:9200/statement"
curl -XDELETE "http://localhost:9200/profile"
curl -XPUT "http://localhost:9200/statement" -H 'Content-Type: application/json' -d @clin-statement-centric.json
curl -XPUT "http://localhost:9200/profile" -H 'Content-Type: application/json' -d @clin-profile-centric.jsonInstall Node.js LTS 10.14.1 using nvm and run
cp -p production.env .env
npm install -g pnpm
pnpm install
pnpm run build
pnpm run service-auth
# Create the proxy & clinnet network to connect all necessary services together
docker network create -d overlay --attachable proxy
docker network create -d overlay --attachable clinnet
# Install on all box sshfs docker volume pluggin
docker plugin install vieux/sshfs DEBUG=1 sshkey.source=/home/ubuntu/.ssh/
# (Optional) Tot test the sshvolume with vieux/sshfs (does not work on macosx)
# Create the volumen sshvolume on all box
docker volume create -d vieux/sshfs -o sshcmd=ubuntu@10.10.0.19:/home/ubuntu/sshvolume/certbot/conf -o allow_other sshvolume
# To Test (does not work on docker for macosx)
docker run -it -v sshvolume:/sshvolume busybox ls /sshvolume
cp -p docker.env auth.env
cp -p docker.env patient.env
docker-compose up --build to rebuild images
or
Edit docker-compose to comment sshfs docker volume and uncomment local volume
docker-compose up
docker stack deploy -c docker-compiose.yml qa-proxi-api
copy docker.env patient.env
copy docker.env auth.env
nano patient.env -- fix environment
nano auth.env -- fix environment
./apply.sh
Edit the docker-compose.yml and apply.sh script so that your desired version is deployed for each service (they point to the same version by default, they don't need to if you need to rollback a particular service) with the number of replicas you want.
copy docker.env patient.env
copy docker.env auth.env
nano patient.env -- fix environment
nano auth.env -- fix environment
./apply.sh
Images are pushed by merging on master. The version tag is taken from the version in the package.json file so make sure you increment it before merging to master.
If you add a new service, make sure to add the building and pushing of its image to the push_images.sh script and its orchestration in the docker-compose.yml file.