Hi @Esther_Moturi - thanks for reporting the issue with our npm build scripts.
What is your end goal youâre looking to achieve? Happy to help either way, but sometimes itâs helpful to know where someone is heading so maybe we can find an alternate path to their destination.
Checking on my Ubuntu x86 system, I can confrim this script works. Hereâs what you would see if it were able to continue past your error:
To build the images correctly, you must first locally build webapp. From the looks of the error, some code tries to copy webapp compiled source code and complains it canât find it.
Please try to run the following commands in the root folder:
Hey @mrjones , the goal is to setup couchDB in CHT 4.x, I am using node: âv18.3.0â, npm: â8.11.0â. I will try and downgrade my node version and see if it works.
Can you please try deleting the â/Users/esthermoturi/cht-core/build/ddocs/medic-db/.DS_Storeâ folder? Our build script expects every folder in ddocs to be a CouchDb view descriptor, and MacOS is adding these additional folders every time you navigate to it (source).
I initially had the same error as @Esther_Moturi but upon running the commands you suggested npm ci, npm run build-dev then npm run local-images, I am now getting the error below.
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 460B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 266B 0.0s
=> ERROR [internal] load metadata for docker.io/library/alpine:3.15 1.7s
------
> [internal] load metadata for docker.io/library/alpine:3.15:
------
failed to solve with frontend dockerfile.v0: failed to create LLB definition: rpc error: code = Unknown desc = open /Users/jackiemoraa/.docker/.token_seed: permission denied
/Users/jackiemoraa/Documents/Work/cht-core/scripts/build/index.js:201
return reject(new Error(`${command} exited with ${code}`));
^
Error: docker exited with 1
at ChildProcess.<anonymous> (/Users/jackiemoraa/Documents/Work/cht-core/scripts/build/index.js:201:21)
at ChildProcess.emit (node:events:527:28)
at maybeClose (node:internal/child_process:1092:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
Confirm you have these four files in the local-build folder: docker-compose.yml , cht-core.yml , cht-couchdb.yml and cht-couchdb-clustered.yml
Use âdocker scanâ to run Snyk tests against images to find vulnerabilities and learn how to fix them
build-service-images: done
I only have the cht-x files. I am missing the docker-compose.yml file.
Should I manually add it?
However, I am a bit lost. If I manually create the docker-compose.yml file, I will be going back up in the documentation process, right?
So, what goes into the docker-compose.yml file and couchdb-override.yml file?
cd ~/cht-docker
COUCHDB_USER=medic COUCHDB_PASSWORD=password docker-compose -f docker-compose.yml -f couchdb-override.yml up -d
or do I need to jump back down and execute this:
Set environment variables required by npm and node
echo "export COUCH_NODE_NAME=nonode@nohost">> ~/.$(basename $SHELL)rc
echo "export COUCH_URL=http://medic:password@localhost:5984/medic">> ~/.$(basename $SHELL)rc
. ~/.$(basename $SHELL)rc
echo "export COUCH_DB_USER=medic">> ~/.$(basename $SHELL)rc
echo "export COUCH_DB_PASSWORD=password">> ~/.$(basename $SHELL)rc
Then followed by: In your terminal, navigate inside the `local-build` folder, stop any running Docker containers and start the CHT Docker containers:
cd ~/cht-core/local-build
docker kill $(docker ps -q)
docker-compose -f cht-couchdb.yml up -d
Okay, yeah, I see that the docs get a bit confused here.
I do not have a Mac to be able to confirm this, but I think the most simple way to get things running is to do the steps in âCouchDB Setup in CHT 4.xâ, but stop before running the docker-compose -f docker-compose.yml -f couchdb-override.yml up -d command. Then:
Hey @jkuester
I had already run npm run local-images and got the cht-xxx.yml files generated.
So now, I have gone back and manually created the docker-compose.yml and couchdb-override.yml in a cht-docker directory and I have pasted the code from cht-couchdb.yml to both these files as advised.
Running the command from cht-docker, I donât get errors but warnings since these variables are not set.
WARNING: The COUCHDB_SECRET variable is not set. Defaulting to a blank string.
WARNING: The COUCHDB_UUID variable is not set. Defaulting to a blank string.
Then back to cht-core directory, I have run npm run build-dev-watch. I get to the waiting ... point. On the second terminal, running npm run dev-api, I get this:
Work/cht-core [masterâ] » npm run dev-api
> medic@4.5.0 dev-api
> ./scripts/build/copy-static-files.sh && TZ=UTC nodemon --inspect=0.0.0.0:9229 --ignore 'api/build/static' --ignore 'api/build/public' --watch api --watch 'shared-libs/**/src/**' api/server.js -- --allow-cors
copy-static-files: copying
copy-static-files: done
[nodemon] 3.0.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): api/**/* shared-libs/**/src/**
[nodemon] watching extensions: js,mjs,cjs,json
[nodemon] starting `node --inspect=0.0.0.0:9229 api/server.js --allow-cors`
Debugger listening on ws://0.0.0.0:9229/6db01c11-7ce3-471e-b59f-5f86c4b8a036
For help, see: https://nodejs.org/en/docs/inspector
2024-01-24T12:10:59.698 INFO: Running server checksâŠ
Node Environment Options: 'undefined'
Node Version: 16.15.0 in development mode
CouchDB Version: 3.3.3
Error: System databases do not exist
at checkCluster (/Users/jackiemoraa/Documents/Work/cht-core/shared-libs/server-checks/src/checks.js:102:11)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async couchDbCheck (/Users/jackiemoraa/Documents/Work/cht-core/shared-libs/server-checks/src/checks.js:135:7)
at async /Users/jackiemoraa/Documents/Work/cht-core/api/server.js:23:5
Weâre making progress, but I am still not successful.
For a local dev instance, I believe this is fine. (I do not set values for either of these when running locally.)
Error: System databases do not exist
This is much more puzzling. Seems to be some kind of corruption in Couch, or in-completion in the the DB setup⊠I think the next thing to try is tearing down Couch and re-running it. So from the cht-docker directory:
docker-compose down -v
sudo rm -rf srv/
COUCHDB_USER=medic COUCHDB_PASSWORD=password docker-compose -f docker-compose.yml -f couchdb-override.yml up -d
(Make sure to include both the docker-compose.yml and the couchdb-override.yml in the docker-compose up command. I have seem behavior similar to what you describe when I forgot to include the couchdb-override.ymlâŠ)
Once the Couch container spins up successfully, you should see something like this in the logs for that container:
Also, you should be able to navigate to http://localhost:5984/_utils/ and login to the Fauxton interface. Before starting the CHT api server, the only DBs you should see in Fauxton are _global_changes, _replicator, and _users. Finally, if all of that looks good, then you can try going back to cht-core again and running npm run dev-api again to start the api server (no need to re-run build-dev-watch until you make actual changes to the webapp code).
My calendar is wide open today, so please feel free to DM if you want to have a quick call and work through any of these issues!
Running docker-compose down -v from the cht-docker directory I immediately get this error
Work/cht-docker » docker-compose down -v
ERROR: Missing mandatory value for "environment" option interpolating
['COUCHDB_USER=${COUCHDB_USER:-admin}',
'COUCHDB_PASSWORD=${COUCHDB_PASSWORD:?COUCHDB_PASSWORD must be set}',
'COUCHDB_SECRET=${COUCHDB_SECRET}', 'COUCHDB_UUID=${COUCHDB_UUID}',
'SVC_NAME=${SVC_NAME:-couchdb}', 'COUCHDB_LOG_LEVEL=${COUCHDB_LOG_LEVEL:
info}'] in service "couchdb": COUCHDB_PASSWORD must be set
This is what I have in the environment as per the docs
So might the difference in the variable name as in the docker-compose.yml file vs the environment e.g., COUCHDB_USER vs COUCH_DB_USER respectively have anything to do with the error? I am not sureâŠ