The container was only on the project's default network, so Coolify's Traefik (on the shared coolify network) had no route to it — Traefik matched the router but reported "no available server". Putting couchdb on both networks lets Traefik reach 5984 while leaving the init sidecar talking to it over the default network as before.
67 lines
1.8 KiB
YAML
67 lines
1.8 KiB
YAML
services:
|
|
couchdb:
|
|
image: couchdb:3
|
|
restart: unless-stopped
|
|
environment:
|
|
SERVICE_FQDN_COUCHDB_5984:
|
|
COUCHDB_USER: ${COUCHDB_USER:-admin}
|
|
COUCHDB_PASSWORD: ${COUCHDB_PASSWORD}
|
|
expose:
|
|
- "5984"
|
|
volumes:
|
|
- couchdb_data:/opt/couchdb/data
|
|
networks:
|
|
- default
|
|
- coolify
|
|
|
|
couchdb-init:
|
|
image: curlimages/curl:latest
|
|
restart: "no"
|
|
depends_on:
|
|
- couchdb
|
|
environment:
|
|
COUCHDB_USER: ${COUCHDB_USER:-admin}
|
|
COUCHDB_PASSWORD: ${COUCHDB_PASSWORD}
|
|
entrypoint: ["sh", "-c"]
|
|
command:
|
|
- |
|
|
set -eu
|
|
base="http://$${COUCHDB_USER}:$${COUCHDB_PASSWORD}@couchdb:5984"
|
|
|
|
echo "waiting for couchdb..."
|
|
i=0
|
|
until curl -fsS "http://couchdb:5984/_up" >/dev/null 2>&1; do
|
|
i=$$((i + 1))
|
|
if [ $$i -gt 60 ]; then
|
|
echo "couchdb did not become ready in 120s"; exit 1
|
|
fi
|
|
sleep 2
|
|
done
|
|
echo "couchdb ready"
|
|
|
|
for db in _users _replicator _global_changes; do
|
|
code=$$(curl -s -o /dev/null -w "%{http_code}" -X PUT "$$base/$$db")
|
|
case "$$code" in
|
|
201|202|412) echo "db $$db: ok ($$code)" ;;
|
|
*) echo "db $$db: failed ($$code)"; exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
put_config() {
|
|
curl -fsS -X PUT -H "Content-Type: application/json" \
|
|
"$$base/_node/_local/_config/$$1/$$2" -d "\"$$3\"" >/dev/null
|
|
echo "cfg $$1/$$2 = $$3"
|
|
}
|
|
put_config chttpd enable_cors true
|
|
put_config cors origins '*'
|
|
put_config cors credentials false
|
|
put_config cors methods 'GET, PUT, POST, HEAD, DELETE'
|
|
put_config cors headers 'accept, authorization, content-type, origin, referer, x-csrf-token'
|
|
|
|
networks:
|
|
coolify:
|
|
external: true
|
|
|
|
volumes:
|
|
couchdb_data:
|