Skip to content

Commit

Permalink
Parameterize DB name and upgrade couchdb
Browse files Browse the repository at this point in the history
  • Loading branch information
Mona Gogia committed Jun 21, 2024
1 parent b153eb5 commit 6360bc4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
11 changes: 7 additions & 4 deletions couchdb-startup.env
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
COUCHDB_USER=<COUCHDB_USERNAME>
COUCHDB_PASSWORD=<COUCHDB_PASSWORD>
COUCHDB_SERVER_IP_ADDR=<COUCHDB_IP>
COUCHDB_USER=Multimodal
COUCHDB_PASSWORD=iqtpass1
COUCHDB_SERVER_IP_ADDR=10.204.183.37
DB_NAME=Multimodal

# Set this value when running it for CouchDB sync server on a peripheral
DEVICE_IP=<DEVICE_IP>

# Set this value to true if running the docker install for a mobile device.
# Set it to false when running it for a CouchDB sync server

PERIPHERAL=true
PERIPHERAL=false
2 changes: 1 addition & 1 deletion couchdb-startup/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM couchdb:3.1.1
FROM couchdb:3.3.3
ADD couchdbinit.sh .
CMD ["chmod", "+x", "/couchdbinit.sh"]
ENTRYPOINT ["sh", "-c", "/couchdbinit.sh"]
6 changes: 3 additions & 3 deletions couchdb-startup/couchdbinit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
# Wait for the CouchDB instance container to be ready before executing setup commands
while [ "$(curl -s -o /dev/null -w ''%{http_code}'' couchdb-server:5984)" != "200" ]; do sleep 5; done

# Create system tables and table "aisonobuoy" which is used for synching all data from devices
# Create system tables and table "multimodal" which is used for synching all data from devices
# TODO: Do not hardcode CouchDB server IP?
curl -X PUT http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@couchdb-server:5984/_users
curl -X PUT http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@couchdb-server:5984/_replicator
curl -X PUT http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@couchdb-server:5984/_global_changes
curl -X PUT http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@couchdb-server:5984/aisonobuoy
curl -X PUT http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@couchdb-server:5984/${DB_NAME}
curl -X GET http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@couchdb-server:5984/_all_dbs

# In case the container is being on a mobile device,
# create a replication task directed to the CouchDB sync server.

if ${PERIPHERAL}; then

curl -X POST http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@couchdb-server:5984/_replicator -d '{"source":"http://'${COUCHDB_USER}':'${COUCHDB_PASSWORD}'@couchdb-server:5984/aisonobuoy", "target":"http://'${COUCHDB_USER}':'${COUCHDB_PASSWORD}'@'${COUCHDB_SERVER_IP_ADDR}':5984/aisonobuoy", "continuous":true}' -H "Content-Type: application/json"
curl -X POST http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@couchdb-server:5984/_replicator -d '{"source":"http://'${COUCHDB_USER}':'${COUCHDB_PASSWORD}'@couchdb-server:5984/multimodal", "target":"http://'${COUCHDB_USER}':'${COUCHDB_PASSWORD}'@'${COUCHDB_SERVER_IP_ADDR}':5984/multimodal", "continuous":true}' -H "Content-Type: application/json"

fi
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
version: '3'
services:
couchdb-server:
image: couchdb:3.1.1
image: couchdb:3.3.3
restart: unless-stopped
ports:
- "5984:5984"
volumes:
- /home/mobian/couchdb-data:/opt/couchdb/data
- /home/ubuntu/couchdb-data:/opt/couchdb/data
env_file:
- .env
- couchdb-startup.env
logging:
driver: "json-file"
options:
Expand Down

0 comments on commit 6360bc4

Please sign in to comment.