From 43a99e2b7116f89b1bc0ee13b33976d7d62911d8 Mon Sep 17 00:00:00 2001 From: javierg Date: Thu, 15 Aug 2024 09:05:36 -0700 Subject: [PATCH 01/22] require user and password for couch --- entrypoint.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 6f0d2c5..0c2bdc7 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,8 @@ #!/bin/sh echo "Starting Docker..." -sh -c "docker run -d -p 5984:5984 -p 5986:5986 --tmpfs /ram_disk couchdb:$INPUT_COUCHDB_VERSION" + +sh -c "docker run -d -p 5984:5984 -p 5986:5986 COUCHDB_USER=$COUCHDB_USER COUCHDB_PASSWORD=$COUCHDB_PASSWORD --tmpfs /ram_disk couchdb:$INPUT_COUCHDB_VERSION" # CouchDB container name export NAME=`docker ps --format "{{.Names}}" --last 1` From 69e5c8663e1f07b6e0624314b475396aa37ea63e Mon Sep 17 00:00:00 2001 From: javierg Date: Thu, 15 Aug 2024 09:12:05 -0700 Subject: [PATCH 02/22] add erlang native --- entrypoint.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 0c2bdc7..1cac94a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,12 +2,14 @@ echo "Starting Docker..." +ERL_QUERIES="${ERL_NATIVE_QUERY:-false}" + sh -c "docker run -d -p 5984:5984 -p 5986:5986 COUCHDB_USER=$COUCHDB_USER COUCHDB_PASSWORD=$COUCHDB_PASSWORD --tmpfs /ram_disk couchdb:$INPUT_COUCHDB_VERSION" # CouchDB container name export NAME=`docker ps --format "{{.Names}}" --last 1` -docker exec $NAME sh -c 'mkdir -p /opt/couchdb/etc/local.d && echo "[couchdb]\ndatabase_dir = /ram_disk\nview_index_dir = /ram_disk\ndelayed_commits = true\n[httpd]\nsocket_options = [{nodelay, true}]\n[native_query_servers]\nerlang = {couch_native_process, start_link, []}" >> /opt/couchdb/etc/local.d/01-github-action-custom.ini' +docker exec $NAME sh -c 'mkdir -p /opt/couchdb/etc/local.d && echo "[couchdb]\ndatabase_dir = /ram_disk\nview_index_dir = /ram_disk\ndelayed_commits = true\n[httpd]\nsocket_options = [{nodelay, true}]\n[native_query_servers]\nenable_erlang_query_server=$ERL_QUERIES" >> /opt/couchdb/etc/local.d/01-github-action-custom.ini' wait_for_couchdb() { echo "Waiting for CouchDB..." @@ -23,6 +25,6 @@ wait_for_couchdb # Set up system databases echo "Setting up CouchDB system databases..." -docker exec $NAME curl -sS 'http://127.0.0.1:5984/_users' -X PUT -H 'Content-Type: application/json' --data '{"id":"_users","name":"_users"}' > /dev/null -docker exec $NAME curl -sS 'http://127.0.0.1:5984/_global_changes' -X PUT -H 'Content-Type: application/json' --data '{"id":"_global_changes","name":"_global_changes"}' > /dev/null -docker exec $NAME curl -sS 'http://127.0.0.1:5984/_replicator' -X PUT -H 'Content-Type: application/json' --data '{"id":"_replicator","name":"_replicator"}' > /dev/null +docker exec $NAME curl -sS "http://$COUCHDB_USER:$COUCHDB_PASSWORD@localhost:5984/_users" -X PUT -H 'Content-Type: application/json' --data '{"id":"_users","name":"_users"}' > /dev/null +docker exec $NAME curl -sS "http://$COUCHDB_USER:$COUCHDB_PASSWORD@localhost:5984/_global_changes" -X PUT -H 'Content-Type: application/json' --data '{"id":"_global_changes","name":"_global_changes"}' > /dev/null +docker exec $NAME curl -sS "http://$COUCHDB_USER:$COUCHDB_PASSWORD@localhost:5984/_replicator" -X PUT -H 'Content-Type: application/json' --data '{"id":"_replicator","name":"_replicator"}' > /dev/null From 4480bee094ac70a3e0678e11473815437ed6174e Mon Sep 17 00:00:00 2001 From: javierg Date: Thu, 15 Aug 2024 09:16:51 -0700 Subject: [PATCH 03/22] add nodename --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 1cac94a..65c1563 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,7 +4,7 @@ echo "Starting Docker..." ERL_QUERIES="${ERL_NATIVE_QUERY:-false}" -sh -c "docker run -d -p 5984:5984 -p 5986:5986 COUCHDB_USER=$COUCHDB_USER COUCHDB_PASSWORD=$COUCHDB_PASSWORD --tmpfs /ram_disk couchdb:$INPUT_COUCHDB_VERSION" +sh -c "docker run -d -p 5984:5984 -p 5986:5986 NODENAME=$NODENAME COUCHDB_USER=$COUCHDB_USER COUCHDB_PASSWORD=$COUCHDB_PASSWORD --tmpfs /ram_disk couchdb:$INPUT_COUCHDB_VERSION" # CouchDB container name export NAME=`docker ps --format "{{.Names}}" --last 1` From 6416a4d7b50b9610b793563155a2f5bebab3d0fd Mon Sep 17 00:00:00 2001 From: javierg Date: Thu, 15 Aug 2024 09:26:13 -0700 Subject: [PATCH 04/22] quote env vars --- entrypoint.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 65c1563..0eef7f9 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,15 +1,14 @@ #!/bin/sh echo "Starting Docker..." - ERL_QUERIES="${ERL_NATIVE_QUERY:-false}" -sh -c "docker run -d -p 5984:5984 -p 5986:5986 NODENAME=$NODENAME COUCHDB_USER=$COUCHDB_USER COUCHDB_PASSWORD=$COUCHDB_PASSWORD --tmpfs /ram_disk couchdb:$INPUT_COUCHDB_VERSION" +sh -c "docker run -d -p 5984:5984 -p 5986:5986 NODENAME=${NODENAME} COUCHDB_USER=${COUCHDB_USER} COUCHDB_PASSWORD=${COUCHDB_PASSWORD} --tmpfs /ram_disk couchdb:${INPUT_COUCHDB_VERSION}" # CouchDB container name export NAME=`docker ps --format "{{.Names}}" --last 1` -docker exec $NAME sh -c 'mkdir -p /opt/couchdb/etc/local.d && echo "[couchdb]\ndatabase_dir = /ram_disk\nview_index_dir = /ram_disk\ndelayed_commits = true\n[httpd]\nsocket_options = [{nodelay, true}]\n[native_query_servers]\nenable_erlang_query_server=$ERL_QUERIES" >> /opt/couchdb/etc/local.d/01-github-action-custom.ini' +docker exec $NAME sh -c "mkdir -p /opt/couchdb/etc/local.d && echo \"[couchdb]\ndatabase_dir = /ram_disk\nview_index_dir = /ram_disk\ndelayed_commits = true\n[httpd]\nsocket_options = [{nodelay, true}]\n[native_query_servers]\nenable_erlang_query_server=${ERL_QUERIES}\" >> /opt/couchdb/etc/local.d/01-github-action-custom.ini" wait_for_couchdb() { echo "Waiting for CouchDB..." @@ -25,6 +24,6 @@ wait_for_couchdb # Set up system databases echo "Setting up CouchDB system databases..." -docker exec $NAME curl -sS "http://$COUCHDB_USER:$COUCHDB_PASSWORD@localhost:5984/_users" -X PUT -H 'Content-Type: application/json' --data '{"id":"_users","name":"_users"}' > /dev/null -docker exec $NAME curl -sS "http://$COUCHDB_USER:$COUCHDB_PASSWORD@localhost:5984/_global_changes" -X PUT -H 'Content-Type: application/json' --data '{"id":"_global_changes","name":"_global_changes"}' > /dev/null -docker exec $NAME curl -sS "http://$COUCHDB_USER:$COUCHDB_PASSWORD@localhost:5984/_replicator" -X PUT -H 'Content-Type: application/json' --data '{"id":"_replicator","name":"_replicator"}' > /dev/null +docker exec $NAME curl -sS "http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@localhost:5984/_users" -X PUT -H 'Content-Type: application/json' --data '{"id":"_users","name":"_users"}' > /dev/null +docker exec $NAME curl -sS "http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@localhost:5984/_global_changes" -X PUT -H 'Content-Type: application/json' --data '{"id":"_global_changes","name":"_global_changes"}' > /dev/null +docker exec $NAME curl -sS "http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@localhost:5984/_replicator" -X PUT -H 'Content-Type: application/json' --data '{"id":"_replicator","name":"_replicator"}' > /dev/null From e234f2fa1c0bebacd160950a3a9b5dac5ed19f7c Mon Sep 17 00:00:00 2001 From: javierg Date: Thu, 15 Aug 2024 09:31:26 -0700 Subject: [PATCH 05/22] really quote env vars --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 0eef7f9..9999fc7 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,7 +3,7 @@ echo "Starting Docker..." ERL_QUERIES="${ERL_NATIVE_QUERY:-false}" -sh -c "docker run -d -p 5984:5984 -p 5986:5986 NODENAME=${NODENAME} COUCHDB_USER=${COUCHDB_USER} COUCHDB_PASSWORD=${COUCHDB_PASSWORD} --tmpfs /ram_disk couchdb:${INPUT_COUCHDB_VERSION}" +sh -c "docker run -d -p 5984:5984 -p 5986:5986 -e \"NODENAME=${NODENAME}\" -e \"COUCHDB_USER=${COUCHDB_USER}\" -e \"COUCHDB_PASSWORD=${COUCHDB_PASSWORD}\" --tmpfs /ram_disk couchdb:${INPUT_COUCHDB_VERSION}" # CouchDB container name export NAME=`docker ps --format "{{.Names}}" --last 1` From c435207e824f4e1070aada7651215eb77cdfc3fb Mon Sep 17 00:00:00 2001 From: javierg Date: Thu, 15 Aug 2024 11:52:07 -0700 Subject: [PATCH 06/22] update tests --- .github/workflows/test.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ffdd645..6ecdbba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,17 +9,23 @@ on: jobs: tests: runs-on: ubuntu-latest + strategy: + matrix: + couchdb: ["3.3", "3.2", "3.1", "2.3"] steps: - uses: actions/checkout@v1 - name: Set up CouchDB uses: ./ with: - couchdb version: '2.3.1' + couchdb version: ${{ matrix.couchdb }} + env: + COUCHDB_USERNAME: admin + COUCHDB_PASSOWRD: password - name: Test that CouchDB can be accessed - run: curl -sS -f http://127.0.0.1:5984/ + run: curl -sS -f http://admin:password@127.0.0.1:5984/ - name: Test that system databases are there - run: curl -sS -f http://127.0.0.1:5984/_users + run: curl -sS -f http://admin:password@127.0.0.1:5984/_users - name: Test that the Erlang query server is enabled run: | - curl -sS -f 'http://127.0.0.1:5984/_users/_design/test' -X PUT -H 'Content-Type: application/json' --data '{"views":{"test":{"map":"fun({Doc}) -> Emit(proplists:get_value(<<\"name\">>, Doc, null), 1) end."}},"language":"erlang"}' - curl -sS -f 'http://127.0.0.1:5984/_users/_design/test/_view/test' + curl -sS -f 'http://admin:password@127.0.0.1:5984/_users/_design/test' -X PUT -H 'Content-Type: application/json' --data '{"views":{"test":{"map":"fun({Doc}) -> Emit(proplists:get_value(<<\"name\">>, Doc, null), 1) end."}},"language":"erlang"}' + curl -sS -f 'http://admin:password@127.0.0.1:5984/_users/_design/test/_view/test' From be8afdb9799106d366e3dae490f67b2194a3f29d Mon Sep 17 00:00:00 2001 From: javierg Date: Thu, 15 Aug 2024 11:58:05 -0700 Subject: [PATCH 07/22] prepare tests --- .github/workflows/test.yml | 2 +- README.md | 3 +++ entrypoint.sh | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6ecdbba..1e7b80f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,7 @@ jobs: with: couchdb version: ${{ matrix.couchdb }} env: - COUCHDB_USERNAME: admin + COUCHDB_USER: admin COUCHDB_PASSOWRD: password - name: Test that CouchDB can be accessed run: curl -sS -f http://admin:password@127.0.0.1:5984/ diff --git a/README.md b/README.md index 770553f..43f5eae 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@ steps: uses: "cobot/couchdb-action@master" with: couchdb version: '2.3.1' + env: + COUCHDB_USER: admin + COUCHDB_PASSWORD: password - name: Do something run: | curl http://127.0.0.1:5984/ diff --git a/entrypoint.sh b/entrypoint.sh index 9999fc7..ed162da 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,6 +2,7 @@ echo "Starting Docker..." ERL_QUERIES="${ERL_NATIVE_QUERY:-false}" +NODENAME="${NODENAME}:-localhost" sh -c "docker run -d -p 5984:5984 -p 5986:5986 -e \"NODENAME=${NODENAME}\" -e \"COUCHDB_USER=${COUCHDB_USER}\" -e \"COUCHDB_PASSWORD=${COUCHDB_PASSWORD}\" --tmpfs /ram_disk couchdb:${INPUT_COUCHDB_VERSION}" From e8cfb95e24172091c4d87abfce989c9324d0e247 Mon Sep 17 00:00:00 2001 From: javierg Date: Thu, 15 Aug 2024 12:03:58 -0700 Subject: [PATCH 08/22] switch host --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1e7b80f..41b653f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,10 +22,10 @@ jobs: COUCHDB_USER: admin COUCHDB_PASSOWRD: password - name: Test that CouchDB can be accessed - run: curl -sS -f http://admin:password@127.0.0.1:5984/ + run: curl -sS -f http://admin:password@localhost:5984/ - name: Test that system databases are there - run: curl -sS -f http://admin:password@127.0.0.1:5984/_users + run: curl -sS -f http://admin:password@localhost:5984/_users - name: Test that the Erlang query server is enabled run: | - curl -sS -f 'http://admin:password@127.0.0.1:5984/_users/_design/test' -X PUT -H 'Content-Type: application/json' --data '{"views":{"test":{"map":"fun({Doc}) -> Emit(proplists:get_value(<<\"name\">>, Doc, null), 1) end."}},"language":"erlang"}' - curl -sS -f 'http://admin:password@127.0.0.1:5984/_users/_design/test/_view/test' + curl -sS -f 'http://admin:password@localhost:5984/_users/_design/test' -X PUT -H 'Content-Type: application/json' --data '{"views":{"test":{"map":"fun({Doc}) -> Emit(proplists:get_value(<<\"name\">>, Doc, null), 1) end."}},"language":"erlang"}' + curl -sS -f 'http://admin:password@localhost:5984/_users/_design/test/_view/test' From 60448d77dc27bdc8ebd8208dda8d0710d0322686 Mon Sep 17 00:00:00 2001 From: javierg Date: Thu, 15 Aug 2024 12:22:02 -0700 Subject: [PATCH 09/22] fix typo on couchdb password --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 41b653f..e6b4b4a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,14 +13,14 @@ jobs: matrix: couchdb: ["3.3", "3.2", "3.1", "2.3"] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Set up CouchDB uses: ./ with: couchdb version: ${{ matrix.couchdb }} env: COUCHDB_USER: admin - COUCHDB_PASSOWRD: password + COUCHDB_PASSWORD: password - name: Test that CouchDB can be accessed run: curl -sS -f http://admin:password@localhost:5984/ - name: Test that system databases are there From e99eaace2680cbe06479633d45d1c9356e240c7c Mon Sep 17 00:00:00 2001 From: javierg Date: Thu, 15 Aug 2024 12:32:26 -0700 Subject: [PATCH 10/22] verify error on test --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e6b4b4a..069927e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,4 +28,4 @@ jobs: - name: Test that the Erlang query server is enabled run: | curl -sS -f 'http://admin:password@localhost:5984/_users/_design/test' -X PUT -H 'Content-Type: application/json' --data '{"views":{"test":{"map":"fun({Doc}) -> Emit(proplists:get_value(<<\"name\">>, Doc, null), 1) end."}},"language":"erlang"}' - curl -sS -f 'http://admin:password@localhost:5984/_users/_design/test/_view/test' + curl -sS -f 'http://admin:password@localhost:5984/_users/_design/test/_view/test' -v From e06d72a8df0d4fd3096c504f5087382dff9ba19d Mon Sep 17 00:00:00 2001 From: javierg Date: Thu, 15 Aug 2024 13:53:58 -0700 Subject: [PATCH 11/22] check native queries config --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 069927e..dbacea0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,5 +27,6 @@ jobs: run: curl -sS -f http://admin:password@localhost:5984/_users - name: Test that the Erlang query server is enabled run: | + curl -X GET 'http://admin:password@localhost:5984/_node/couchdb2@localhost/_config/native_query_servers/enable_erlang_query_server' curl -sS -f 'http://admin:password@localhost:5984/_users/_design/test' -X PUT -H 'Content-Type: application/json' --data '{"views":{"test":{"map":"fun({Doc}) -> Emit(proplists:get_value(<<\"name\">>, Doc, null), 1) end."}},"language":"erlang"}' curl -sS -f 'http://admin:password@localhost:5984/_users/_design/test/_view/test' -v From 59ac5adacdcb725fd7ce4a28ea1cfd482a933000 Mon Sep 17 00:00:00 2001 From: javierg Date: Thu, 15 Aug 2024 13:55:19 -0700 Subject: [PATCH 12/22] right node name --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dbacea0..d3b4eff 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,6 +27,6 @@ jobs: run: curl -sS -f http://admin:password@localhost:5984/_users - name: Test that the Erlang query server is enabled run: | - curl -X GET 'http://admin:password@localhost:5984/_node/couchdb2@localhost/_config/native_query_servers/enable_erlang_query_server' + curl -X GET 'http://admin:password@localhost:5984/_node/couchdb@localhost/_config/native_query_servers/enable_erlang_query_server' curl -sS -f 'http://admin:password@localhost:5984/_users/_design/test' -X PUT -H 'Content-Type: application/json' --data '{"views":{"test":{"map":"fun({Doc}) -> Emit(proplists:get_value(<<\"name\">>, Doc, null), 1) end."}},"language":"erlang"}' curl -sS -f 'http://admin:password@localhost:5984/_users/_design/test/_view/test' -v From 75a2b681544f7f51c85ab2d6d4f3182cfb69de8c Mon Sep 17 00:00:00 2001 From: javierg Date: Thu, 15 Aug 2024 14:11:33 -0700 Subject: [PATCH 13/22] check node name --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d3b4eff..219436d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,6 +19,7 @@ jobs: with: couchdb version: ${{ matrix.couchdb }} env: + NODENAME: localhost COUCHDB_USER: admin COUCHDB_PASSWORD: password - name: Test that CouchDB can be accessed @@ -27,6 +28,6 @@ jobs: run: curl -sS -f http://admin:password@localhost:5984/_users - name: Test that the Erlang query server is enabled run: | - curl -X GET 'http://admin:password@localhost:5984/_node/couchdb@localhost/_config/native_query_servers/enable_erlang_query_server' + curl -X GET 'http://admin:password@localhost:5984/_membership' curl -sS -f 'http://admin:password@localhost:5984/_users/_design/test' -X PUT -H 'Content-Type: application/json' --data '{"views":{"test":{"map":"fun({Doc}) -> Emit(proplists:get_value(<<\"name\">>, Doc, null), 1) end."}},"language":"erlang"}' curl -sS -f 'http://admin:password@localhost:5984/_users/_design/test/_view/test' -v From 072327a28170cc09332ad0be136adf7c5a2c4b21 Mon Sep 17 00:00:00 2001 From: javierg Date: Thu, 15 Aug 2024 14:13:09 -0700 Subject: [PATCH 14/22] fix nodename --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index ed162da..e11a585 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,7 +2,7 @@ echo "Starting Docker..." ERL_QUERIES="${ERL_NATIVE_QUERY:-false}" -NODENAME="${NODENAME}:-localhost" +NODENAME="${NODENAME:-localhost}" sh -c "docker run -d -p 5984:5984 -p 5986:5986 -e \"NODENAME=${NODENAME}\" -e \"COUCHDB_USER=${COUCHDB_USER}\" -e \"COUCHDB_PASSWORD=${COUCHDB_PASSWORD}\" --tmpfs /ram_disk couchdb:${INPUT_COUCHDB_VERSION}" From 4dd1767985563110e8475829a05587a1285905f9 Mon Sep 17 00:00:00 2001 From: javierg Date: Thu, 15 Aug 2024 14:15:43 -0700 Subject: [PATCH 15/22] check erl version --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 219436d..eaf43b2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,6 +28,6 @@ jobs: run: curl -sS -f http://admin:password@localhost:5984/_users - name: Test that the Erlang query server is enabled run: | - curl -X GET 'http://admin:password@localhost:5984/_membership' + curl -X GET 'http://admin:password@localhost:5984/_node/couchdb@localhost/_config/native_query_servers/enable_erlang_query_server' curl -sS -f 'http://admin:password@localhost:5984/_users/_design/test' -X PUT -H 'Content-Type: application/json' --data '{"views":{"test":{"map":"fun({Doc}) -> Emit(proplists:get_value(<<\"name\">>, Doc, null), 1) end."}},"language":"erlang"}' curl -sS -f 'http://admin:password@localhost:5984/_users/_design/test/_view/test' -v From 9b55a1f1501d612483ca5d1381f62b5cfdec1273 Mon Sep 17 00:00:00 2001 From: javierg Date: Thu, 15 Aug 2024 14:20:35 -0700 Subject: [PATCH 16/22] set erlang queries per default --- .github/workflows/test.yml | 1 + entrypoint.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eaf43b2..db2ed48 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,6 +20,7 @@ jobs: couchdb version: ${{ matrix.couchdb }} env: NODENAME: localhost + ERL_NATOVE_QUERY: true COUCHDB_USER: admin COUCHDB_PASSWORD: password - name: Test that CouchDB can be accessed diff --git a/entrypoint.sh b/entrypoint.sh index e11a585..1a39357 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/sh echo "Starting Docker..." -ERL_QUERIES="${ERL_NATIVE_QUERY:-false}" +ERL_QUERIES="${ERL_NATIVE_QUERY:-true}" NODENAME="${NODENAME:-localhost}" sh -c "docker run -d -p 5984:5984 -p 5986:5986 -e \"NODENAME=${NODENAME}\" -e \"COUCHDB_USER=${COUCHDB_USER}\" -e \"COUCHDB_PASSWORD=${COUCHDB_PASSWORD}\" --tmpfs /ram_disk couchdb:${INPUT_COUCHDB_VERSION}" From 605521959c27f1dd2d47c2201e80a1d046d8911f Mon Sep 17 00:00:00 2001 From: javierg Date: Thu, 15 Aug 2024 14:22:07 -0700 Subject: [PATCH 17/22] remove debug line --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index db2ed48..db132ad 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,6 +29,5 @@ jobs: run: curl -sS -f http://admin:password@localhost:5984/_users - name: Test that the Erlang query server is enabled run: | - curl -X GET 'http://admin:password@localhost:5984/_node/couchdb@localhost/_config/native_query_servers/enable_erlang_query_server' curl -sS -f 'http://admin:password@localhost:5984/_users/_design/test' -X PUT -H 'Content-Type: application/json' --data '{"views":{"test":{"map":"fun({Doc}) -> Emit(proplists:get_value(<<\"name\">>, Doc, null), 1) end."}},"language":"erlang"}' curl -sS -f 'http://admin:password@localhost:5984/_users/_design/test/_view/test' -v From 3a12c3cc06ff109d345356c1a2a14e2001cd8634 Mon Sep 17 00:00:00 2001 From: javierg Date: Fri, 28 Nov 2025 08:44:47 -0800 Subject: [PATCH 18/22] improve error messages --- entrypoint.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 1a39357..207bc4e 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -11,15 +11,23 @@ export NAME=`docker ps --format "{{.Names}}" --last 1` docker exec $NAME sh -c "mkdir -p /opt/couchdb/etc/local.d && echo \"[couchdb]\ndatabase_dir = /ram_disk\nview_index_dir = /ram_disk\ndelayed_commits = true\n[httpd]\nsocket_options = [{nodelay, true}]\n[native_query_servers]\nenable_erlang_query_server=${ERL_QUERIES}\" >> /opt/couchdb/etc/local.d/01-github-action-custom.ini" + wait_for_couchdb() { - echo "Waiting for CouchDB..." hostip=$(ip route show | awk '/default/ {print $3}') + echo "Waiting for CouchDB at ${hostip}..." + + for i in {1..60}; do + if curl -s http://$hostip:5984/ >/dev/null; then + echo "CouchDB is up" + return 0 + fi - while ! curl -f http://$hostip:5984/ &> /dev/null - do - echo "." + echo "Still waiting ($i)..." sleep 1 done + + echo "CouchDB did not become available after 60 seconds" + exit 1 } wait_for_couchdb From 98c9cd0680f0843adc52b4cf63eb3319aa4dcaa0 Mon Sep 17 00:00:00 2001 From: javierg Date: Fri, 28 Nov 2025 08:58:28 -0800 Subject: [PATCH 19/22] add debug curl --- entrypoint.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 207bc4e..8ccbefa 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -16,6 +16,8 @@ wait_for_couchdb() { hostip=$(ip route show | awk '/default/ {print $3}') echo "Waiting for CouchDB at ${hostip}..." + curl -I http://$hostip:5984/ + for i in {1..60}; do if curl -s http://$hostip:5984/ >/dev/null; then echo "CouchDB is up" From 604a5422cca3b28d94e031a597ec09648b7ecb06 Mon Sep 17 00:00:00 2001 From: javierg Date: Fri, 28 Nov 2025 09:09:46 -0800 Subject: [PATCH 20/22] try docket host --- entrypoint.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 8ccbefa..6665ff2 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -13,7 +13,12 @@ docker exec $NAME sh -c "mkdir -p /opt/couchdb/etc/local.d && echo \"[couchdb]\n wait_for_couchdb() { - hostip=$(ip route show | awk '/default/ {print $3}') + if getent hosts host.docker.internal >/dev/null 2>&1; then + hostip=host.docker.internal + else + hostip=$(ip route | awk '/default/ {print $3}') + fi + echo "Waiting for CouchDB at ${hostip}..." curl -I http://$hostip:5984/ From 12f8048aef7541fbdbd16f7cc5b4f746eff004a0 Mon Sep 17 00:00:00 2001 From: javierg Date: Fri, 28 Nov 2025 09:16:08 -0800 Subject: [PATCH 21/22] try localhost --- entrypoint.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 6665ff2..6e0edfd 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -11,7 +11,6 @@ export NAME=`docker ps --format "{{.Names}}" --last 1` docker exec $NAME sh -c "mkdir -p /opt/couchdb/etc/local.d && echo \"[couchdb]\ndatabase_dir = /ram_disk\nview_index_dir = /ram_disk\ndelayed_commits = true\n[httpd]\nsocket_options = [{nodelay, true}]\n[native_query_servers]\nenable_erlang_query_server=${ERL_QUERIES}\" >> /opt/couchdb/etc/local.d/01-github-action-custom.ini" - wait_for_couchdb() { if getent hosts host.docker.internal >/dev/null 2>&1; then hostip=host.docker.internal @@ -21,7 +20,7 @@ wait_for_couchdb() { echo "Waiting for CouchDB at ${hostip}..." - curl -I http://$hostip:5984/ + curl -I http://localhost:5984/ for i in {1..60}; do if curl -s http://$hostip:5984/ >/dev/null; then From ead3b24edf1a8b86eec54cdef03b4cd19cc2402e Mon Sep 17 00:00:00 2001 From: javierg Date: Fri, 28 Nov 2025 09:19:06 -0800 Subject: [PATCH 22/22] try tobind 0 --- entrypoint.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 6e0edfd..86e61b2 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -9,18 +9,14 @@ sh -c "docker run -d -p 5984:5984 -p 5986:5986 -e \"NODENAME=${NODENAME}\" -e \" # CouchDB container name export NAME=`docker ps --format "{{.Names}}" --last 1` -docker exec $NAME sh -c "mkdir -p /opt/couchdb/etc/local.d && echo \"[couchdb]\ndatabase_dir = /ram_disk\nview_index_dir = /ram_disk\ndelayed_commits = true\n[httpd]\nsocket_options = [{nodelay, true}]\n[native_query_servers]\nenable_erlang_query_server=${ERL_QUERIES}\" >> /opt/couchdb/etc/local.d/01-github-action-custom.ini" +docker exec $NAME sh -c "mkdir -p /opt/couchdb/etc/local.d && echo \"[couchdb]\ndatabase_dir = /ram_disk\nview_index_dir = /ram_disk\ndelayed_commits = true\n[httpd]\nsocket_options = [{nodelay, true}]\nbind_address = 0.0.0.0\n[native_query_servers]\nenable_erlang_query_server=${ERL_QUERIES}\" >> /opt/couchdb/etc/local.d/01-github-action-custom.ini" wait_for_couchdb() { - if getent hosts host.docker.internal >/dev/null 2>&1; then - hostip=host.docker.internal - else - hostip=$(ip route | awk '/default/ {print $3}') - fi + hostip=$(ip route | awk '/default/ {print $3}') echo "Waiting for CouchDB at ${hostip}..." - curl -I http://localhost:5984/ + curl -I http://$hostip:5984/ for i in {1..60}; do if curl -s http://$hostip:5984/ >/dev/null; then