-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
executable file
·117 lines (92 loc) · 2.31 KB
/
docker-entrypoint.sh
File metadata and controls
executable file
·117 lines (92 loc) · 2.31 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
set -e
# Translate environment variables to imp-server CLI flags.
# Usage: docker run ... -e IMP_MODEL=/models/model.gguf imp:latest
CMD="$1"
shift 2>/dev/null || true
# Default to imp-server if no command given
if [ -z "$CMD" ]; then
CMD="imp-server"
fi
# If the command is not imp-server or imp-cli, exec directly (e.g. bash, sh)
case "$CMD" in
imp-server|imp-cli) ;;
*) exec "$CMD" "$@" ;;
esac
args=()
# Model path
if [ -n "$IMP_MODEL" ]; then
args+=(--model "$IMP_MODEL")
fi
# Host — default 0.0.0.0 inside container
if [ -n "$IMP_HOST" ]; then
args+=(--host "$IMP_HOST")
elif [ "$CMD" = "imp-server" ]; then
args+=(--host "0.0.0.0")
fi
# Port
if [ -n "$IMP_PORT" ]; then
args+=(--port "$IMP_PORT")
fi
# Max tokens
if [ -n "$IMP_MAX_TOKENS" ]; then
args+=(--max-tokens "$IMP_MAX_TOKENS")
fi
# GPU layers
if [ -n "$IMP_GPU_LAYERS" ]; then
args+=(--gpu-layers "$IMP_GPU_LAYERS")
fi
# Device ID
if [ -n "$IMP_DEVICE" ]; then
args+=(--device "$IMP_DEVICE")
fi
# Chat template
if [ -n "$IMP_CHAT_TEMPLATE" ]; then
args+=(--chat-template "$IMP_CHAT_TEMPLATE")
fi
# Boolean flags — accept 1 or true
is_true() { [ "$1" = "1" ] || [ "$1" = "true" ] || [ "$1" = "TRUE" ]; }
if is_true "$IMP_KV_FP8"; then
args+=(--kv-fp8)
fi
if is_true "$IMP_KV_INT8"; then
args+=(--kv-int8)
fi
if [ "$IMP_DECODE_NVFP4" = "1" ]; then
args+=(--decode-nvfp4)
elif [ "$IMP_DECODE_NVFP4" = "2" ]; then
args+=(--decode-nvfp4-only)
elif [ "$IMP_DECODE_NVFP4" = "0" ]; then
args+=(--no-nvfp4)
fi
if is_true "$IMP_DECODE_NVFP4_ONLY"; then
args+=(--decode-nvfp4-only)
fi
if is_true "$IMP_NO_NVFP4"; then
args+=(--no-nvfp4)
fi
if is_true "$IMP_NO_CUDA_GRAPHS"; then
args+=(--no-cuda-graphs)
fi
if is_true "$IMP_SSM_FP16"; then
args+=(--ssm-fp16)
fi
# Vision encoder
if [ -n "$IMP_MMPROJ" ]; then
args+=(--mmproj "$IMP_MMPROJ")
fi
# Prefill chunk size
if [ -n "$IMP_PREFILL_CHUNK_SIZE" ]; then
args+=(--prefill-chunk-size "$IMP_PREFILL_CHUNK_SIZE")
fi
# Think budget
if [ -n "$IMP_THINK_BUDGET" ]; then
args+=(--think-budget "$IMP_THINK_BUDGET")
fi
# Models directory
if [ -n "$IMP_MODELS_DIR" ]; then
args+=(--models-dir "$IMP_MODELS_DIR")
elif [ "$CMD" = "imp-server" ] && [ -d "/models" ]; then
args+=(--models-dir "/models")
fi
exec "$CMD" "${args[@]}" "$@"