-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-test.sh
More file actions
executable file
·61 lines (51 loc) · 1.69 KB
/
docker-test.sh
File metadata and controls
executable file
·61 lines (51 loc) · 1.69 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
#!/bin/bash
# Test script for Docker setup
echo "===== Testing Docker setup for PDF Annotation Tool ====="
# Check if Docker is installed
if ! command -v docker &> /dev/null; then
echo "Error: Docker is not installed or not in PATH"
exit 1
fi
# Check if Docker Compose is installed
if ! command -v docker-compose &> /dev/null; then
echo "Warning: Docker Compose is not installed. You can still use plain Docker commands."
fi
# Build the Docker image
echo "Building Docker image..."
docker build -t pdf-annotation-tool-test .
if [ $? -ne 0 ]; then
echo "Error: Failed to build Docker image"
exit 1
fi
# Run the container in detached mode
echo "Starting container..."
CONTAINER_ID=$(docker run -d -p 9090:80 pdf-annotation-tool-test)
if [ $? -ne 0 ]; then
echo "Error: Failed to start container"
exit 1
fi
# Give the container a moment to start
echo "Waiting for container to initialize..."
sleep 3
# Test if the server is responding
echo "Testing HTTP connection..."
if command -v curl &> /dev/null; then
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:9090)
if [ "$response" != "200" ]; then
echo "Error: Server responded with status $response, expected 200"
docker stop $CONTAINER_ID > /dev/null
docker rm $CONTAINER_ID > /dev/null
exit 1
fi
else
echo "Warning: curl not found, skipping HTTP test"
fi
# Stop and remove the container
echo "Cleaning up..."
docker stop $CONTAINER_ID > /dev/null
docker rm $CONTAINER_ID > /dev/null
echo "===== Docker test completed successfully! ====="
echo "You can now use the Docker setup with:"
echo "docker-compose up -d"
echo "And access the application at http://localhost:8080"
exit 0