Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Merge pull request #48 from openhie/ohie-420-docker-outside-of-docker
Browse files Browse the repository at this point in the history
OHIE-420 docker outside of docker
  • Loading branch information
Martin Brocker authored Jul 21, 2020
2 parents b4183ec + dddfa2e commit 1fac11a
Show file tree
Hide file tree
Showing 27 changed files with 665 additions and 171 deletions.
14 changes: 14 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# docker volume data folders
**/data

# cli client
goinstant

# vscode config
.vscode

# Docs
docs

# Dependency directories
node_modules/
21 changes: 21 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"useTabs": false,
"vueIndentScriptAndStyle": false,
"filepath": "/home/ryan/git/instant/instant.ts",
"parser": "typescript"
}
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM node:lts

WORKDIR /instant

# install curl
RUN apt-get update; apt-get install -y curl

# install kubectl
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
RUN chmod +x ./kubectl
RUN mv ./kubectl /usr/local/bin/kubectl

# install docker engine
RUN curl -sSL https://get.docker.com/ | sh

# install docker-compose binary
RUN curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
RUN chmod +x /usr/local/bin/docker-compose

# install node deps
ADD package.json .
ADD yarn.lock .
RUN yarn

ADD . .

ENTRYPOINT [ "yarn", "instant" ]
32 changes: 22 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,33 @@ Navigate to the main folder to execute the commands.
To set the Instant OpenHIE services run the following command:

```sh
./instant.sh init docker
yarn
yarn docker:build
yarn docker:instant init -t docker
```

To tear down the deployments use the opposing command:

```bash
./instant.sh down docker
yarn docker:instant down -t docker
```

To start up the services after a tear down, use the following command:

```bash
./instant.sh up docker
yarn docker:instant up -t docker
```

To completely remove all project components use the following option:

```bash
./instant.sh destroy docker
yarn docker:instant destroy -t docker
```

Each command also takes a list of package IDs to operate on. If this is left out then all packages are run by default.

E.g only run `core` package: `yarn docker:instant init -t docker core`

## Kubernetes

A kubernetes deployment can either be to AWS using [eksctl](https://docs.aws.amazon.com/eks/latest/userguide/getting-started-eksctl.html) and [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) or locally using [minikube](https://kubernetes.io/docs/setup/learning-environment/minikube/) and `kubectl`.
Expand All @@ -45,23 +51,29 @@ Navigate to the main folder to execute the commands.
To set the Instant OpenHIE services run the following command:

```sh
./instant.sh init k8s
yarn
yarn docker:build
yarn docker:instant init -t k8s
```

To tear down the deployments use the following command:
To tear down the deployments, use the following command:

```bash
./instant.sh down k8s
yarn docker:instant down -t k8s
```

To start up the services after a tear down, use the following command:

```bash
./instant.sh up k8s
yarn docker:instant up -t k8s
```

To completely remove all project components use the following option:
To completely remove all project components, use the following option:

```bash
./instant.sh destroy k8s
yarn docker:instant destroy -t k8s
```

Each command also takes a list of package IDs to operate on. If this is left out then all packages are run by default.

E.g only run `core` package: `yarn docker:instant init -t k8s core`
12 changes: 6 additions & 6 deletions client/docker/compose.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
composeFilePath=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )

if [ "$1" == "init" ]; then
docker-compose -f "$composeFilePath"/docker-compose.yml up -d fhir es
docker-compose -p instant -f "$composeFilePath"/docker-compose.yml up -d fhir es

# Set up the openhim
# "$composeFilePath"/initiateReplicaSet.sh

# Wait
sleep 100
docker-compose -f "$composeFilePath"/docker-compose.yml up -d opencr
docker-compose -p instant -f "$composeFilePath"/docker-compose.yml up -d opencr


elif [ "$1" == "up" ]; then
docker-compose -f "$composeFilePath"/docker-compose.yml up -d fhir es
docker-compose -p instant -f "$composeFilePath"/docker-compose.yml up -d fhir es

# Wait
sleep 20
docker-compose -f "$composeFilePath"/docker-compose.yml up -d opencr
docker-compose -p instant -f "$composeFilePath"/docker-compose.yml up -d opencr

elif [ "$1" == "down" ]; then
docker-compose -f "$composeFilePath"/docker-compose.yml stop
docker-compose -p instant -f "$composeFilePath"/docker-compose.yml stop

elif [ "$1" == "destroy" ]; then
docker-compose -f "$composeFilePath"/docker-compose.yml down -v
docker-compose -p instant -f "$composeFilePath"/docker-compose.yml down -v

else
echo "Valid options are: init, up, down, or destroy"
Expand Down
12 changes: 6 additions & 6 deletions core/docker/compose.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
composeFilePath=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )

if [ "$1" == "init" ]; then
docker-compose -f "$composeFilePath"/docker-compose-mongo.yml up -d
docker-compose -p instant -f "$composeFilePath"/docker-compose-mongo.yml up -d

# Set up the replica set
"$composeFilePath"/initiateReplicaSet.sh

docker-compose -f "$composeFilePath"/docker-compose.yml -f "$composeFilePath"/docker-compose.dev.yml -f "$composeFilePath"/importer/docker-compose.config.yml up -d
docker-compose -p instant -f "$composeFilePath"/docker-compose.yml -f "$composeFilePath"/docker-compose.dev.yml -f "$composeFilePath"/importer/docker-compose.config.yml up -d
elif [ "$1" == "up" ]; then
docker-compose -f "$composeFilePath"/docker-compose-mongo.yml up -d
docker-compose -p instant -f "$composeFilePath"/docker-compose-mongo.yml up -d

# Wait for mongo replica set to be set up
sleep 20

