Skip to content
This repository has been archived by the owner on Feb 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #72 from PhysiciansDataCollaborative/dev
Browse files Browse the repository at this point in the history
0.1.2
  • Loading branch information
DerekRoberts committed Jul 30, 2015
2 parents 0638c35 + 7738ede commit a933202
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 96 deletions.
90 changes: 47 additions & 43 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,43 +48,43 @@ prod:
#########################

hubdb:
@ sudo mkdir -p $(PATH_MONGO)
@ $(call dockerize,hubdb,$(DOCKER_HUBDB_PRODUCTION))
@ sudo mkdir -p $(PATH_MONGO_DB) $(PATH_MONGO_DUMP)
@ $(call dockerize,hubdb,$(DOCKER_HUBDB_PROD))
@ sudo docker exec hubdb /app/mongodb_init.sh > /dev/null


hub:
@ sudo mkdir -p $(PATH_HUB_SSH_HOST) $(PATH_HUB_SSH_AUTOSSH)
@ $(call dockerize,hub,$(DOCKER_HUB_PRODUCTION))
@ sudo mkdir -p $(PATH_HUB_AUTHKEYS) $(PATH_HUB_AUTOSSH)
@ $(call dockerize,hub,$(DOCKER_HUB_PROD))


auth:
@ sudo mkdir -p $(PATH_DACS)
@ $(call dockerize,auth,$(DOCKER_AUTH_PRODUCTION))
@ $(call dockerize,auth,$(DOCKER_AUTH_PROD))


dclapi:
@ sudo mkdir -p $(PATH_DRUGREF)
@ $(call dockerize,dclapi,$(DOCKER_DCLAPI_PRODUCTION))
@ $(call dockerize,dclapi,$(DOCKER_DCLAPI_PROD))


hapi:
@ $(call dockerize,hapi,$(DOCKER_HAPI_PRODUCTION))
@ $(call dockerize,hapi,$(DOCKER_HAPI_PROD))


viz:
@ sudo mkdir -p $(PATH_CERT)
@ $(call dockerize,viz,$(DOCKER_VIZ_PRODUCTION))
@ $(call dockerize,viz,$(DOCKER_VIZ_PROD))


ep-sample:
@ sudo mkdir -p $(PATH_EPX_AUTOSSH)
@ $(call dockerize,endpoint,$(DOCKER_ENDPOINT_PRODUCTION),0)
@ $(call dockerize,endpoint,$(DOCKER_ENDPOINT_PROD),0)
@ $(call config_ep,0,cpsid,cpsid,admin,TEST,sample)


queries:
@ $(call dockerize,queries,$(DOCKER_QI_PRODUCTION))
@ $(call dockerize,queries,$(DOCKER_QI_PROD))
@ sudo docker logs -f queries
@ $(call docker_remove,queries)

Expand All @@ -107,7 +107,7 @@ ep:
echo "Usage: make ep [gID=#] [DOCTOR=#####] [op:JURISDUCTION] [op:ROLE] [op:PASSWORD]"; \
echo; \
else \
$(call dockerize_ep,endpoint,$(DOCKER_ENDPOINT_PRODUCTION),$(gID)); \
$(call dockerize_ep,endpoint,$(DOCKER_ENDPOINT_PROD),$(gID)); \
$(call config_ep,$(gID),$(DOCTOR),$(ROLE),$(JURISDICTION),$(PASSWORD)); \
fi

Expand Down Expand Up @@ -269,6 +269,7 @@ config-bash:
echo "alias r='sudo docker rm -fv'"; \
echo "alias s='sudo docker ps -a | less -S'"; \
echo "alias m='make'"; \
echo "alias gitsubdiffs='find . -maxdepth 1 -mindepth 1 -type d -exec git -C {} status \;'"; \
) | tee -a $${HOME}/.bashrc; \
echo ""; \
echo ""; \
Expand All @@ -277,8 +278,8 @@ config-bash:
fi


config-oc:
# Add repository and install owncloud cmd client
config-backups:
# Add repository, install owncloud cmd client and run cronjobs for infrastructure and MongoDB data
#
@ echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/desktop/xUbuntu_14.04/ /' \
| sudo tee /etc/apt/sources.list.d/owncloud-client.list
Expand Down Expand Up @@ -306,6 +307,11 @@ config-oc:
echo 'cd $${SCRIPT_DIR}'; \
echo ''; \
echo ''; \
echo '# Create a MongoDB dump'; \
echo '#'; \
echo 'sudo docker exec hubdb /app/mongodb_dump.sh';\
echo ''; \
echo ''; \
echo '# Copy non-sensitive MongoDB dumps to ./mongo_partial/'; \
echo '#'; \
echo 'sudo mkdir -p mongo_partial/'; \
Expand Down Expand Up @@ -345,10 +351,17 @@ config-oc:
@ if((! sudo test -e /var/spool/cron/crontabs/root )||(! sudo grep --quiet 'oc_backup.sh' /var/spool/cron/crontabs/root )); \
then \
( \
echo ''; \
echo ''; \
echo '# Backup to ownCloud every 30 minutes'; \
echo '#'; \
echo '0,30 * * * * $\${PATH_HOST}/oc_backup.sh'; \
echo ''; \
echo ''; \
echo '# Dump MongoDB nightly for UVic backup'; \
echo '#'; \
echo '15 1 * * * sudo docker exec hubdb /app/mongodb_dump.sh'; \
echo ''; \
) | sudo tee -a /var/spool/cron/crontabs/root; \
fi

