As developers, we often find ourselves switching between operating systems, facing compatibility issues, or longing for a more flexible development environment. In this post, I'll share my journey of setting up a remote development environment using a home lab, and how it has transformed my workflow.
While using MacOS with Apple Silicon (ARM-based CPU), I frequently encountered limitations when debugging Python libraries or building OCI images incompatible with ARM architecture. Despite the existence of Rosetta for x86 simulation, the terminal environment quickly became messy and difficult to manage.
To overcome these challenges, I decided to build a home lab with carefully selected PC components running Ubuntu Server 24.04 LTS. This server serves multiple purposes:
My typical development workflow involves:
Visual Studio Code makes remote development via SSH remarkably smooth, offering:
To protect against potentially harmful code execution and to facilitate experimentation, isolated development environments are crucial. While there are multiple options available, I chose LXD containers for their balance of isolation and resource efficiency.
QEMU virtual machines offer the strongest isolation by emulating entire systems, but they come with higher resource overhead and slower startup times. Both Docker and LXD containers use the same Linux kernel features for isolation, making them more lightweight and efficient compared to full VMs.
The key difference between Docker and LXD lies in their intended use cases. Docker containers are designed primarily for running single applications, whereas LXD containers provide a system container-like experience, allowing multiple applications to run within a single container. This makes LXD feel more like a full OS environment.
After considering these factors, I chose LXD containers for my setup due to their balance of isolation and flexibility, particularly their ability to easily run multiple applications in a system-like environment. To start an LXD container:
This setup allows me to create isolated environments that feel like full systems, making it easy to experiment with different configurations and run multiple services without the overhead of full virtual machines.
Tailscale provides secure remote access to the home lab server without exposing ports on the home's public IP. It's the Swiss Army knife of networking.
Tailscale creates a private cloud (tailnet) connecting:
Setting up Tailscale on a new LXD container:
Tailscale provides:
For seamless GitHub access:
gh auth login -p https --skip-ssh-key -w
In case of SSH issues, consider setting up a PiKVM for remote physical access to your server. This blog post from Tailscale explain how to setup a remotely accessible PiKVM: Access PiKVM from anywhere.
To enable Docker within LXD containers:
Setting up a remote development environment with a home lab has significantly improved my workflow, offering flexibility, security, and efficiency. By leveraging tools like VS Code, LXD containers, and Tailscale, you can create a powerful, versatile development setup that adapts to your needs.
Whether you're dealing with architecture incompatibilities, seeking a more isolated development environment, or simply want the freedom to work from any device, this setup provides a robust solution. Give it a try, and experience the benefits of remote development for yourself!