docker-compose.yml 3.92 KB
Newer Older
1
2
3
version: '2'
services:
    couchbase-couchbase:
Jeremie TISSERAND's avatar
Jeremie TISSERAND committed
4
        image: couchbase/server:community-5.0.1
5
6
7
8
9
10
11
12
13
14
        ports:
            - 8091:8091
            - 8092:8092
            - 8093:8093
            - 11210:11210
        entrypoint:
            - /bin/bash
            - -c
            - "echo 'Launching couchbase' &&
              /usr/sbin/runsvdir-start &
15

16
17
18
19
20
21
22
23
24
              (
                  ok=1; \
                  while [ $$ok != 0 ]; do \
                      sleep 5; \
                      echo 'Couchbase is starting (rest api not available)'; \
                      curl --connect-timeout 1 -s  http://127.0.0.1:8091 > /dev/null; \
                      ok=$$?; \
                  done
              ) &&
25

26
27
28
29
30
31
32
33
34
              (
                  echo 'Configuring Couchbase' &&
                  echo 'Creating cluster' &&
                  couchbase-cli cluster-init -c 127.0.0.1:8091 --cluster-username=${COUCHBASE_ADMIN_USER} --cluster-password=${COUCHBASE_ADMIN_PWD} --cluster-ramsize=512 --cluster-index-ramsize=512 --cluster-fts-ramsize=256 --services=data,index,query,fts &&
                  echo 'Creating '${BUCKET_NAME}' bucket' &&
                  couchbase-cli bucket-create -c 127.0.0.1:8091 -u ${COUCHBASE_ADMIN_USER} -p ${COUCHBASE_ADMIN_PWD} --bucket=${BUCKET_NAME} --bucket-type=couchbase --bucket-ramsize=300 &&
                  echo 'Creating a user to give the gateway an access to the bucket' &&
                  couchbase-cli user-manage -c 127.0.0.1 -u ${COUCHBASE_ADMIN_USER} -p ${COUCHBASE_ADMIN_PWD} --set --rbac-username ${SECURITY_USER} --rbac-password ${SECURITY_PWD} --roles admin --auth-domain local
              ) &&
35

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
              echo 'Initialization done' &&
              tail -f /opt/couchbase/var/lib/couchbase/logs/error.log"
    couchbase-gateway:
        image: couchbase/sync-gateway:2.0.0-community
        ports:
            - 4984:4984
            - 4985:4985
        entrypoint:
            - /bin/bash
            - -c
            - "
                echo 'Sleep 5s at launch time' &&
                sleep 5 &&
                echo 'Creating configuration file' &&
                COUCHBASE=$$(ping couchbase-couchbase -c 1 | grep -m 1 -E -o '[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+') &&
51

52
53
54
55
56
57
58
59
60
61
62
63
64
                echo '
                {
                    \"adminInterface\": \"0.0.0.0:4985\",
                    \"log\": [
                        \"[*]\"
                    ],
                    \"verbose\": true,
                    \"databases\": {
                        \"app\": {
                            \"server\": \"http://'$$COUCHBASE':8091\",
                            \"bucket\": \"${BUCKET_NAME}\",
                            \"username\": \"${SECURITY_USER}\",
                            \"password\": \"${SECURITY_PWD}\",
Jeremie TISSERAND's avatar
Jeremie TISSERAND committed
65
66
                            \"enable_shared_bucket_access\": true,
                            \"import_docs\": \"continuous\",
67
                            \"users\": {
68
69
                                \"admin\": {\"password\": \"adminadmin\", \"admin_channels\": [\"*\"]},
                                \"test\": {\"password\": \"test\", \"admin_channels\": [\"CHANNEL_test\"]}
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
                            },
                            \"sync\": `
                                function(doc, oldDoc) {
                                    if (doc.tag !== undefined) {
                                        channel(\"CHANNEL_\" + doc.tag);
                                    }
                                }
                            `
                        }
                    }
                }
                ' > /home/sync_gateway/sync_gateway.json &&

                echo 'Sleep 20s before starting Sync Gateway' &&
                sleep 20 &&
                echo 'Starting Sync Gateway' &&
                /opt/couchbase-sync-gateway/bin/sync_gateway /home/sync_gateway/sync_gateway.json &
                tail -f /dev/null"
        links:
          - couchbase-couchbase