Expand Down Expand Up @@ -437,7 +450,7 @@ define config_ep
# Add Hub to known_hosts and receive Endpoint's public key
#
sudo docker exec ep$1 ssh -p $(PORT_AUTOSSH) -o StrictHostKeyChecking=no autossh@$(URL_HUB) 2> /dev/null || true
sudo docker exec ep$1 /app/key_exchange.sh | sudo tee -a $(PATH_HUB_SSH_AUTOSSH)/authorized_keys > /dev/null
sudo docker exec ep$1 /app/key_exchange.sh | sudo tee -a $(PATH_HUB_AUTOSSH)/authorized_keys > /dev/null

# Add Endpoint to the HubDB
#
Expand Down Expand Up @@ -480,40 +493,31 @@ endef
include config.env


# Set branch defaults
# Override branch defaults for non-production modes
#
ifeq ($(BUILD_MODE), dev)
BRANCH_DEFAULT = dev
else ifeq ($(BUILD_MODE), master)
BRANCH_DEFAULT = master
else
BRANCH_DEFAULT = $(RELEASE_VERSION)
ifneq ($(BUILD_MODE), prod)
BRANCH_AUTH ?= $(BUILD_MODE)
BRANCH_DCLAPI ?= $(BUILD_MODE)
BRANCH_ENDPOINT ?= $(BUILD_MODE)
BRANCH_EPXCLOUD ?= $(BUILD_MODE)
BRANCH_HAPI ?= $(BUILD_MODE)
BRANCH_HUB ?= $(BUILD_MODE)
BRANCH_HUBDB ?= $(BUILD_MODE)
BRANCH_QI ?= $(BUILD_MODE)
BRANCH_VIZ ?= $(BUILD_MODE)
endif


# Append Docker run commands for non-production modes
#
ifneq ($(BUILD_MODE), prod)
DOCKER_AUTH_PRODUCTION += $(DOCKER_AUTH_DEV_APPEND)
DOCKER_DCLAPI_PRODUCTION += $(DOCKER_DCLAPI_DEV_APPEND)
DOCKER_ENDPOINT_PRODUCTION += $(DOCKER_ENDPOINT_DEV_APPEND)
DOCKER_EPXCLOUD_PRODUCTION += $(DOCKER_ENDPOINT_DEV_APPEND)
DOCKER_HAPI_PRODUCTION += $(DOCKER_HAPI_DEV_APPEND)
DOCKER_HUB_PRODUCTION += $(DOCKER_HUB_DEV_APPEND)
DOCKER_HUBDB_PRODUCTION += $(DOCKER_HUBDB_DEV_APPEND)
DOCKER_QI_PRODUCTION += $(DOCKER_QI_DEV_APPEND)
DOCKER_VIZ_PRODUCTION += $(DOCKER_VIZ_DEV_APPEND)
DOCKER_AUTH_PROD += $(DOCKER_AUTH_JOIN)
DOCKER_DCLAPI_PROD += $(DOCKER_DCLAPI_JOIN)
DOCKER_ENDPOINT_PROD += $(DOCKER_ENDPOINT_JOIN)
DOCKER_EPXCLOUD_PROD += $(DOCKER_ENDPOINT_JOIN)
DOCKER_HAPI_PROD += $(DOCKER_HAPI_JOIN)
DOCKER_HUB_PROD += $(DOCKER_HUB_JOIN)
DOCKER_HUBDB_PROD += $(DOCKER_HUBDB_JOIN)
DOCKER_QI_PROD += $(DOCKER_QI_JOIN)
DOCKER_VIZ_PROD += $(DOCKER_VIZ_JOIN)
endif


