Repository navigation
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·63 lines (57 loc) · 1.8 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·63 lines (57 loc) · 1.8 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
#!/bin/bash
# Runs the AutonomousSimulator web image on the mini PC: bash deploy.sh <image_ref>
set -euo pipefail
IMAGE_REF=$1
NAME=autonomoussim
URL=http://127.0.0.1:5060/
RESULTS_PATH="$HOME/autonomoussim/results"
SECRETS_PATH="$HOME/.autonomoussim-secrets"
AK_PATH="$HOME/AutonomousKart"
echo "Checking host paths..."
mkdir -p "$RESULTS_PATH"
for p in "$SECRETS_PATH/env" "$SECRETS_PATH/ssh" "$AK_PATH"; do
if [ ! -e "$p" ]; then
echo "Missing $p (see the Deploy section of README.md)"
exit 1
fi
done
if ! grep -q '^AUTONOMOUS_SIM_PASSWORD=.' "$SECRETS_PATH/env"; then
echo "AUTONOMOUS_SIM_PASSWORD is not set in $SECRETS_PATH/env"
exit 1
fi
HF_UPLOAD=1
grep -q '^HF_TOKEN=.' "$SECRETS_PATH/env" || HF_UPLOAD=0
if [ "$(git -C "$AK_PATH" config --get remote.origin.mirror || true)" != "true" ]; then
echo "Warning: $AK_PATH is not a mirror clone, so its local branches stay stale after a fetch"
fi
echo "Pulling Docker image: $IMAGE_REF"
docker pull "$IMAGE_REF"
echo "Stopping existing container..."
docker stop "$NAME" || true
docker rm "$NAME" || true
echo "Starting new container..."
docker run -d \
--name "$NAME" \
--restart unless-stopped \
--network host \
--pid host \
--env-file "$SECRETS_PATH/env" \
-e AUTONOMOUS_SIM_RESULTS=/data/results \
-e AUTONOMOUS_KART_REPO=/repos/AutonomousKart \
-e AUTONOMOUS_SIM_HF_UPLOAD="$HF_UPLOAD" \
-v "$RESULTS_PATH:/data/results" \
-v "$AK_PATH:/repos/AutonomousKart" \
-v "$SECRETS_PATH/ssh:/root/.ssh" \
"$IMAGE_REF"
echo "Waiting for $URL..."
for _ in $(seq 30); do
if curl -fsS -o /dev/null "$URL"; then
echo "Deployment successful!"
docker ps --filter name="$NAME" --format "table {{.Names}}\t{{.Status}}\t{{.Image}}"
exit 0
fi
sleep 2
done
echo "Container did not answer on $URL"
docker logs --tail 200 "$NAME" || true
exit 1