From c3ed911abcec2386811a6afb36ab42c5cc4de064 Mon Sep 17 00:00:00 2001 From: Jonathan Hall Date: Mon, 25 Dec 2023 20:14:59 +0100 Subject: [PATCH] Configure docker-compose to start CouchDB for tests --- docker-compose.yml | 151 ++++++++++++++++++++++++++++++++++++++ script/complete_couch2.sh | 9 ++- 2 files changed, 156 insertions(+), 4 deletions(-) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..acdfd5ba0 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,151 @@ +version: '3.1' + +x-common-env: &common-env + COUCHDB_USER: admin + COUCHDB_PASSWORD: abc123 + +x-healthcheck: &healthcheck + test: ["CMD-SHELL", "curl -f http://localhost:5984/_up || exit 1"] + interval: 1m + timeout: 2s + retries: 3 + start_period: 10s + +services: + couch22: + container_name: couch22 + image: couchdb:2.2.0 + restart: always + environment: + <<: *common-env + ports: + - "6002:5984" + healthcheck: + <<: *healthcheck + couch22setup: + image: curlimages/curl:8.5.0 + restart: "no" + environment: + <<: *common-env + depends_on: + couch22: + condition: service_healthy + volumes: + - ./script/complete_couch2.sh:/complete_couch2.sh + entrypoint: /complete_couch2.sh + command: http://couch22:5984/ + + couch23: + container_name: couch23 + image: couchdb:2.3.1 + restart: always + environment: + <<: *common-env + ports: + - "6003:5984" + healthcheck: + <<: *healthcheck + couch23setup: + image: curlimages/curl:8.5.0 + restart: "no" + environment: + <<: *common-env + depends_on: + couch22: + condition: service_healthy + volumes: + - ./script/complete_couch2.sh:/complete_couch2.sh + entrypoint: /complete_couch2.sh + command: http://couch23:5984/ + + couch30: + container_name: couch30 + image: couchdb:3.0.0 + restart: always + environment: + <<: *common-env + ports: + - "6004:5984" + healthcheck: + <<: *healthcheck + couch30setup: + image: curlimages/curl:8.5.0 + restart: "no" + environment: + <<: *common-env + depends_on: + couch22: + condition: service_healthy + volumes: + - ./script/complete_couch2.sh:/complete_couch2.sh + entrypoint: /complete_couch2.sh + command: http://couch30:5984/ + + couch31: + container_name: couch31 + image: couchdb:3.1.2 + restart: always + environment: + <<: *common-env + ports: + - "6005:5984" + healthcheck: + <<: *healthcheck + couch31setup: + image: curlimages/curl:8.5.0 + restart: "no" + environment: + <<: *common-env + depends_on: + couch22: + condition: service_healthy + volumes: + - ./script/complete_couch2.sh:/complete_couch2.sh + entrypoint: /complete_couch2.sh + command: http://couch31:5984/ + + couch32: + container_name: couch32 + image: couchdb:3.2.3 + restart: always + environment: + <<: *common-env + ports: + - "6006:5984" + healthcheck: + <<: *healthcheck + couch32setup: + image: curlimages/curl:8.5.0 + restart: "no" + environment: + <<: *common-env + depends_on: + couch22: + condition: service_healthy + volumes: + - ./script/complete_couch2.sh:/complete_couch2.sh + entrypoint: /complete_couch2.sh + command: http://couch32:5984/ + + couch33: + container_name: couch33 + image: couchdb:3.3.3 + restart: always + environment: + <<: *common-env + ports: + - "6007:5984" + healthcheck: + <<: *healthcheck + couch33setup: + image: curlimages/curl:8.5.0 + restart: "no" + environment: + <<: *common-env + depends_on: + couch22: + condition: service_healthy + volumes: + - ./script/complete_couch2.sh:/complete_couch2.sh + entrypoint: /complete_couch2.sh + command: http://couch33:5984/ diff --git a/script/complete_couch2.sh b/script/complete_couch2.sh index 9ea30ecd0..587ee4de7 100755 --- a/script/complete_couch2.sh +++ b/script/complete_couch2.sh @@ -1,7 +1,8 @@ -#!/bin/bash -e +#!/bin/sh -e for db in _users _replicator _global_changes; do - status=$(curl --silent --write-out %{http_code} -o /dev/null -X PUT ${1}/${db}) +echo ${1}/${db} + status=$(curl --silent --write-out "%{http_code}" -o /dev/null -u ${COUCHDB_USER}:${COUCHDB_PASSWORD} -X PUT "${1}/${db}") case ${status} in 2*) # Success! @@ -15,5 +16,5 @@ for db in _users _replicator _global_changes; do ;; esac done -curl --silent --fail -o /dev/null -X PUT ${1}/_node/nonode@nohost/_config/replicator/interval -d '"1000"' -curl --silent --fail -o /dev/null -X PUT ${1}/_node/nonode@nohost/_config/cluster/n -d '"1"' +curl --silent --fail -o /dev/null -u ${COUCHDB_USER}:${COUCHDB_PASSWORD} -X PUT "${1}/_node/nonode@nohost/_config/replicator/interval" -d '"1000"' +curl --silent --fail -o /dev/null -u ${COUCHDB_USER}:${COUCHDB_PASSWORD} -X PUT "${1}/_node/nonode@nohost/_config/cluster/n" -d '"1"'