Skip to content

Commit be2281d

Browse files
committed
fix: add start.sh with auto port fallback, revert docker-compose to 0.0.0.0
1 parent 48b07b5 commit be2281d

2 files changed

Lines changed: 47 additions & 2 deletions

File tree

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ services:
33
image: qdrant/qdrant:v1.13.2
44
restart: unless-stopped
55
ports:
6-
- "127.0.0.1:${QDRANT_HTTP_PORT:-6343}:6333"
6+
- "${QDRANT_HTTP_PORT:-6343}:6333"
77
volumes:
88
- ./data/qdrant:/qdrant/storage
99
entrypoint: ["/bin/sh", "-c", "find /qdrant/storage -name .DS_Store -delete 2>/dev/null; exec ./entrypoint.sh"]
@@ -14,7 +14,7 @@ services:
1414
app:
1515
build: .
1616
ports:
17-
- "127.0.0.1:${API_PORT:-18900}:18900"
17+
- "${API_PORT:-18900}:18900"
1818
volumes:
1919
- ./data:/app/data
2020
environment:

start.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# ── Default ports ──
5+
API_PORT="${API_PORT:-18900}"
6+
QDRANT_HTTP_PORT="${QDRANT_HTTP_PORT:-6343}"
7+
QDRANT_GRPC_PORT="${QDRANT_GRPC_PORT:-6334}"
8+
9+
# ── Check if a port is available ──
10+
port_free() {
11+
! lsof -i ":$1" -sTCP:LISTEN >/dev/null 2>&1
12+
}
13+
14+
# ── Find next free port starting from $1 ──
15+
find_free_port() {
16+
local port="$1"
17+
local max=$((port + 100))
18+
while ! port_free "$port"; do
19+
if [ "$port" -ge "$max" ]; then
20+
echo "ERROR: No free port found in range $1-$max" >&2
21+
exit 1
22+
fi
23+
port=$((port + 1))
24+
done
25+
echo "$port"
26+
}
27+
28+
# ── Resolve ports ──
29+
API_PORT=$(find_free_port "$API_PORT")
30+
QDRANT_HTTP_PORT=$(find_free_port "$QDRANT_HTTP_PORT")
31+
QDRANT_GRPC_PORT=$(find_free_port "$QDRANT_GRPC_PORT")
32+
33+
# ── Write .env for docker compose ──
34+
cat > .env <<EOF
35+
API_PORT=$API_PORT
36+
QDRANT_HTTP_PORT=$QDRANT_HTTP_PORT
37+
QDRANT_GRPC_PORT=$QDRANT_GRPC_PORT
38+
EOF
39+
40+
echo "Starting SinkDuce..."
41+
echo " API: http://localhost:$API_PORT"
42+
echo " Qdrant: http://localhost:$QDRANT_HTTP_PORT (gRPC: $QDRANT_GRPC_PORT)"
43+
echo ""
44+
45+
exec docker compose up -d "$@"

0 commit comments

Comments
 (0)