# Local builds with resource limits
docker system prune -f # Clean up before building
chutes build my_chute:chute --local --memory 8g --cpus 4
Troubleshooting Builds
Common Build Issues
Build fails with dependency errors?
# Check requirements.txtcat requirements.txt
# Build with debug to see full output
chutes build my_chute:chute --local --debug
# Try building with no cache
chutes build my_chute:chute --no-cache --debug
Out of memory during build?
# For local builds, check available memory
free -h
# Use remote building for large models
chutes build my_chute:chute --wait# Remote has more memory# Optimize image layers# Put large downloads in separate layers
Build takes too long?
# Use remote building (usually faster)
chutes build my_chute:chute --wait# Optimize Docker layers in your Image definition# Check .chutesbuildignore to exclude unnecessary files# Use smaller base images where possible
Permission errors?
# Check file permissionsls -la
# Fix permissions if neededchmod -R 755 .
# For local builds, check Docker daemonsudo systemctl status docker
Debug Commands
# Inspect build context
tar -czf - . | tar -tz | head -20
# Check image layers
docker history myuser/my-chute:latest
# Inspect built image
docker run -it myuser/my-chute:latest /bin/bash
# Check build logs
chutes build my_chute:chute --debug 2>&1 | tee build.log
Build Strategies
Development Workflow
# Fast iteration during development
chutes build my_chute:chute --local --tag dev
# Test the built image
chutes run my_chute:chute --tag dev
# Once stable, build remotely
chutes build my_chute:chute --wait --tag stable
# Good: Stable operations first
.with_python("3.11")
.with_pip_packages("torch==2.1.0") # Pin versions
.add("requirements.txt", "/app/")
.run_command("pip install -r /app/requirements.txt")
.add("src/", "/app/src/") # Code changes most# Bad: Frequent changes first
.add("src/", "/app/src/") # This invalidates all subsequent layers
.with_pip_packages("torch")
2. Pin Dependencies
# requirements.txt - Good
torch==2.1.0
transformers==4.30.2
numpy==1.24.3
# requirements.txt - Bad
torch
transformers
numpy # Could break with version changes
3. Minimize Image Size
# Use multi-stage builds for smaller images# Clean up package caches
.run_command("""
apt-get update &&
apt-get install -y git curl &&
rm -rf /var/lib/apt/lists/*
""")
# Use .chutesbuildignore extensively
4. Security Scanning
# Scan images for vulnerabilities
chutes build my_chute:chute --scan-security
# Use official base images
.from_base("nvidia/cuda:12.2-runtime-ubuntu22.04") # Official