Last active
May 27, 2022 00:12
-
-
Save mrjones-plip/7bbe7b0a44ce7876a551b9730c6fc43d to your computer and use it in GitHub Desktop.
Developer CHT Install with couchdb in docker (standard)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a quick way to install a CHT instance. Uses starndard docker based couchdb | |
# see bare-metal guide here: https://gist.github.com/mrjones-plip/7760b6a1a7e9cface3714a16fe60eb93 | |
# | |
# assumes running as not root user, but with user with sudo | |
# update system, choose default and "ok" for any prompts | |
sudo apt update | |
sudo apt -y dist-upgrade | |
# install NVM, add to path, install node 12 | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash | |
. ~/.bashrc | |
nvm install v12 | |
# ensure node 12 and npm 6 versions are shown here: | |
node -v&&npm -v | |
# install grunt and xsltpro, curl, uidmap and jq | |
npm install -g grunt-cli | |
sudo apt -y install xsltproc curl uidmap jq | |
# install docker and docker compose - note this is from official docker script here https://get.docker.com | |
curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh | |
# in order for docker to boot correctly, restart entire machine | |
sudo reboot | |
# let docker run rootless | |
dockerd-rootless-setuptool.sh install | |
echo "export PATH=/usr/bin:$PATH" >> ~/.bashrc | |
echo "export DOCKER_HOST=unix:///run/user/1000/docker.sock" >> ~/.bashrc | |
. ~/.bashrc | |
# test docker works | |
docker run hello-world | |
# start couchdb container | |
docker run -d -p 5984:5984 -p 5986:5986 --name medic-couchdb -e COUCHDB_USER=medic -e COUCHDB_PASSWORD=password -v ~/cht-docker/local.d:/opt/couchdb/data -v ~/cht-docker/local.d:/opt/couchdb/etc/local.d apache/couchdb:2 | |
# double check node name - should show "nonode@nohost" in JSON | |
curl -X GET "http://medic:password@localhost:5984/_membership" | jq | |
# set couch exports, source bash file and ensure they're set | |
echo "export COUCH_NODE_NAME=nonode@nohost">> ~/.bashrc | |
echo "export COUCH_URL=http://medic:password@localhost:5984/medic">> ~/.bashrc | |
. ~/.bashrc | |
echo $COUCH_NODE_NAME&& echo $COUCH_URL | |
# clone cht-core repo, cd into and install npm requirements | |
git clone https://github.com/medic/cht-core | |
cd cht-core | |
npm ci # warning - may take a looooooong time - 5+ minutes - be patient! | |
# harden couchdb | |
grunt secure-couchdb | |
curl -X PUT "http://medic:password@localhost:5984/_node/$COUCH_NODE_NAME/_config/httpd/WWW-Authenticate" -d '"Basic realm=\"administrator\""' -H "Content-Type: application/json" | |
# start CHT in development mode | |
grunt # in current terminal - wait 5+ min, then at "Waiting..." proceed | |
cd cht-core&&grunt dev-api # in 2nd terminal | |
cd cht-core&&grunt dev-sentinel # in 3rd terminal | |
# todo - add nginx-local-ip steps? | |
# test it! | |
xdg-open http://localhost:5988/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment