-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathdocker.sh
More file actions
executable file
·90 lines (70 loc) · 2.29 KB
/
Copy pathdocker.sh
File metadata and controls
executable file
·90 lines (70 loc) · 2.29 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
#!/usr/bin/env bash
# Smoke coddy serve inside docker compose (see repo docker-compose.dev.yml). Needs docker and docker compose.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
cd "$ROOT"
HTTP_DIR="$ROOT/examples/httpserver"
if ! command -v docker >/dev/null 2>&1; then
echo "docker not found" >&2
exit 1
fi
if ! docker compose version >/dev/null 2>&1; then
echo "docker compose not found" >&2
exit 1
fi
PORT="${PORT:-12345}"
export PORT
TMP_DIR="$(mktemp -d -t coddy-docker-http-XXXXXX)"
cleanup() {
docker compose -f docker-compose.dev.yml down -v --remove-orphans >/dev/null 2>&1 || true
if [[ "${KEEP_TMP:-0}" != "1" ]]; then
rm -rf "$TMP_DIR" >/dev/null 2>&1 || true
fi
}
trap cleanup EXIT
CODDY_CWD="${CODDY_CWD:-$TMP_DIR/workspace}"
CODDY_HOME="${CODDY_HOME:-$TMP_DIR/coddy_home}"
CODDY_CONFIG="${CODDY_CONFIG:-$TMP_DIR/config.yaml}"
mkdir -p "$CODDY_CWD" "$CODDY_HOME"
python3 - "$ROOT/examples/config.demo.yaml" "$CODDY_CONFIG" "$PORT" <<'PY'
from __future__ import annotations
import sys
src_path = sys.argv[1]
dst_path = sys.argv[2]
port = sys.argv[3]
raw = open(src_path, "r", encoding="utf-8").read()
raw = raw.replace('host: "127.0.0.1"', 'host: "0.0.0.0"')
raw = raw.replace("port: 19876", f"port: {port}", 1)
# Make container logs visible in `docker compose logs`.
raw = raw.replace('outputs: ["file"]', 'outputs: ["stderr"]')
raw = raw.replace('file: "__E2E_LOG_PATH__"', 'file: ""')
open(dst_path, "w", encoding="utf-8").write(raw)
PY
if [[ ! -f "$CODDY_CONFIG" ]]; then
echo "config path is not a file: $CODDY_CONFIG" >&2
ls -la "$(dirname "$CODDY_CONFIG")" >&2 || true
exit 1
fi
if [[ ! -s "$CODDY_CONFIG" ]]; then
echo "config file is empty: $CODDY_CONFIG" >&2
exit 1
fi
export CODDY_CWD CODDY_HOME CODDY_CONFIG
docker compose -f docker-compose.dev.yml up -d --build coddy
ready=0
for _ in $(seq 1 120); do
if curl -sf -o /dev/null "http://127.0.0.1:${PORT}/v1/models"; then
ready=1
break
fi
sleep 0.25
done
if [[ "$ready" != 1 ]]; then
echo "http server did not become ready on port ${PORT}" >&2
docker compose -f docker-compose.dev.yml ps -a || true
docker compose -f docker-compose.dev.yml logs coddy || true
exit 1
fi
export BASE_URL="http://127.0.0.1:${PORT}/v1"
python3 "$HTTP_DIR/http_smoke_gateway.py"
echo "ok docker httpserver tests"