Bank-Scrubber / build-docker.sh
Aryan Jain
bank scrubber streamlit application
4e71548
#!/bin/bash
# Docker build script for Bank Statement Analyzer
echo "🐳 Building Bank Statement Analyzer Docker Image"
echo "=================================================="
# Check if we're in the right directory
if [ ! -f "Dockerfile" ]; then
echo "❌ Error: Dockerfile not found in current directory"
echo " Please run this script from the project root directory"
exit 1
fi
# Check build context size
echo "πŸ” Checking build context size..."
python3 check-build-context.py
echo ""
echo "πŸ“¦ Building Docker image..."
# Check if pyproject.toml exists
if [ ! -f "pyproject.toml" ]; then
echo "❌ Error: pyproject.toml not found!"
echo " Please ensure you have a valid pyproject.toml file"
exit 1
fi
# Try building with the main Dockerfile first
echo "πŸ”„ Attempting build with main Dockerfile..."
docker build -t bank-statement-analyzer .
if [ $? -eq 0 ]; then
echo ""
echo "βœ… Docker image built successfully!"
echo ""
echo "πŸš€ To run the application:"
echo " docker run -p 8501:8501 --env-file .env bank-statement-analyzer"
echo ""
echo " Or use docker-compose:"
echo " docker-compose up"
else
echo ""
echo "⚠️ Main Dockerfile build failed. Trying alternative method..."
# Check if alternative Dockerfile exists
if [ -f "Dockerfile.alternative" ]; then
echo "πŸ”„ Attempting build with alternative Dockerfile..."
docker build -f Dockerfile.alternative -t bank-statement-analyzer .
if [ $? -eq 0 ]; then
echo ""
echo "βœ… Docker image built successfully with alternative method!"
echo ""
echo "πŸš€ To run the application:"
echo " docker run -p 8501:8501 --env-file .env bank-statement-analyzer"
echo ""
echo " Or use docker-compose:"
echo " docker-compose up"
else
echo ""
echo "⚠️ Alternative Dockerfile also failed. Trying fallback method..."
# Check if fallback Dockerfile exists
if [ -f "Dockerfile.fallback" ]; then
echo "πŸ”„ Attempting build with fallback Dockerfile (pip-based)..."
docker build -f Dockerfile.fallback -t bank-statement-analyzer .
if [ $? -eq 0 ]; then
echo ""
echo "βœ… Docker image built successfully with fallback method!"
echo ""
echo "πŸš€ To run the application:"
echo " docker run -p 8501:8501 --env-file .env bank-statement-analyzer"
echo ""
echo " Or use docker-compose:"
echo " docker-compose up"
else
echo ""
echo "❌ All Dockerfile methods failed!"
echo ""
echo "πŸ’‘ Troubleshooting tips:"
echo " - Check if Poetry is properly configured"
echo " - Ensure pyproject.toml and poetry.lock are valid"
echo " - Try running 'poetry install' locally first"
echo " - Check Docker logs for specific error messages"
echo " - Verify system dependencies are available"
echo ""
echo "πŸ”§ Manual troubleshooting:"
echo " docker build -t bank-statement-analyzer . 2>&1 | tee build.log"
exit 1
fi
else
echo ""
echo "❌ Fallback Dockerfile not found!"
echo ""
echo "πŸ’‘ Troubleshooting tips:"
echo " - Check if large files are being included in build context"
echo " - Ensure .dockerignore is properly configured"
echo " - Try running 'python3 check-build-context.py' to identify issues"
echo " - Check Poetry installation and configuration"
exit 1
fi
fi
else
echo ""
echo "❌ Alternative Dockerfile not found!"
echo ""
echo "πŸ’‘ Troubleshooting tips:"
echo " - Check if large files are being included in build context"
echo " - Ensure .dockerignore is properly configured"
echo " - Try running 'python3 check-build-context.py' to identify issues"
echo " - Check Poetry installation and configuration"
exit 1
fi
fi