I recently faced a tricky challenge: transforming a complex
.NET
CLI app, built to parse a proprietary binary protocol, into a more flexible solution. It's powerful but, in fact, locked to Windows. Rewriting it from scratch wasn't an option, and the pre-built self-contained version wouldn't run on Mac (my host system) without modifying the source code – something I'd like to avoid.I wanted to make it accessible to other backends, like
Node.js
, and turn it into a self-hosted service.Here’s what I did:
- Created a multistage Dockerfile to containerize the CLI, making it platform-agnostic
- Built a lightweight Node.js server to wrap the CLI's output and expose its functionality via a REST API
- Added docker-compose configs both for prod and dev (with hot reloading)
- Implemented a smart build process to skip rebuilding the CLI app when only the Node.js server code changes
- Tested this setup on fly.io and render.com – both ran the container smoothly on their free tiers with limited resources
- Added a simple web playground for testing
The Result
- The CLI is now a portable service I can deploy anywhere containers are supported
- No dependency on .NET runtime on the host
- A thin REST api layer for interaction
It's not rocket science, but it shows how even complex desktop-oriented tools can be repurposed as lightweight services with very little glue code. Here is the source code, so you can explore the result.