initial commit
This commit is contained in:
75
test-docker.sh
Executable file
75
test-docker.sh
Executable file
@@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Script to test the Docker setup for the FFXI Trust Characters web app
|
||||
|
||||
echo "Testing Docker setup for FFXI Trust Characters web app..."
|
||||
|
||||
# Check if Docker is installed
|
||||
if ! command -v docker &> /dev/null; then
|
||||
echo "Error: Docker is not installed. Please install Docker first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if Docker Compose is installed
|
||||
if ! command -v docker-compose &> /dev/null; then
|
||||
echo "Error: Docker Compose is not installed. Please install Docker Compose first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Build the Docker image
|
||||
echo "Building Docker image..."
|
||||
docker-compose build
|
||||
|
||||
# Start the Docker container
|
||||
echo "Starting Docker container..."
|
||||
docker-compose up -d
|
||||
|
||||
# Wait for the container to start
|
||||
echo "Waiting for the container to start..."
|
||||
sleep 5
|
||||
|
||||
# Check if the container is running
|
||||
if [ "$(docker-compose ps -q | wc -l)" -eq 0 ]; then
|
||||
echo "Error: Docker container failed to start."
|
||||
docker-compose logs
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test the API
|
||||
echo "Testing API..."
|
||||
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000/api/trusts)
|
||||
|
||||
if [ "$response" -eq 200 ]; then
|
||||
echo "API test successful!"
|
||||
else
|
||||
echo "Error: API test failed with status code $response."
|
||||
docker-compose logs
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test the web app
|
||||
echo "Testing web app..."
|
||||
response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:3000)
|
||||
|
||||
if [ "$response" -eq 200 ]; then
|
||||
echo "Web app test successful!"
|
||||
else
|
||||
echo "Error: Web app test failed with status code $response."
|
||||
docker-compose logs
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "All tests passed! The Docker setup is working correctly."
|
||||
echo "You can access the web app at http://localhost:3000"
|
||||
echo "You can access the API at http://localhost:3000/api/trusts"
|
||||
|
||||
# Ask if the user wants to stop the container
|
||||
read -p "Do you want to stop the Docker container? (y/n) " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "Stopping Docker container..."
|
||||
docker-compose down
|
||||
echo "Docker container stopped."
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user