CouchDB installation issue on Apple Silicon chip

:man_facepalming: Whoops! I think the docker-compose down errors are coming because I forgot to include both compose files in the command. Can you try:

COUCHDB_USER=medic COUCHDB_PASSWORD=password docker-compose -f docker-compose.yml -f couchdb-override.yml down -v

Then delete everything in ./srv (which now that I think of it, I guess you will not have sudo on macOS, but you can do whatever you need to do remove the whole ./srv directory). And then finally try starting Couch back up again. What you are seeing in Photon is what I would expect from your original errors (Error: System databases do not exist). Something is going wrong with the initial Couch bootstrapping. Hopefully tearing it down and re-trying will get things where they need to be.

Running COUCHDB_USER=medic COUCHDB_PASSWORD=password docker-compose -f docker-compose.yml -f couchdb-override.yml down -v

I am getting this error …

Removing network cht-net
ERROR: error while removing network: network cht-net id 5adca7c9020f5587ee206fab9c360cd96cdca748a0b0e0797783dd5715e4854f has active endpoints

That should be okay (since it will still remove everything else and leave the network). But it does make me wonder what is running that is using cht-net? :thinking: Can you check and see what other Docker containers you have running and if any of them seem to still be connected to cht-net? (For this troubleshooting, I just want to be sure that we are starting from scratch and don’t have other containers running in the background that might be making things weird…)

This is what I get when I run docker network ls

NETWORK ID     NAME                              DRIVER    SCOPE
21ff2a0cae63   bridge                            bridge    local
5adca7c9020f   cht-net                           bridge    local
5ba2152646dd   chtcore-platform-docker_default   bridge    local
34c204a2dcec   django-datta-able_db_network      bridge    local
5af51929442b   django-datta-able_web_network     bridge    local
645aca2d6e8b   host                              host      local
add461084b4f   medic-conf_default                bridge    local
8b99d5b7fd16   none                              null      local

Hmm, docker ps -a might be more helpful to see which containers are actually running (that might be using cht-net). Basically I just want to be sure that no other CouchDB containers of any sort are running.

Work/cht-docker Ā» docker ps -a
CONTAINER ID   IMAGE                                             COMMAND                  CREATED         STATUS                       PORTS                                                                                                                             NAMES
319c2ddc0a71   medicmobile/cht-couchdb:4.5.0-dev.1705914674948   "tini -- /docker-ent…"   29 hours ago    Up 29 hours                  4369/tcp, 5984/tcp, 9100/tcp                                                                                                      cht-core_couchdb_1
ebd1e04265b4   hello-world                                       "/hello"                 7 days ago      Exited (0) 7 days ago                                                                                                                                          elastic_pascal
8427dc99e5a6   apache/couchdb:2                                  "tini -- /docker-ent…"   6 weeks ago     Created                                                                                                                                                        medic-couchdb
039881ecfdfd   hello-world                                       "/hello"                 6 weeks ago     Exited (0) 6 weeks ago                                                                                                                                         naughty_hugle
f83fb283614f   registry.livinggoods.net/cht-core:3.6.0           "docker-entrypoint.s…"   6 weeks ago     Exited (255) 7 days ago      0.0.0.0:5988->5988/tcp, :::5988->5988/tcp                                                                                         chtcore-platform-docker_chtcore_1
19bc33be9131   bitnami/couchdb:3                                 "/opt/bitnami/script…"   6 weeks ago     Exited (255) 7 days ago      0.0.0.0:5984->5984/tcp, :::5984->5984/tcp, 0.0.0.0:9100->9100/tcp, :::9100->9100/tcp, 0.0.0.0:4367->4369/tcp, :::4367->4369/tcp   chtcore-platform-docker_couchdb_1
8b68a14b990e   medic-conf_lg-medic-conf                          "docker-entrypoint.s…"   19 months ago   Exited (255) 19 months ago                                                                                                                                     medic-conf_lg-medic-conf_run_642eda4d2022
9c85428595f9   medic-conf_lg-medic-conf                          "docker-entrypoint.s…"   19 months ago   Created                                                                                                                                                        medic-conf_lg-medic-conf_run_97d172b3916b
fe7d647a1046   medic-conf_lg-medic-conf                          "docker-entrypoint.s…"   2 years ago     Exited (255) 2 years ago                                                                                                                                       medic-conf_lg-medic-conf_run_b80da07d0ce2