docker-compose -f "$composeFilePath"/docker-compose.yml up -d
docker-compose -p instant -f "$composeFilePath"/docker-compose.yml up -d
elif [ "$1" == "down" ]; then
docker-compose -f "$composeFilePath"/docker-compose-mongo.yml -f "$composeFilePath"/docker-compose.yml -f "$composeFilePath"/docker-compose.dev.yml -f "$composeFilePath"/importer/docker-compose.config.yml stop
docker-compose -p instant -f "$composeFilePath"/docker-compose-mongo.yml -f "$composeFilePath"/docker-compose.yml -f "$composeFilePath"/docker-compose.dev.yml -f "$composeFilePath"/importer/docker-compose.config.yml stop
elif [ "$1" == "destroy" ]; then
docker-compose -f "$composeFilePath"/docker-compose-mongo.yml -f "$composeFilePath"/docker-compose.yml -f "$composeFilePath"/docker-compose.dev.yml -f "$composeFilePath"/importer/docker-compose.config.yml down -v
docker-compose -p instant -f "$composeFilePath"/docker-compose-mongo.yml -f "$composeFilePath"/docker-compose.yml -f "$composeFilePath"/docker-compose.dev.yml -f "$composeFilePath"/importer/docker-compose.config.yml down -v
else
echo "Valid options are: init, up, down, or destroy"
fi
11 changes: 8 additions & 3 deletions core/docker/docker-compose-mongo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
image: mongo:4.2
container_name: mongo-1
volumes:
- './data/mongo1:/data/db'
- 'openhim-mongo1:/data/db'
command:
- --replSet
- mongo-set
Expand All @@ -14,7 +14,7 @@ services:
image: mongo:4.2
container_name: mongo-2
volumes:
- './data/mongo2:/data/db'
- 'openhim-mongo2:/data/db'
command:
- --replSet
- mongo-set
Expand All @@ -23,7 +23,12 @@ services:
image: mongo:4.2
container_name: mongo-3
volumes:
- './data/mongo3:/data/db'
- 'openhim-mongo3:/data/db'
command:
- --replSet
- mongo-set

volumes:
openhim-mongo1:
openhim-mongo2:
openhim-mongo3:
4 changes: 1 addition & 3 deletions core/docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ version: '3.3'

services:
mongo-1:
image: mongo:4.2
container_name: mongo-1
volumes:
- './data/mongo1:/data/db'
image: mongo:4.2
ports:
- "27017:27017"

Expand Down
13 changes: 10 additions & 3 deletions core/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ services:
container_name: hapi-fhir
image: hapiproject/hapi:v4.1.0
environment:
- JAVA_OPTS='-Dhapi.properties=/usr/local/tomcat/conf/hapi.properties'
- JAVA_OPTS='-Dhapi.properties=/instant/core/docker/hapi.properties'
volumes:
- ./hapi.properties:/usr/local/tomcat/conf/hapi.properties
- type: volume
source: instant
target: /instant
depends_on:
- mysql

Expand All @@ -42,4 +44,9 @@ services:
MYSQL_PASSWORD: 'instant101'
MYSQL_ROOT_PASSWORD: 'instant101'
volumes:
- './data/mysql:/var/lib/mysql'
- 'hapi-mysql:/var/lib/mysql'

volumes:
hapi-mysql:
instant:
external: true
2 changes: 0 additions & 2 deletions core/docker/importer/.dockerignore

This file was deleted.

12 changes: 8 additions & 4 deletions core/docker/importer/docker-compose.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ services:
# Reject unauthorised is only needed if the OpenHIM's SSL is not setup
NODE_TLS_REJECT_UNAUTHORIZED: 0
volumes:
- type: bind
source: ./importer/volume
target: /importer
- type: volume
source: instant
target: /instant
# This command will only attempt to import the OpenHIM config when the heartbeat responds with a 2xx
command: sh -c "wait-on -t 60000 https-get://core:8080/heartbeat && node openhimConfig.js"
command: sh -c "wait-on -t 60000 https-get://core:8080/heartbeat && node /instant/core/docker/importer/volume/openhimConfig.js"
# ensure all relevant services are running before executing the importer
depends_on:
- core

volumes:
instant:
external: true
1 change: 0 additions & 1 deletion core/gen-k8s-config.sh

This file was deleted.

6 changes: 6 additions & 0 deletions core/instant.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"id": "core",
"name": "Core package",
"description": "",
"version": ""
}
4 changes: 3 additions & 1 deletion core/kubernetes/main/k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ cloud_setup () {
}

local_setup () {
minikubeIP=$(minikube ip)
minikubeIP=$(kubectl config view -o=jsonpath='{.clusters[?(@.name=="minikube")].cluster.server}' | awk '{ split($0,A,/:\/*/) ; print A[2] }')
openhimCoreMediatorSSLPort=$(kubectl get service openhim-core-service -o=jsonpath={.spec.ports[0].nodePort})
openhimCoreTransactionPort=$(kubectl get service openhim-core-service -o=jsonpath={.spec.ports[2].nodePort})
openhimCoreTransactionSSLPort=$(kubectl get service openhim-core-service -o=jsonpath={.spec.ports[1].nodePort})
Expand Down Expand Up @@ -123,6 +123,8 @@ if [ "$1" == "init" ]; then

print_services_url
printf ">>> The OpenHIM Console Url will take a few minutes to become active <<<\n\n"

bash "$k8sMainRootFilePath"/../importer/k8s.sh up
elif [ "$1" == "up" ]; then
kubectl apply -k $k8sMainRootFilePath

Expand Down
Loading

0 comments on commit 1fac11a

Please sign in to comment.