-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathdocker-extract-configs.sh
More file actions
executable file
·91 lines (76 loc) · 3.17 KB
/
docker-extract-configs.sh
File metadata and controls
executable file
·91 lines (76 loc) · 3.17 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
#!/bin/bash
# Script to extract default llms.json and providers.json from the Docker container
# Usage: ./docker-extract-configs.sh [output-directory]
set -e
OUTPUT_DIR="${1:-./config}"
IMAGE="${LLMS_DOCKER_IMAGE:-ghcr.io/servicestack/llms:latest}"
echo "Extracting default configuration files from llms-py Docker image"
echo "================================================================"
echo "Image: $IMAGE"
echo "Output directory: $OUTPUT_DIR"
echo ""
# Create output directory
mkdir -p "$OUTPUT_DIR"
# Pull the latest image
echo "Pulling Docker image..."
docker pull "$IMAGE"
echo ""
echo "Extracting configuration files..."
# Create a temporary container and initialize configs
CONTAINER_ID=$(docker create "$IMAGE" llms --init)
# Start the container briefly to initialize configs
docker start "$CONTAINER_ID" || true
sleep 2
docker stop "$CONTAINER_ID" || true
# Copy the config files
echo "Copying llms.json..."
docker cp "$CONTAINER_ID:/home/llms/.llms/llms.json" "$OUTPUT_DIR/llms.json" 2>/dev/null || {
echo "Warning: Could not extract llms.json from container, trying alternative method..."
# Alternative: Run container with init and copy
docker run --rm -v "$(pwd)/$OUTPUT_DIR:/output" "$IMAGE" sh -c "llms --init && cp /home/llms/.llms/llms.json /output/llms.json" || {
echo "Error: Could not extract llms.json"
docker rm -f "$CONTAINER_ID" 2>/dev/null || true
exit 1
}
}
echo "Copying providers.json..."
docker cp "$CONTAINER_ID:/home/llms/.llms/providers.json" "$OUTPUT_DIR/providers.json" 2>/dev/null || {
echo "Warning: Could not extract providers.json from container, trying alternative method..."
docker run --rm -v "$(pwd)/$OUTPUT_DIR:/output" "$IMAGE" sh -c "llms --init && cp /home/llms/.llms/providers.json /output/providers.json" || {
echo "Error: Could not extract providers.json"
docker rm -f "$CONTAINER_ID" 2>/dev/null || true
exit 1
}
}
echo "Copying providers-extra.json..."
docker cp "$CONTAINER_ID:/home/llms/.llms/providers-extra.json" "$OUTPUT_DIR/providers-extra.json" 2>/dev/null || {
echo "Warning: Could not extract providers-extra.json from container, trying alternative method..."
docker run --rm -v "$(pwd)/$OUTPUT_DIR:/output" "$IMAGE" sh -c "llms --init && cp /home/llms/.llms/providers-extra.json /output/providers-extra.json" || {
echo "Error: Could not extract providers-extra.json"
docker rm -f "$CONTAINER_ID" 2>/dev/null || true
exit 1
}
}
# Clean up
docker rm -f "$CONTAINER_ID" 2>/dev/null || true
echo ""
echo "================================================================"
echo "Configuration files extracted successfully!"
echo ""
echo "Files created:"
echo " - $OUTPUT_DIR/llms.json"
echo " - $OUTPUT_DIR/providers.json"
echo " - $OUTPUT_DIR/providers-extra.json"
echo ""
echo "You can now edit these files and mount them in your container:"
echo ""
echo " docker run -p 8000:8000 \\"
echo " -v \$(pwd)/$OUTPUT_DIR:/home/llms/.llms \\"
echo " -e OPENROUTER_API_KEY=\"your-key\" \\"
echo " $IMAGE"
echo ""
echo "Or update your docker-compose.yml volumes section:"
echo ""
echo " volumes:"
echo " - ./$OUTPUT_DIR:/home/llms/.llms"
echo ""