Skip to content

Commit 2ecd7a4

Browse files
committed
added missing docker .env/arguments
1 parent 9f1e0a1 commit 2ecd7a4

File tree

3 files changed

+158
-2
lines changed

3 files changed

+158
-2
lines changed

docker/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ RUN apt-get update && apt-get install -y \
4141
unzip \
4242
supervisor \
4343
redis-server \
44+
jq \
4445
&& rm -rf /var/lib/apt/lists/*
4546

4647
WORKDIR /app
@@ -57,6 +58,8 @@ COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
5758
COPY docker/redis.conf /etc/redis/redis.conf
5859
COPY docker/kvrocks.conf /etc/kvrocks/kvrocks.conf
5960
COPY docker/bob.json /app/bob.json
61+
COPY docker/entrypoint.sh /app/entrypoint.sh
62+
RUN chmod +x /app/entrypoint.sh
6063

6164
# Expose ports
6265
# 21842 - bob server port
@@ -66,4 +69,5 @@ EXPOSE 21842 40420
6669
# Data volumes for persistence
6770
VOLUME ["/data/redis", "/data/kvrocks", "/data/bob"]
6871

72+
ENTRYPOINT ["/app/entrypoint.sh"]
6973
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

docker/entrypoint.sh

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/bin/bash
2+
set -e
3+
4+
CONFIG_FILE="/app/bob.json"
5+
6+
# Patch bob.json with environment variables using jq
7+
# Only overrides values when the corresponding env var is set
8+
9+
# --- String parameters ---
10+
if [ -n "$NODE_SEED" ]; then
11+
jq --arg v "$NODE_SEED" '.["node-seed"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
12+
fi
13+
14+
if [ -n "$LOG_LEVEL" ]; then
15+
jq --arg v "$LOG_LEVEL" '.["log-level"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
16+
fi
17+
18+
if [ -n "$ARBITRATOR_IDENTITY" ]; then
19+
jq --arg v "$ARBITRATOR_IDENTITY" '.["arbitrator-identity"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
20+
fi
21+
22+
if [ -n "$NODE_ALIAS" ]; then
23+
jq --arg v "$NODE_ALIAS" '.["node-alias"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
24+
fi
25+
26+
if [ -n "$TICK_STORAGE_MODE" ]; then
27+
jq --arg v "$TICK_STORAGE_MODE" '.["tick-storage-mode"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
28+
fi
29+
30+
if [ -n "$TX_STORAGE_MODE" ]; then
31+
jq --arg v "$TX_STORAGE_MODE" '.["tx-storage-mode"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
32+
fi
33+
34+
if [ -n "$KEYDB_URL" ]; then
35+
jq --arg v "$KEYDB_URL" '.["keydb-url"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
36+
fi
37+
38+
if [ -n "$KVROCKS_URL" ]; then
39+
jq --arg v "$KVROCKS_URL" '.["kvrocks-url"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
40+
fi
41+
42+
# --- Unsigned integer parameters ---
43+
if [ -n "$RPC_PORT" ]; then
44+
jq --argjson v "$RPC_PORT" '.["rpc-port"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
45+
fi
46+
47+
if [ -n "$SERVER_PORT" ]; then
48+
jq --argjson v "$SERVER_PORT" '.["server-port"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
49+
fi
50+
51+
if [ -n "$REQUEST_CYCLE_MS" ]; then
52+
jq --argjson v "$REQUEST_CYCLE_MS" '.["request-cycle-ms"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
53+
fi
54+
55+
if [ -n "$REQUEST_LOGGING_CYCLE_MS" ]; then
56+
jq --argjson v "$REQUEST_LOGGING_CYCLE_MS" '.["request-logging-cycle-ms"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
57+
fi
58+
59+
if [ -n "$FUTURE_OFFSET" ]; then
60+
jq --argjson v "$FUTURE_OFFSET" '.["future-offset"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
61+
fi
62+
63+
if [ -n "$MAX_THREAD" ]; then
64+
jq --argjson v "$MAX_THREAD" '.["max-thread"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
65+
fi
66+
67+
if [ -n "$SPAM_QU_THRESHOLD" ]; then
68+
jq --argjson v "$SPAM_QU_THRESHOLD" '.["spam-qu-threshold"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
69+
fi
70+
71+
if [ -n "$TX_TICK_TO_LIVE" ]; then
72+
jq --argjson v "$TX_TICK_TO_LIVE" '.["tx_tick_to_live"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
73+
fi
74+
75+
if [ -n "$LAST_N_TICK_STORAGE" ]; then
76+
jq --argjson v "$LAST_N_TICK_STORAGE" '.["last_n_tick_storage"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
77+
fi
78+
79+
if [ -n "$KVROCKS_TTL" ]; then
80+
jq --argjson v "$KVROCKS_TTL" '.["kvrocks_ttl"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
81+
fi
82+
83+
# --- Boolean parameters ---
84+
if [ -n "$RUN_SERVER" ]; then
85+
jq --argjson v "$RUN_SERVER" '.["run-server"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
86+
fi
87+
88+
if [ -n "$IS_TESTNET" ]; then
89+
jq --argjson v "$IS_TESTNET" '.["is-testnet"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
90+
fi
91+
92+
if [ -n "$ENABLE_ADMIN_ENDPOINTS" ]; then
93+
jq --argjson v "$ENABLE_ADMIN_ENDPOINTS" '.["enable-admin-endpoints"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
94+
fi
95+
96+
if [ -n "$ALLOW_CHECK_IN_QUBIC_GLOBAL" ]; then
97+
jq --argjson v "$ALLOW_CHECK_IN_QUBIC_GLOBAL" '.["allow-check-in-qubic-global"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
98+
fi
99+
100+
if [ -n "$ALLOW_RECEIVE_LOG_FROM_INCOMING" ]; then
101+
jq --argjson v "$ALLOW_RECEIVE_LOG_FROM_INCOMING" '.["allow-receive-log-from-incoming-connections"] = $v' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
102+
fi
103+
104+
# --- Array parameters ---
105+
# P2P_NODES: comma-separated list, e.g. "1:1.2.3.4:21841,2:5.6.7.8:21841"
106+
if [ -n "$P2P_NODES" ]; then
107+
jq --arg v "$P2P_NODES" '.["p2p-node"] = ($v | split(",") | map(. | ltrimstr(" ") | rtrimstr(" ")))' "$CONFIG_FILE" > "$CONFIG_FILE.tmp" && mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
108+
fi
109+
110+
echo "=== Bob configuration ==="
111+
# Print config but redact the node-seed for security
112+
jq 'if .["node-seed"] then .["node-seed"] = "***REDACTED***" else . end' "$CONFIG_FILE"
113+
echo "========================="
114+
115+
# Execute the original CMD (supervisord)
116+
exec "$@"

docker/examples/docker-compose.yml

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
11
# Docker Compose for Qubic Bob (includes Redis and Kvrocks)
22
# Image: qubiccore/bob:latest
3+
#
4+
# Configuration can be done in two ways:
5+
# 1. Mount a custom bob.json file (see volume mount below)
6+
# 2. Use environment variables (env vars override values in bob.json)
7+
#
8+
# Supported environment variables:
9+
# NODE_SEED - 55-char lowercase seed for node identity (a-z only)
10+
# P2P_NODES - Comma-separated peer list, e.g. "1:1.2.3.4:21841,2:5.6.7.8:21841"
11+
# LOG_LEVEL - debug | info | warn | error
12+
# RPC_PORT - REST API port (default: 40420)
13+
# SERVER_PORT - P2P server port (default: 21842)
14+
# RUN_SERVER - Enable P2P serving: true | false
15+
# IS_TESTNET - Testnet mode: true | false
16+
# ARBITRATOR_IDENTITY - 60-char uppercase arbitrator identity
17+
# NODE_ALIAS - Display name for this node
18+
# TICK_STORAGE_MODE - lastNTick | kvrocks | free
19+
# TX_STORAGE_MODE - lastNTick | kvrocks | free
20+
# MAX_THREAD - Max worker threads (0 = auto)
21+
# SPAM_QU_THRESHOLD - Min QU amount to index transfers
22+
# TX_TICK_TO_LIVE - Ticks to keep tx data in RAM
23+
# LAST_N_TICK_STORAGE - Number of ticks to keep (lastNTick mode)
24+
# KVROCKS_TTL - Data expiration in seconds (0 = no expiration)
25+
# REQUEST_CYCLE_MS - Tick data request interval in ms
26+
# REQUEST_LOGGING_CYCLE_MS - Logging event request interval in ms
27+
# FUTURE_OFFSET - How many ticks ahead to request
28+
# KEYDB_URL - Redis/KeyDB connection URL
29+
# KVROCKS_URL - KVRocks connection URL
30+
# ENABLE_ADMIN_ENDPOINTS - Enable admin RPC methods: true | false
31+
# ALLOW_CHECK_IN_QUBIC_GLOBAL - Allow check-in with qubic.global: true | false
32+
# ALLOW_RECEIVE_LOG_FROM_INCOMING - Accept logging from incoming connections: true | false
333

434
services:
535
qubic-bob:
@@ -9,9 +39,15 @@ services:
939
ports:
1040
- "21842:21842"
1141
- "40420:40420"
42+
environment:
43+
- NODE_SEED=your_55_character_lowercase_seed_here_aaaaaaaaaaaa
44+
# - LOG_LEVEL=info
45+
# - P2P_NODES=1:1.2.3.4:21841,2:5.6.7.8:21841
46+
# - RUN_SERVER=true
47+
# - IS_TESTNET=false
1248
volumes:
13-
# - ./bob.json:/app/bob.json:ro # if needed you can use a custom configuration
14-
# - ./redis.conf:/etc/redis/redis.conf:ro # custom Redis config (e.g., to increase maxmemory beyond default 4GB)
49+
# - ./bob.json:/app/bob.json:ro # custom config file (env vars still override it)
50+
# - ./redis.conf:/etc/redis/redis.conf:ro # custom Redis config
1551
- qubic-bob-redis:/data/redis
1652
- qubic-bob-kvrocks:/data/kvrocks
1753
- qubic-bob-data:/data/bob

0 commit comments

Comments
 (0)