-
Notifications
You must be signed in to change notification settings - Fork 3.3k
/
Copy pathdocker.sh
executable file
·91 lines (81 loc) · 2.43 KB
/
docker.sh
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
#!/bin/bash
# Check if an argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 {build|run|start|bash}"
exit 1
fi
# Execute the corresponding command based on the argument
case "$1" in
build)
docker build --platform linux/amd64 -t eliza .
;;
run)
# Ensure the container is not already running
if [ "$(docker ps -q -f name=eliza)" ]; then
echo "Container 'eliza' is already running. Stopping it first."
docker stop eliza
docker rm eliza
fi
# Define base directories to mount
BASE_MOUNTS=(
"characters:/app/characters"
".env:/app/.env"
"agent:/app/agent"
"docs:/app/docs"
"scripts:/app/scripts"
)
# Define package directories to mount
PACKAGES=(
"adapter-postgres"
"adapter-sqlite"
"adapter-sqljs"
"adapter-supabase"
"client-auto"
"client-direct"
"client-discord"
"client-farcaster"
"client-telegram"
"client-twitter"
"core"
"plugin-bootstrap"
"plugin-image-generation"
"plugin-node"
"plugin-solana"
"plugin-evm"
"plugin-tee"
)
# Start building the docker run command
CMD="docker run --platform linux/amd64 -p 3000:3000 -d"
# Add base mounts
for mount in "${BASE_MOUNTS[@]}"; do
CMD="$CMD -v \"$(pwd)/$mount\""
done
# Add package mounts
for package in "${PACKAGES[@]}"; do
CMD="$CMD -v \"$(pwd)/packages/$package/src:/app/packages/$package/src\""
done
# Add core types mount separately (special case)
CMD="$CMD -v \"$(pwd)/packages/core/types:/app/packages/core/types\""
# Add container name and image
CMD="$CMD --name eliza eliza"
# Execute the command
eval $CMD
;;
start)
docker start eliza
;;
bash)
# Check if the container is running before executing bash
if [ "$(docker ps -q -f name=eliza)" ]; then
docker exec -it eliza bash
else
echo "Container 'eliza' is not running. Please start it first."
exit 1
fi
;;
*)
echo "Invalid option: $1"
echo "Usage: $0 {build|run|start|bash}"
exit 1
;;
esac