|
| 1 | +# Author: Nuno Aguiar |
| 2 | +help: |
| 3 | + text : Generates a docker-compose for FalkorDB |
| 4 | + expects: |
| 5 | + - name : serverOnly |
| 6 | + desc : "If serverOnly=true use the falkordb/falkordb-server image instead of the image with the browser." |
| 7 | + mandatory: false |
| 8 | + example : "true" |
| 9 | + - name : tag |
| 10 | + desc : Docker image tag to use |
| 11 | + mandatory: false |
| 12 | + example : latest |
| 13 | + - name : port |
| 14 | + desc : Host port to expose FalkorDB |
| 15 | + mandatory: false |
| 16 | + example : 6379 |
| 17 | + - name : browserPort |
| 18 | + desc : Host port to expose FalkorDB Browser when serverOnly=false |
| 19 | + mandatory: false |
| 20 | + example : 3000 |
| 21 | + - name : volume |
| 22 | + desc : Named volume to persist data to /data |
| 23 | + mandatory: false |
| 24 | + example : falkordb_data |
| 25 | + - name : bind |
| 26 | + desc : Host path to bind mount to /data |
| 27 | + mandatory: false |
| 28 | + example : ./falkordb-data |
| 29 | + - name : password |
| 30 | + desc : If defined will add Redis authentication with --requirepass |
| 31 | + mandatory: false |
| 32 | + example : secret123 |
| 33 | + - name : appendonly |
| 34 | + desc : "If appendonly=true will add --appendonly yes to REDIS_ARGS." |
| 35 | + mandatory: false |
| 36 | + example : "true" |
| 37 | + - name : appendfsync |
| 38 | + desc : Redis appendfsync policy |
| 39 | + mandatory: false |
| 40 | + example : everysec |
| 41 | + - name : maxmemory |
| 42 | + desc : Redis maxmemory value |
| 43 | + mandatory: false |
| 44 | + example : 2gb |
| 45 | + - name : maxmemoryPolicy |
| 46 | + desc : Redis maxmemory-policy value |
| 47 | + mandatory: false |
| 48 | + example : allkeys-lru |
| 49 | + - name : redisArgs |
| 50 | + desc : Additional raw Redis arguments appended to REDIS_ARGS |
| 51 | + mandatory: false |
| 52 | + example : --save 60 1 --dir /data |
| 53 | + - name : threadCount |
| 54 | + desc : FalkorDB THREAD_COUNT |
| 55 | + mandatory: false |
| 56 | + example : 4 |
| 57 | + - name : cacheSize |
| 58 | + desc : FalkorDB CACHE_SIZE |
| 59 | + mandatory: false |
| 60 | + example : 25 |
| 61 | + - name : ompThreadCount |
| 62 | + desc : FalkorDB OMP_THREAD_COUNT |
| 63 | + mandatory: false |
| 64 | + example : 2 |
| 65 | + - name : nodeCreationBuffer |
| 66 | + desc : FalkorDB NODE_CREATION_BUFFER |
| 67 | + mandatory: false |
| 68 | + example : 16384 |
| 69 | + - name : boltPort |
| 70 | + desc : FalkorDB BOLT_PORT and exposed bolt port |
| 71 | + mandatory: false |
| 72 | + example : 7687 |
| 73 | + - name : maxQueuedQueries |
| 74 | + desc : FalkorDB MAX_QUEUED_QUERIES |
| 75 | + mandatory: false |
| 76 | + example : 500 |
| 77 | + - name : timeout |
| 78 | + desc : FalkorDB TIMEOUT (deprecated upstream in favor of timeoutMax and timeoutDefault) |
| 79 | + mandatory: false |
| 80 | + example : 1000 |
| 81 | + - name : timeoutMax |
| 82 | + desc : FalkorDB TIMEOUT_MAX |
| 83 | + mandatory: false |
| 84 | + example : 30000 |
| 85 | + - name : timeoutDefault |
| 86 | + desc : FalkorDB TIMEOUT_DEFAULT |
| 87 | + mandatory: false |
| 88 | + example : 5000 |
| 89 | + - name : resultsetSize |
| 90 | + desc : FalkorDB RESULTSET_SIZE |
| 91 | + mandatory: false |
| 92 | + example : 1000 |
| 93 | + - name : queryMemCapacity |
| 94 | + desc : FalkorDB QUERY_MEM_CAPACITY in bytes |
| 95 | + mandatory: false |
| 96 | + example : 104857600 |
| 97 | + - name : vkeyMaxEntityCount |
| 98 | + desc : FalkorDB VKEY_MAX_ENTITY_COUNT |
| 99 | + mandatory: false |
| 100 | + example : 100000 |
| 101 | + - name : effectsThreshold |
| 102 | + desc : FalkorDB EFFECTS_THRESHOLD |
| 103 | + mandatory: false |
| 104 | + example : 300 |
| 105 | + - name : cmdInfo |
| 106 | + desc : FalkorDB CMD_INFO (yes or no) |
| 107 | + mandatory: false |
| 108 | + example : "yes" |
| 109 | + - name : maxInfoQueries |
| 110 | + desc : FalkorDB MAX_INFO_QUERIES |
| 111 | + mandatory: false |
| 112 | + example : 1000 |
| 113 | + - name : deltaMaxPendingChanges |
| 114 | + desc : FalkorDB DELTA_MAX_PENDING_CHANGES |
| 115 | + mandatory: false |
| 116 | + example : 10000 |
| 117 | + - name : importFolder |
| 118 | + desc : FalkorDB IMPORT_FOLDER absolute path |
| 119 | + mandatory: false |
| 120 | + example : /var/lib/FalkorDB/import/ |
| 121 | + - name : falkordbArgs |
| 122 | + desc : Additional raw FalkorDB module arguments appended to FALKORDB_ARGS |
| 123 | + mandatory: false |
| 124 | + example : SOME_OPTION 1 |
| 125 | + |
| 126 | +todo: |
| 127 | +- Check for docker |
| 128 | +- Generate docker-compose |
| 129 | + |
| 130 | +include: |
| 131 | +- ojob.io/docker/_common |
| 132 | + |
| 133 | +init: |
| 134 | + dc : &DC | |
| 135 | + version: '3.8' |
| 136 | + |
| 137 | + networks: |
| 138 | + falkordb: |
| 139 | + driver: bridge |
| 140 | + |
| 141 | + services: |
| 142 | + falkordb: |
| 143 | + image : {{image}}:{{tag}} |
| 144 | + restart : unless-stopped |
| 145 | + container_name: falkordb |
| 146 | + ports : |
| 147 | + - "{{port}}:6379"{{#if browser}} |
| 148 | + - "{{browserPort}}:3000"{{/if}}{{#if boltPort}} |
| 149 | + - "{{boltPort}}:{{boltPort}}"{{/if}} |
| 150 | + {{#if env}}environment :{{#if redisArgs}} |
| 151 | + - REDIS_ARGS={{redisArgs}}{{/if}}{{#if falkordbArgs}} |
| 152 | + - FALKORDB_ARGS={{falkordbArgs}}{{/if}}{{/if}} |
| 153 | + healthcheck : |
| 154 | + test : [ "CMD-SHELL", "redis-cli{{#if password}} -a '{{password}}'{{/if}} ping | grep PONG || exit 1" ] |
| 155 | + interval : 30s |
| 156 | + timeout : 10s |
| 157 | + retries : 3 |
| 158 | + start_period: 30s{{#if dataMount}} |
| 159 | + volumes : |
| 160 | + - {{dataMount}}:{{dataPath}}{{/if}} |
| 161 | + networks : |
| 162 | + - falkordb |
| 163 | + {{#if volume}} |
| 164 | + |
| 165 | + volumes: |
| 166 | + {{volume}}: |
| 167 | + driver: local |
| 168 | + {{/if}} |
| 169 | + |
| 170 | +ojob: |
| 171 | + opacks : |
| 172 | + - openaf: 20250725 |
| 173 | + catch : printErrnl("[" + job.name + "] "); if (isDef(exception.javaException)) exception.javaException.printStackTrace(); else printErr(exception) |
| 174 | + logToConsole: false |
| 175 | + |
| 176 | +jobs: |
| 177 | +# ------------------------------ |
| 178 | +- name : Generate docker-compose |
| 179 | + exec : | |
| 180 | + var data = { |
| 181 | + browser : !toBoolean(_$(args.serverOnly, "serverOnly").default("false")), |
| 182 | + image : toBoolean(_$(args.serverOnly, "serverOnly").default("false")) ? "falkordb/falkordb-server" : "falkordb/falkordb", |
| 183 | + tag : _$(args.tag, "tag").default("latest"), |
| 184 | + port : _$(args.port, "port").default("6379"), |
| 185 | + browserPort: _$(args.browserPort, "browserPort").default("3000"), |
| 186 | + password : _$(args.password, "password").default(__), |
| 187 | + volume : _$(args.volume, "volume").default(__) |
| 188 | + } |
| 189 | +
|
| 190 | + if (isDef(args.bind) && isDef(args.volume)) throw "Please use either 'bind' or 'volume', not both." |
| 191 | +
|
| 192 | + data.dataPath = "/data" |
| 193 | + if (isDef(args.bind)) data.dataMount = args.bind |
| 194 | + if (isDef(args.volume)) data.dataMount = args.volume |
| 195 | +
|
| 196 | + var redisArgs = [] |
| 197 | + var falkordbArgs = [] |
| 198 | +
|
| 199 | + if (isDef(args.password)) redisArgs.push("--requirepass " + args.password) |
| 200 | + if (toBoolean(_$(args.appendonly, "appendonly").default("false"))) redisArgs.push("--appendonly yes") |
| 201 | + if (isDef(args.appendfsync)) redisArgs.push("--appendfsync " + args.appendfsync) |
| 202 | + if (isDef(args.maxmemory)) redisArgs.push("--maxmemory " + args.maxmemory) |
| 203 | + if (isDef(args.maxmemoryPolicy)) redisArgs.push("--maxmemory-policy " + args.maxmemoryPolicy) |
| 204 | + if (isDef(args.redisArgs)) redisArgs.push(args.redisArgs) |
| 205 | +
|
| 206 | + ;[ |
| 207 | + [ "THREAD_COUNT" , "threadCount" ], |
| 208 | + [ "CACHE_SIZE" , "cacheSize" ], |
| 209 | + [ "OMP_THREAD_COUNT" , "ompThreadCount" ], |
| 210 | + [ "NODE_CREATION_BUFFER" , "nodeCreationBuffer" ], |
| 211 | + [ "BOLT_PORT" , "boltPort" ], |
| 212 | + [ "MAX_QUEUED_QUERIES" , "maxQueuedQueries" ], |
| 213 | + [ "TIMEOUT" , "timeout" ], |
| 214 | + [ "TIMEOUT_MAX" , "timeoutMax" ], |
| 215 | + [ "TIMEOUT_DEFAULT" , "timeoutDefault" ], |
| 216 | + [ "RESULTSET_SIZE" , "resultsetSize" ], |
| 217 | + [ "QUERY_MEM_CAPACITY" , "queryMemCapacity" ], |
| 218 | + [ "VKEY_MAX_ENTITY_COUNT" , "vkeyMaxEntityCount" ], |
| 219 | + [ "EFFECTS_THRESHOLD" , "effectsThreshold" ], |
| 220 | + [ "CMD_INFO" , "cmdInfo" ], |
| 221 | + [ "MAX_INFO_QUERIES" , "maxInfoQueries" ], |
| 222 | + [ "DELTA_MAX_PENDING_CHANGES", "deltaMaxPendingChanges" ], |
| 223 | + [ "IMPORT_FOLDER" , "importFolder" ] |
| 224 | + ].forEach(r => { |
| 225 | + if (isDef(args[r[1]])) falkordbArgs.push(r[0] + " " + args[r[1]]) |
| 226 | + }) |
| 227 | +
|
| 228 | + if (isDef(args.falkordbArgs)) falkordbArgs.push(args.falkordbArgs) |
| 229 | +
|
| 230 | + if (falkordbArgs.length > 0) data.falkordbArgs = falkordbArgs.join(" ") |
| 231 | + if (redisArgs.length > 0) data.redisArgs = redisArgs.join(" ") |
| 232 | + data.env = (falkordbArgs.length > 0 || redisArgs.length > 0) |
| 233 | + if (isDef(args.boltPort)) data.boltPort = args.boltPort |
| 234 | +
|
| 235 | + tprint(args.init.dc, data) |
0 commit comments