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

56 lines
1.4 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. Try running with --no-cache flag:"
echo " docker build --no-cache -f Dockerfile.stable -t digital-archive:test ."
fi
echo
echo "=== Test completed ==="