Ahh yes, so that cht-core_couchdb_1 container is probably what is still holding onto the cht-net. We definitely want to get rid of that one to avoid confusion.

Also, unless you need it, I would also recommend deleting medic-couchdb to avoid any confusion. Finally, I don’t think it is probably a huge deal, but if you are done with the chtcore-platform-docker project you could also remove these containers: chtcore-platform-docker_couchdb_1 and chtcore-platform-docker_chtcore_1. Then try to spin up a fresh copy of Couch from your ~/cht-docker directory!

COUCHDB_USER=medic COUCHDB_PASSWORD=password docker-compose -f docker-compose.yml -f couchdb-override.yml up -d

I have deleted these containers as recommended and spun up Couch afresh.
Then proceeded to run the following commands sequentially as per the docs npm run build-dev-watch, npm run dev-api and npm run dev-sentinel.
No errors from the terminal. So this is great progress \o/

Though going to the instance on http://localhost:5988/, the site doesn’t load. It’s just ā€œtwitchingā€. See the attached gif below.

ScreenRecording2024-01-26at11.29.46-ezgif.com-video-to-gif-converter

Wow, we cannot catch a break here! :sweat_smile:

Just to double-check, are you opening the page in Chrome/FireFox (and not Safari)? Also do you happen to be running any plugins in the browser for disabling JavaScript, etc? Finally, can you check your browser console logs and see what is erroring in there? Seems like something is going very bad as the webapp tries to bootstrap.

Lastly, out of curiosity, what happens if you try to go directly to http://localhost:5988/admin/ ?

No break FR! :joy::joy:

I’m opening the page on Chrome. I do have a pop-up blocker on Chrome, although disabling it didn’t do anything for this error. Also tested with another browser (Safari) and it also ā€œflickersā€ there as well.

The console is not static enough for me to take a screenshot but the message is somewhat on this line:
OTS parsing error: invalid sfntVersion: 1008813135

Going directly to http://localhost:5988/admin/ still has the same issue.

Very strange! Definitely have not seen this error before. Is there any other context from the console logs that you could share? (Trying to understand what it might be trying to parse…)

From this helpful comment it seems like that error is related to loading a font:

This occurs if you try to load a font, but get HTML content instead (for example a fallback website or error page).

So far I have no theories about why there would be a failure loading fonts. Can you see any suspicious errors in the logs for the CHT api?

Another thing I want to double-check (to make sure we are on the same page) is what version of the code are you trying to build in your local dev environment? Are you on the latest code from master or an earlier commit?

Yeah, I saw the font related comments on GitHub and StackOverflow. On the console the font NatoSans-Regular is also being referenced aside from that OTS parsing error.
Failed to decode downloaded font: http://localhost:5988/fonts/NatoSans-Regular.tff

When I ran docker ps --format '{{.Names}}', I am getting cht-docker_couchdb_1
These are the logs from docker logs cht-docker_couchdb_1 --tail 25

