Skip to content

Commit

Permalink
Merge pull request #853 from go-kivik/docker-compose
Browse files Browse the repository at this point in the history
Configure docker-compose to start CouchDB for tests
  • Loading branch information
flimzy authored Dec 25, 2023
2 parents 16365e9 + c3ed911 commit 6c7e12e
Show file tree
Hide file tree
Showing 2 changed files with 156 additions and 4 deletions.
151 changes: 151 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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/
9 changes: 5 additions & 4 deletions script/complete_couch2.sh
Original file line number Diff line number Diff line change
@@ -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!
Expand All @@ -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"'

0 comments on commit 6c7e12e

Please sign in to comment.