Database Migration Docker Example
This example demonstrates that the database extension with migrations can now start successfully in Docker containers after the migration initialization fix.
The Problem (Before)
Applications using Forge's database extension would panic during startup in Docker with:
panic: stat .: no such file or directory
goroutine 1 [running]:
github.com/xraph/forge/extensions/database/migrate.init.0()
The Solution (After)
The fix makes migration discovery lazy and graceful, allowing applications to start successfully in any environment.
Testing the Fix
Run Locally
cd examples/database-migration-docker
go run main.go
Expected output:
✅ Application started successfully!
✅ This would have panicked before the fix!
✅ Database extension with migrations works in Docker/CI!
✅ Application stopped gracefully
Run in Docker
cd examples/database-migration-docker
# Build the Docker image
docker build -t migration-demo .
# Run the container
docker run --rm migration-demo
Expected output:
✅ Application started successfully!
✅ This would have panicked before the fix!
✅ Database extension with migrations works in Docker/CI!
✅ Application stopped gracefully
What Changed
Before Fix
- ❌
init() function called DiscoverCaller() at package initialization
- ❌ Filesystem access required before
main() runs
- ❌ Panic if working directory doesn't exist or isn't accessible
After Fix
- ✅ Migration discovery is lazy (happens when actually needed)
- ✅ Filesystem errors are logged but don't prevent startup
- ✅ Applications start successfully in any environment
- ✅ Fully backward compatible
Files Changed
extensions/database/migrate/migrations.go - Core library fix
cmd/forge/plugins/database.go - Template generation fix
extensions/database/migrate/migrations_test.go - Comprehensive tests
This fix ensures applications work on:
- ✅ Docker / Podman
- ✅ Kubernetes
- ✅ Render.com
- ✅ Fly.io
- ✅ Railway
- ✅ Google Cloud Run
- ✅ AWS ECS/Fargate
- ✅ Azure Container Instances
- ✅ Any containerized platform
Technical Details
See the following documentation for more details:
MIGRATION_FIX_SUMMARY.md - Quick summary
MIGRATION_INITIALIZATION_FIX.md - Detailed technical documentation