WepNG Docker & .NET Migration Strategy
[!IMPORTANT] Key Finding: The
EITWEP.ModelandPersistencelayers utilize Entity Framework 6.4.4, generated by LLBLGen Pro. This is a Game Changer. EF 6.4.4 supports .NET Standard 2.1, meaning we can reuse the existing data access layer in a modern .NET 8 applications running on Linux Containers.
1. The Strategy: "Hybrid Strangler Fig"β
We do not need to choose between "Stay on Windows" and "Rewrite Everything". We can have both.
Phase 1: Containerize Legacy (Windows Containers)β
Goal: CI/CD Consistency & "it works on my machine".
- Image:
mcr.microsoft.com/dotnet/framework/aspnet:4.8 - Size: Large (~4-8 GB).
- Host: Requires Windows Server nodes (or Azure App Service for Containers Windows).
- Value: Eliminates "folder X is missing" issues (like
C:\temp\). Forces configuration externalization.
Phase 2: The .NET 8 "Sidecar" (Linux Containers)β
Goal: Performance & Modernization.
- Action: Create a new project
WepNG.ModernAPI(ASP.NET Core 8). - Dependency: Reference existing
EITWEP.ModelandEITWEP.Persistence(converted to .NET Standard). - Deployment: run as a lightweight Linux Container side-by-side with the Legacy Monolith.
- Routing: Configure a Reverse Proxy (YARP) in the Legacy App (or upfront) to route specific traffic to the New App.
Phase 3: Strangler Migrationβ
- Identify high-traffic/low-dependency read endpoints (e.g.,
CodePromoLivechecks). - Implement them in
WepNG.ModernAPIusing the shared Data Context. - Switch traffic.
- Shut down legacy controllers.
2. Windows vs Linux Containers: The Reality Checkβ
To justify the effort of the "Hybrid Strangler" approach, we must quantify the cost of remaining solely on Windows Containers vs moving to Linux.
Technical Comparisonβ
| Feature | πͺ Windows Containers (Legacy) | π§ Linux Containers (.NET 8) | Impact |
|---|---|---|---|
| Base Image Size | Huge (3GB - 8GB) | Tiny (100MB - 300MB) | Slower pulls, higher storage costs, longer CI/CD pipelines. |
| Startup Time | Slow (15s - 90s) | Instant (< 1s) | Critical for auto-scaling and "serverless" scenarios. |
| Kernel | Isolated kernels (Hyper-V often needed) | Shared Host Kernel | Windows requires heavier virtualization overhead. |
| Orchestration | Second-class citizen in K8s | Native / First-class | Windows nodes often have networking quirks or limited CNI support. |
| Dev Experience | Requires Windows Pro/Enterprise | Runs anywhere (Mac/Linux/Win) | Developers on Macs cannot run Windows Containers natively. |
Cost Comparison (Cloud / Azure Example)β
| Item | πͺ Windows | π§ Linux | Note |
|---|---|---|---|
| OS License | Paid. Approx +40-50% on compute costs. | Free (usually included in node price). | Windows nodes in AKS/EKS carry a licensing surcharge. |
| Density | Low. High RAM overhead per pod. | High. Minimal overhead. | You need more nodes to run the same number of Windows apps. |
| Spot Instances | Harder to use (slow startup). | Ideal (fast recovery). | Linux allows aggressive cost-saving via Spot/Preemptible VMs. |
[!WARNING] Conclusion: Staying on Windows Containers is a "Tax on Innovation". The migration to Linux (.NET 8) is not just technicalβit directly reduces monthly OpEx by an estimated 30-50% for the compute layer.
3. Infrastructure Evolution: On-Premise Datacenterβ
User asked: "Can we use our existing Datacenter to run these Linux machines?"
Answer: YES, absolutely.
Your current hardware (Datacenter) uses a Hypervisor (likely VMware ESXi, Hyper-V, or Nutanix). This Hypervisor usually hosts Windows VMs. It can host Linux VMs just as easily.
The Transformationβ
- Today: You have big Physical Servers hosting heavy Windows Server VMs (running IIS).
- Tomorrow: You use the same Physical Servers to host lightweight Linux VMs (running Docker/Kubernetes).
Benefits for On-Premiseβ
- Higher Density: You can run many more Linux Containers on the same physical hardware compared to Windows-based-IIS apps.
- No New Hardware: You do not need to buy new servers. You just provision different VMs.
- License Savings: Every Windows VM you replace with a Linux VM saves a Windows Server License cost (Datacenter Edition).
4. Technical Feasibility Analysisβ
| Component | Current State | Target State (.NET 8) | Feasibility |
|---|---|---|---|
| Data Layer | EF 6.4.4 (Generated by LLBLGen) | EF 6.4.4 (running on .NET 8) | HIGH. EF 6.4 is compatible. |
| Web Framework | ASP.NET MVC 5 (System.Web) | ASP.NET Core 8 MVC | ZERO. Requires manual porting of Controllers. |
| Logic | WepNG_Business (Class Lib) | .NET Standard / .NET 8 | MEDIUM. Requires removing HttpContext dependencies. |
| Authentication | ASP.NET Identity (OWIN) | ASP.NET Core Identity | MEDIUM. Cookies can be shared via Data Protection keys. |
5. Roadblocks & Solutionsβ
A. System.Web in Business Logicβ
- Problem:
WepNG_BusinessusesHttpContext.Current(verified in analysis). - Solution: Abstract current user/cache behind
ICurrentUserProvider/ICacheProviderinterfaces. Implement one for Legacy (Web) and one for Modern (Core).
B. Windows Dependenciesβ
- Problem: Searching for
System.Drawing,CrystalReports(if any), or COM objects. - Analysis:
System.Drawingis present. It must be replaced byImageSharporSkiaSharpfor Linux compatibility.
6. Recommendation for Userβ
Do NOT attempt a full port of WepNG_MVC to .NET 8. It is too entangled.
DO implement the Hybrid Strangler:
- Refactor
EITWEP.Modelto target.NET Standard 2.1. (This allows it to be used by both Legacy 4.8 and Modern 8.0). - Create
WepNG.ModernAPIfor all new features (e.g., the Reports, User Dashboard). - Dockerize:
- Legacy App -> Windows Container (if budget permits Windows Nodes) OR keep on IIS/Azure App Service.
- Modern API -> Linux Container (Kubernetes/Cloud Run).
7. Addendum: Why not split EITWEP.Model?β
User asked: "Shouldn't we unpack/split EITWEP.Model too?"
Answer: Not yet.
- Risk:
EITWEP.Modelcontains thousands of entities. Splitting it before the migration is a "Big Bang" refactoring risk (breaking everything at once). - Pattern: We use the "Shared Database Pattern" (or Shared Kernel). The Legacy System and the Modern System share the same compiled Data Layer (
EITWEP.Model.dll) temporarily. - Evolution: We will "unpack" the domain logically by creating new, small Bounded Contexts for new features (e.g.,
WepNG.Module.Booking), eventually leavingEITWEP.Modelas a read-only legacy wrapper.
8. Next Stepsβ
- Spike: Try to compile
EITWEP.Modelas.NET Standard 2.0. - Spike: Create a "Hello World" .NET 8 Console App that queries the DB using
EITWEP.Model. - Output: If Step 2 works, the path to Docker (Linux) is open.