Overview
Docker deployment allows you to:- Package your Evidence app with all dependencies
- Deploy to any Docker-compatible platform
- Ensure consistent builds across environments
- Scale horizontally with container orchestration
Creating a Dockerfile
Create aDockerfile in your Evidence project root:
Docker Ignore File
Create a.dockerignore file to exclude unnecessary files:
Building the Docker Image
Docker Compose
For more complex setups with databases, use Docker Compose:Environment Variables
Build-Time Variables
Pass secrets during the build phase:Using .env Files
Deployment Platforms
AWS ECS
- Push image to ECR:
- Create ECS task definition and service
Google Cloud Run
Azure Container Instances
Kubernetes
Optimization Tips
Multi-Stage Builds
Use multi-stage builds to reduce final image size:- Build stage includes all build dependencies
- Production stage only includes runtime dependencies and built files
Layer Caching
Optimize build times by ordering Dockerfile commands:- Copy package files first
- Install dependencies
- Copy source code last
Smaller Base Images
Use Alpine-based images for smaller sizes:node:18-alpineinstead ofnode:18nginx:alpineinstead ofnginx
Troubleshooting
Build Fails with Memory Error
Increase Docker memory limit or add to Dockerfile:Container Exits Immediately
Check logs:Can’t Connect to Database
- Verify network connectivity between containers
- Use service names (not localhost) in Docker Compose
- Check firewall rules for external databases
Files Not Updating
Clear Docker cache:Next Steps
- Set up CI/CD pipelines for automated builds
- Configure health checks
- Implement secrets management