-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_docker.sh
More file actions
42 lines (33 loc) · 882 Bytes
/
test_docker.sh
File metadata and controls
42 lines (33 loc) · 882 Bytes
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
#!/bin/bash
set -e
# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color
IMAGE_NAME="openspec-ui:test"
CONTAINER_NAME="openspec-ui-test"
cleanup() {
echo "Cleaning up..."
if [ "$(docker ps -aq -f name=$CONTAINER_NAME)" ]; then
docker rm -f $CONTAINER_NAME > /dev/null
fi
}
trap cleanup EXIT
echo "Building Docker image..."
docker build -t $IMAGE_NAME .
echo "Starting container..."
docker run -d --name $CONTAINER_NAME -p 3000:3000 $IMAGE_NAME
echo "Waiting for health check..."
# Wait up to 30 seconds for the service to be ready
for i in {1..30}; do
if curl -s http://localhost:3000/api/health > /dev/null; then
echo -e "${GREEN}Health check passed!${NC}"
exit 0
fi
echo -n "."
sleep 1
done
echo -e "\n${RED}Health check failed.${NC}"
echo "Container logs:"
docker logs $CONTAINER_NAME
exit 1