Files
server/test-docker-build.sh
2025-11-01 15:50:06 +08:00

78 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
echo "=== Docker Build Test Script ==="
echo "Testing Dockerfile.stable build process..."
echo
# 检查Docker是否可用
if ! command -v docker &> /dev/null; then
echo "❌ Docker is not available on this system"
echo "Please run this script on a server with Docker installed"
exit 1
fi
echo "✓ Docker found: $(docker --version)"
# 构建镜像
echo
echo "🏗️ Building Docker image..."
echo "This may take several minutes..."
if docker build -f Dockerfile.stable -t digital-archive:test .; then
echo
echo "✅ Build successful!"
echo
echo "📋 Image details:"
docker images digital-archive:test
echo
echo "🧪 Testing container startup..."
# 测试容器启动
if docker run --rm --name test-container digital-archive:test java -version; then
echo "✅ Container test successful!"
else
echo "❌ Container test failed"
fi
# 清理测试镜像
echo
echo "🧹 Cleaning up test image..."
docker rmi digital-archive:test
else
echo
echo "❌ Build failed!"
echo
echo "🔍 Debugging info:"
echo "1. Check Dockerfile.stable for syntax errors"
echo "2. Verify all required files are present"
echo "3. Check network connectivity for package downloads"
echo "4. Verify src/main/lib/ directory contains all required JAR files"
echo "5. Try running with --no-cache flag:"
echo " docker build --no-cache -f Dockerfile.stable -t digital-archive:test ."
echo
echo "📋 Checking required files..."
if [ -f "pom.xml" ]; then
echo "✓ pom.xml found"
else
echo "❌ pom.xml missing"
fi
if [ -f "settings.xml" ]; then
echo "✓ settings.xml found"
else
echo "❌ settings.xml missing"
fi
if [ -d "src/main/lib" ]; then
echo "✓ src/main/lib directory found"
echo " JAR files in lib:"
ls -la src/main/lib/*.jar 2>/dev/null || echo " No JAR files found"
else
echo "❌ src/main/lib directory missing"
fi
fi
echo
echo "=== Test completed ==="