# Use branch defaults where overrides are not provided
#
BRANCH_AUTH ?= $(BRANCH_DEFAULT)
BRANCH_DCLAPI ?= $(BRANCH_DEFAULT)
BRANCH_ENDPOINT ?= $(BRANCH_DEFAULT)
BRANCH_EPXCLOUD ?= $(BRANCH_DEFAULT)
BRANCH_HAPI ?= $(BRANCH_DEFAULT)
BRANCH_HUB ?= $(BRANCH_DEFAULT)
BRANCH_HUBDB ?= $(BRANCH_DEFAULT)
BRANCH_QI ?= $(BRANCH_DEFAULT)
BRANCH_VIZ ?= $(BRANCH_DEFAULT)
102 changes: 49 additions & 53 deletions config.env
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,9 @@
BUILD_MODE=prod


# Release
#
RELEASE_VERSION=0.1.1


# Hub external IP/Address (10.0.2.2 for Vagrant/VirtualBox)
#
URL_HUB=hub.pdc.io


# Notification addresses
#
EMAIL_ERRORS=[email protected]


# ownCloud backup details
#
OWNCLOUD_ID=hub.pdc.io
OWNCLOUD_PW=
OWNCLOUD_URL=
URL_HUB=10.0.2.2


# GitHub branch overrides
Expand All @@ -37,15 +20,22 @@ OWNCLOUD_URL=
#
# (Note: do not leave blank values!)
#
#BRANCH_AUTH=master
#BRANCH_DCLAPI=master
#BRANCH_ENDPOINT=master
#BRANCH_EP=master
#BRANCH_HAPI=master
#BRANCH_HUB=master
#BRANCH_HUBDB=master
#BRANCH_QI=master
#BRANCH_VIZ=master
BRANCH_AUTH=0.1.2
BRANCH_DCLAPI=0.1.1
BRANCH_ENDPOINT=0.1.2
BRANCH_EPXCLOUD=0.1.1
BRANCH_HAPI=0.1.2
BRANCH_HUB=0.1.1
BRANCH_HUBDB=0.1.2
BRANCH_QI=0.1.1
BRANCH_VIZ=0.1.2


# ownCloud backup details
#
OWNCLOUD_ID=hub.pdc.io
OWNCLOUD_PW=<password>
OWNCLOUD_URL=<https://...>


# DACS
Expand All @@ -60,6 +50,11 @@ DACS_JURISDICTION=TEST
PATH_HOST=/pdc/data


# Notification addresses
#
EMAIL_ERRORS=[email protected]


# Node.js
#
NODE_TLS_REJECT_UNAUTHORIZED=0
Expand Down Expand Up @@ -118,46 +113,47 @@ URL_DCLAPI=http://dclapi:3007

# Host data folders
#
PATH_HUB_AUTHKEYS=${PATH_HOST}/hub/etc/ssh
PATH_HUB_AUTOSSH=${PATH_HOST}/hub/home/autossh/DOTssh
PATH_HUB_AUTHKEYS=${PATH_HOST}/hub/etc/ssh/
PATH_HUB_AUTOSSH=${PATH_HOST}/hub/home/autossh/DOTssh/
PATH_EPX_AUTOSSH=${PATH_HOST}/epx/root/DOTssh/
PATH_CERT=${PATH_HOST}/cert
PATH_DACS=${PATH_HOST}/dacs
PATH_MONGO=${PATH_HOST}/mongo
PATH_DRUGREF=${PATH_HOST}/drugref
PATH_CERT=${PATH_HOST}/cert/
PATH_DACS=${PATH_HOST}/dacs/
PATH_MONGO_DB=${PATH_HOST}/mongo/db/
PATH_MONGO_DUMP=${PATH_HOST}/mongo/dump/
PATH_DRUGREF=${PATH_HOST}/drugref/


# DACS
#
DACS_KEYFILE=${DACS_STOREDIR}/federations/pdc.dev/federation_keyfile
DACS_ROLEFILE=${DACS_STOREDIR}/federations/pdc.dev/roles
DACS_KEYFILE=/etc/dacs/federations/pdc.dev/federation_keyfile
DACS_ROLEFILE=/etc/dacs/federations/pdc.dev/roles