[notice] 2024-01-30T11:46:25.586078Z couchdb@127.0.0.1 <0.14340.143> 6df164a2e2 localhost:5984 172.22.0.1 medic GET /medic/settings? 200 ok 3
[notice] 2024-01-30T11:46:25.591477Z couchdb@127.0.0.1 <0.14109.143> ec536ae469 localhost:5984 172.22.0.1 medic GET /medic/settings? 200 ok 9
[notice] 2024-01-30T11:46:25.602363Z couchdb@127.0.0.1 <0.14539.143> 38b83d58d7 localhost:5984 172.22.0.1 medic GET /medic/_all_docs?include_docs=true&startkey=%22messages-%22&endkey=%22messages-%EF%BF%B0%22 200 ok 20
[notice] 2024-01-30T11:46:25.619882Z couchdb@127.0.0.1 <0.14430.143> eb6dfaed7c localhost:5984 172.22.0.1 medic GET /medic/_all_docs?include_docs=true&startkey=%22messages-%22&endkey=%22messages-%EF%BF%B0%22 200 ok 37
[notice] 2024-01-30T11:46:25.638083Z couchdb@127.0.0.1 <0.14374.143> 80530f5c68 localhost:5984 172.22.0.1 medic GET /medic/branding? 200 ok 1
[notice] 2024-01-30T11:46:25.644506Z couchdb@127.0.0.1 <0.14229.143> 1373b48987 localhost:5984 172.22.0.1 medic GET /medic/branding/favicon.ico?rev=1-096044ecbe81b834da528b2759ec9e92 200 ok 1
[notice] 2024-01-30T11:46:25.645270Z couchdb@127.0.0.1 <0.14528.143> a8557a4596 localhost:5984 172.22.0.1 medic GET /medic/branding/cht-logo.png?rev=1-096044ecbe81b834da528b2759ec9e92 200 ok 2
[notice] 2024-01-30T11:46:25.657995Z couchdb@127.0.0.1 <0.12354.143> 564d246745 localhost:5984 172.22.0.1 medic GET /medic/branding? 200 ok 1
[notice] 2024-01-30T11:46:25.665385Z couchdb@127.0.0.1 <0.14771.143> 58d09a6f19 localhost:5984 172.22.0.1 medic GET /medic/branding/favicon.ico?rev=1-096044ecbe81b834da528b2759ec9e92 200 ok 3
[notice] 2024-01-30T11:46:25.664779Z couchdb@127.0.0.1 <0.14395.143> 1267799a9e localhost:5984 172.22.0.1 medic GET /medic/branding/cht-logo.png?rev=1-096044ecbe81b834da528b2759ec9e92 200 ok 2
[notice] 2024-01-30T11:46:25.722681Z couchdb@127.0.0.1 <0.14195.143> 16a2d4de8d localhost:5984 172.22.0.1 medic GET /medic/settings? 200 ok 21
[notice] 2024-01-30T11:46:25.766353Z couchdb@127.0.0.1 <0.14068.143> d107dbc77b localhost:5984 172.22.0.1 medic GET /medic/settings? 200 ok 63
[notice] 2024-01-30T11:46:25.791878Z couchdb@127.0.0.1 <0.14575.143> 3173d8bdc7 localhost:5984 172.22.0.1 medic GET /medic/_all_docs?include_docs=true&startkey=%22messages-%22&endkey=%22messages-%EF%BF%B0%22 200 ok 90
[notice] 2024-01-30T11:46:25.793738Z couchdb@127.0.0.1 <0.14769.143> 30299f6d36 localhost:5984 172.22.0.1 medic GET /medic/_all_docs?include_docs=true&startkey=%22messages-%22&endkey=%22messages-%EF%BF%B0%22 200 ok 91
[notice] 2024-01-30T11:46:25.870200Z couchdb@127.0.0.1 <0.14293.143> 2b9cdebb61 localhost:5984 172.22.0.1 medic GET /medic/branding? 200 ok 4
[notice] 2024-01-30T11:46:25.870522Z couchdb@127.0.0.1 <0.14781.143> 726d910954 localhost:5984 172.22.0.1 medic GET /medic/branding? 200 ok 5
[notice] 2024-01-30T11:46:25.879591Z couchdb@127.0.0.1 <0.13448.143> 0acf77e7e2 localhost:5984 172.22.0.1 medic GET /medic/branding/cht-logo.png?rev=1-096044ecbe81b834da528b2759ec9e92 200 ok 1
[notice] 2024-01-30T11:46:25.879934Z couchdb@127.0.0.1 <0.14611.143> 578566b32c localhost:5984 172.22.0.1 medic GET /medic/branding/favicon.ico?rev=1-096044ecbe81b834da528b2759ec9e92 200 ok 2
[notice] 2024-01-30T11:46:25.880844Z couchdb@127.0.0.1 <0.14889.143> 021a217ee1 localhost:5984 172.22.0.1 medic GET /medic/branding/cht-logo.png?rev=1-096044ecbe81b834da528b2759ec9e92 200 ok 3
[notice] 2024-01-30T11:46:25.882662Z couchdb@127.0.0.1 <0.14826.143> e80fd40549 localhost:5984 172.22.0.1 medic GET /medic/branding/favicon.ico?rev=1-096044ecbe81b834da528b2759ec9e92 200 ok 4
[notice] 2024-01-30T11:46:25.946305Z couchdb@127.0.0.1 <0.14795.143> 0bc475561f localhost:5984 172.22.0.1 medic GET /medic/settings? 200 ok 4
[notice] 2024-01-30T11:46:25.947830Z couchdb@127.0.0.1 <0.14695.143> 198485639f localhost:5984 172.22.0.1 medic GET /medic/settings? 200 ok 6
[notice] 2024-01-30T11:46:25.970697Z couchdb@127.0.0.1 <0.14502.143> 2699eb75b3 localhost:5984 172.22.0.1 medic GET /medic/_all_docs?include_docs=true&startkey=%22messages-%22&endkey=%22messages-%EF%BF%B0%22 200 ok 29
[notice] 2024-01-30T11:46:25.977816Z couchdb@127.0.0.1 <0.14869.143> d0f0cae20f localhost:5984 172.22.0.1 medic GET /medic/_all_docs?include_docs=true&startkey=%22messages-%22&endkey=%22messages-%EF%BF%B0%22 200 ok 35
[notice] 2024-01-30T11:46:26.029931Z couchdb@127.0.0.1 <0.14692.143> 54feb9c4e2 localhost:5984 172.22.0.1 medic GET /medic/branding? 200 ok 2

