-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathentrypoint.sh
executable file
·25 lines (20 loc) · 1010 Bytes
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh
echo "Starting Docker..."
sh -c "docker run -d -p 5984:5984 -p 5986:5986 --tmpfs /ram_disk couchdb:$INPUT_COUCHDB_VERSION"
# CouchDB container name
export NAME=`docker ps --format "{{.Names}}" --last 1`
wait_for_couchdb() {
echo "Waiting for CouchDB..."
hostip=$(ip route show | awk '/default/ {print $3}')
while ! curl -f http://$hostip:5984/ &> /dev/null
do
echo "."
sleep 1
done
}
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