# Containers
#
DOCKER_AUTH_PRODUCTION=-v ${PATH_DACS}:${DACS_STOREDIR}/:rw
DOCKER_AUTH_DEV_APPEND=-p ${PORT_AUTH_M}:${PORT_AUTH_M} -p ${PORT_AUTH_C}:${PORT_AUTH_C}
DOCKER_AUTH_PROD=-v ${PATH_DACS}:${DACS_STOREDIR}/:rw
DOCKER_AUTH_SUPPLEMENT=-p ${PORT_AUTH_M}:${PORT_AUTH_M} -p ${PORT_AUTH_C}:${PORT_AUTH_C}
#
DOCKER_DCLAPI_PRODUCTION=-v ${PATH_DRUGREF}:/app/drugref/
DOCKER_DCLAPI_DEV_APPEND=-p ${PORT_DACS}:${PORT_DACS}
DOCKER_DCLAPI_PROD=-v ${PATH_DRUGREF}:/app/drugref/
DOCKER_DCLAPI_JOIN=-p ${PORT_DACS}:${PORT_DACS}
#
DOCKER_ENDPOINT_PRODUCTION=-v $(PATH_EPX_AUTOSSH):/root/.ssh/:rw
DOCKER_ENDPOINT_DEV_APPEND=
DOCKER_ENDPOINT_PROD=-v $(PATH_EPX_AUTOSSH):/root/.ssh/:rw
DOCKER_ENDPOINT_JOIN=
#
DOCKER_EPXCLOUD_PRODUCTION=-v $(PATH_EPX_AUTOSSH):/root/.ssh/:ro
DOCKER_EPXCLOUD_DEV_APPEND=
DOCKER_EPXCLOUD_PROD=-v $(PATH_EPX_AUTOSSH):/root/.ssh/:ro
DOCKER_EPXCLOUD_JOIN=
#
DOCKER_HAPI_PRODUCTION=--link auth:auth --link hubdb:hubdb --link dclapi:dclapi
DOCKER_HAPI_DEV_APPEND=-p ${PORT_HAPI}:${PORT_HAPI}
DOCKER_HAPI_PROD=--link auth:auth --link hubdb:hubdb --link dclapi:dclapi
DOCKER_HAPI_JOIN=-p ${PORT_HAPI}:${PORT_HAPI}
#
DOCKER_HUB_PRODUCTION=--link hubdb:hubdb -v ${PATH_HUB_AUTOSSH}:/home/autossh/.ssh/:rw -v ${PATH_HUB_AUTHKEYS}:/etc/ssh/:rw -p ${PORT_AUTOSSH}:22 -p ${PORT_HUB_WEB}:3002
DOCKER_HUB_DEV_APPEND=
DOCKER_HUB_PROD=--link hubdb:hubdb -v ${PATH_HUB_AUTOSSH}:/home/autossh/.ssh/:rw -v ${PATH_HUB_AUTHKEYS}:/etc/ssh/:rw -p ${PORT_AUTOSSH}:22 -p ${PORT_HUB_WEB}:3002
DOCKER_HUB_JOIN=
#
DOCKER_HUBDB_PRODUCTION=-v ${PATH_MONGO}:/data/:rw
DOCKER_HUBDB_DEV_APPEND=-p ${PORT_MONGO}:27017
DOCKER_HUBDB_PROD=-v ${PATH_MONGO_DB}:/data/db/:rw -v ${PATH_MONGO_DUMP}:/data/dump/:rw
DOCKER_HUBDB_JOIN=-p ${PORT_MONGO}:27017
#
DOCKER_QI_PRODUCTION=--link hubdb:hubdb
DOCKER_QI_DEV_APPEND=
DOCKER_QI_PROD=--link hubdb:hubdb
DOCKER_QI_JOIN=
#
DOCKER_VIZ_PRODUCTION=--link auth:auth --link hapi:hapi -p 80:${PORT_VIZ} -p 443:${PORT_VIZ} -v ${PATH_CERT}:/app/cert/:ro
DOCKER_VIZ_DEV_APPEND=-p ${PORT_VIZ}:${PORT_VIZ}
DOCKER_VIZ_PROD=--link auth:auth --link hapi:hapi -p 443:${PORT_VIZ} -v ${PATH_CERT}:/app/cert/:ro
DOCKER_VIZ_JOIN=-p ${PORT_VIZ}:${PORT_VIZ}
43 changes: 43 additions & 0 deletions viz_add.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
#
#
set -e -o nounset


# Expected input
#
# $0 this script
# $1 Endpoint #
# $2 Doctor ID


# Check parameters
#
if([ $# -lt 2 ] || [ $# -gt 3 ])
then
echo ""
echo "Unexpected number of parameters."
echo ""
echo "Usage: viz_add.sh [endpointNumber] [doctorID] [more soon!]"
echo ""
exit
fi


# Set variables from parameters
#
export EP_NUM=$(printf "%04d" ${1})
export EP_NAME=pdc-${EP_NUM}
export DOCTOR=${2}


# Add Endpoint to the HubDB
#
#sudo docker exec hubdb /app/endpoint_add.sh $1 | grep WriteResult


# Get ClinicID (Endpoint's MongoDB ObjectID) and provide it to Auth
#
sudo docker exec -ti auth /sbin/setuser app /app/dacs_add.sh \
${DOCTOR} $(sudo docker exec hubdb /app/endpoint_getClinicID.sh ${EP_NUM}) \
${EP_NAME} admin TEST sample

0 comments on commit a933202

Please sign in to comment.