I have also shared the logs from running ./compress_and_archive_docker_logs.sh from cht-core/scripts via Slack. If there are other logs needed, you can direct me on how to get them so that we can be able to troubleshoot this.

Also, yes. I am on the ā€˜latest’ master code. I did a fresh clone on 18 January 2024

I just tried to run the local environment by following the documentation above on my Mac M1 Apple Silicon. I am sharing the steps that made it finally work for me. The documentation needs some attention @Esther_Moturi and I am happy to support you making it clearer, and also fixing some errors as per below.

These are the node and npm versions I use locally:

node -v && npm -v
v16.20.2
8.19.4

I then ran (in the root directory of the cht-core project - master branch):

npm ci
npm run build-dev
npm run local-images

I jumped to and followed all the steps in the CouchDB Setup in 4.x for Apple Silicon Chip section, which meant:

  • Edit cht-couchdb.yml with the ports values stated in the doc
  • Add the following env variables in the ~/.zshrc file:
export COUCH_NODE_NAME="nonode@nohost"
export COUCH_URL="http://medic:password@localhost:5984/medic"
export COUCHDB_USER="medic"
export COUCHDB_PASSWORD="password"

@Esther_Moturi the documentation is incorrect for the last two variables (it should be COUCHDB_, not COUCH_), that needs to be fixed.

  • Run source ~/.zshrc
  • I then ran:
cd ~/cht-core/local-build
docker kill $(docker ps -q)
docker-compose -f cht-couchdb.yml up -d

I finally run the three npm run commands in the Developing section, and managed to have the CHT open at http://localhost:5988/ correctly.

@Kymoraa any chance for you to start fresh and follow these steps?

2 Likes

Thanks for this update @andra.
I’ll re-start the process and report back on the progress.

2 Likes

Thanks @andra , I will wait for @Kymoraa’s feedback and try out the provided steps then update the documentation.

1 Like

@Esther_Moturi, @Kymoraa, as from today the master branch is using node v20 and npm v10. The documentation was updated accordingly.

If you are using nvm, you can easily switch between versions via:

nvm alias default 20
nvm use
node -v

Let us know if you encounter any blocker!

1 Like

Hey @andra , after running npm run local-images, I am getting the errors below and I am not getting the local-build folder.

=> ERROR [base_couchdb_build 2/8] COPY --chown=couchdb:couchdb 10-docker-default.ini /opt/couchdb/etc/default.d/ 0.0s
=> ERROR [base_couchdb_build 3/8] COPY --chown=couchdb:couchdb vm.args /opt/couchdb/etc/ 0.0s
=> ERROR [base_couchdb_build 4/8] COPY docker-entrypoint.sh /usr/local/bin 0.0s
=> ERROR [base_couchdb_build 5/8] COPY --chown=couchdb:couchdb set-up-cluster.sh /opt/couchdb/etc/set-up-cluster.sh

@diana, any ideas on what might be the cause of @Esther_Moturi’s errors above?

@Esther_Moturi is there any more context in the terminal output surrounding these errors? Seems like the docker image is failing to build, but it is not clear what the actual errors are… :thinking: