-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
85 lines (79 loc) · 2.36 KB
/
docker-entrypoint.sh
File metadata and controls
85 lines (79 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/sh
set -e
# SIDEMANTIC_MODE: "serve" (default), "mcp", "api", or "both"
MODE="${SIDEMANTIC_MODE:-serve}"
DEMO_ARGS=""
if [ -n "$SIDEMANTIC_DEMO" ]; then
DEMO_ARGS="--demo"
fi
# Build arg arrays for each command.
# serve accepts: --connection, --db, --host, --port, --username, --password
# mcp-serve accepts: --db only
# Serve args
SERVE_ARGS="--host 0.0.0.0"
if [ -n "$SIDEMANTIC_CONNECTION" ]; then
SERVE_ARGS="$SERVE_ARGS --connection \"$SIDEMANTIC_CONNECTION\""
fi
if [ -n "$SIDEMANTIC_DB" ]; then
SERVE_ARGS="$SERVE_ARGS --db \"$SIDEMANTIC_DB\""
fi
if [ -n "$SIDEMANTIC_USERNAME" ]; then
SERVE_ARGS="$SERVE_ARGS --username \"$SIDEMANTIC_USERNAME\""
fi
if [ -n "$SIDEMANTIC_PASSWORD" ]; then
SERVE_ARGS="$SERVE_ARGS --password \"$SIDEMANTIC_PASSWORD\""
fi
if [ -n "$SIDEMANTIC_PORT" ]; then
SERVE_ARGS="$SERVE_ARGS --port \"$SIDEMANTIC_PORT\""
fi
# MCP args (only --db is supported)
MCP_ARGS=""
if [ -n "$SIDEMANTIC_DB" ]; then
MCP_ARGS="$MCP_ARGS --db \"$SIDEMANTIC_DB\""
fi
# HTTP API args
API_ARGS="--host 0.0.0.0"
if [ -n "$SIDEMANTIC_CONNECTION" ]; then
API_ARGS="$API_ARGS --connection \"$SIDEMANTIC_CONNECTION\""
fi
if [ -n "$SIDEMANTIC_DB" ]; then
API_ARGS="$API_ARGS --db \"$SIDEMANTIC_DB\""
fi
if [ -n "$SIDEMANTIC_API_TOKEN" ]; then
API_ARGS="$API_ARGS --auth-token \"$SIDEMANTIC_API_TOKEN\""
fi
if [ -n "$SIDEMANTIC_API_PORT" ]; then
API_ARGS="$API_ARGS --port \"$SIDEMANTIC_API_PORT\""
fi
if [ -n "$SIDEMANTIC_MAX_REQUEST_BODY_BYTES" ]; then
API_ARGS="$API_ARGS --max-request-body-bytes \"$SIDEMANTIC_MAX_REQUEST_BODY_BYTES\""
fi
if [ -n "$SIDEMANTIC_CORS_ORIGINS" ]; then
OLD_IFS="$IFS"
IFS=','
for ORIGIN in $SIDEMANTIC_CORS_ORIGINS; do
API_ARGS="$API_ARGS --cors-origin \"$ORIGIN\""
done
IFS="$OLD_IFS"
fi
case "$MODE" in
serve)
eval exec sidemantic serve $SERVE_ARGS $DEMO_ARGS "$@"
;;
mcp)
eval exec sidemantic mcp-serve $MCP_ARGS $DEMO_ARGS "$@"
;;
api)
eval exec sidemantic api-serve $API_ARGS $DEMO_ARGS "$@"
;;
both)
eval sidemantic serve $SERVE_ARGS $DEMO_ARGS &
SERVE_PID=$!
trap "kill $SERVE_PID 2>/dev/null" EXIT
eval exec sidemantic mcp-serve $MCP_ARGS $DEMO_ARGS "$@"
;;
*)
echo "Unknown SIDEMANTIC_MODE: $MODE (use serve, mcp, api, or both)" >&2
exit 1
;;
esac