A self-hosted Rails development platform is a private, infrastructure-as-code environment where AI agents operate within isolated virtual machines, ensuring that sensitive code, credentials, and data never leave your controlled network while enabling 24/7 autonomous development cycles.
Why Senior Rails Teams Need Private AI Infrastructure
The primary driver for building a private environment is risk containment. When you run agentic coding tools like Claude Code or Cursor, you are handing over significant autonomy to a model that executes shell commands, reads files, and potentially interacts with your network. In a public cloud or a shared laptop environment, a single prompt injection or a hallucinated command can expose your API keys, leak proprietary business logic, or corrupt your local state. By moving this workload to a dedicated, isolated home server, you create a hard boundary between the AI’s experimental sandbox and your production systems.
I built this setup because my laptop was becoming a thermal bottleneck. Running multiple virtual machines (VMs) for different Rails projects caused my battery to drain rapidly and the chassis to heat up uncomfortably. More importantly, I wanted a persistent, always-on environment where agents could work while I slept. This is not about replacing human developers; it is about creating a safe, reproducible “factory” where AI agents can perform repetitive, risky, or long-running tasks without jeopardizing the stability of your primary workstation or exposing your secrets to third-party servers.
The core philosophy here is isolation. Every project gets its own VM. Every service (Git, CI/CD, DNS) is separated by VLANs. If an agent goes rogue in one project, the blast radius is limited to that specific VM and its immediate network segment. This level of control is difficult to achieve with standard cloud offerings, which often rely on shared kernels or less granular network segmentation for individual developer instances.
How to Architect the Hardware and Virtualization Layer
The foundation of this platform is a refurbished Dell Optiplex Micro 7010 with a 13th Gen Intel Core i5-13500T and 32 GB of RAM. I chose the Micro chassis specifically for its low power consumption and quiet operation, making it suitable for a home office environment. I initially considered an i7, but the price difference for the Micro form factor was significant, and 32 GB of RAM is sufficient for running 3-5 concurrent lightweight VMs running Rails development environments.
I installed Proxmox VE as the base operating system. Proxmox is an open-source virtualization platform that allows me to manage KVM virtual machines and LXC containers. Since I already owned a Lenovo ThinkCentre Tiny running Proxmox, I used Proxmox Datacenter Manager to oversee both hosts. This centralizes management and allows me to monitor resource usage across my entire home cluster.
For the virtualization strategy, I use a VM per project. This ensures that if a specific Rails application crashes, hangs, or is compromised by a malicious agent action, it does not affect other projects. Each VM runs a standard Ubuntu LTS image with Docker and the necessary Ruby/Rails tooling. The key advantage here is reproducibility. If a VM becomes unstable, I can destroy it and spin up a fresh one from a template in minutes. This “disposable” nature is critical for AI-driven development, where agents might execute destructive commands like rm -rf / or modify system files in ways that are hard to reverse.
# Example: Creating a new VM from a template in Proxmox
# This command assumes you have a base template VM with ID 9000
qm clone 9000 101 --name rails-project-alpha
qm start 101This approach also simplifies resource management. I can set CPU and memory limits per VM to ensure that one heavy build process doesn’t starve others of resources. For a senior Rails team, this translates to a predictable development environment where performance issues are isolated and debuggable, rather than a shared resource contention problem.
Networking Isolation: VLANs and Secure DNS
Network segmentation is the most critical security feature of this setup. I divided my home network into two primary VLANs: srv (services) and dev (development machines). The srv VLAN hosts all supporting infrastructure, including Git, CI/CD, and DNS. The dev VLAN hosts the individual project VMs.
This separation prevents a compromised dev VM from scanning the entire network for management ports or sensitive services. For example, if an AI agent in a dev VM attempts to perform a port scan, it will only see other dev VMs, not the Forgejo instance or the Semaphore CI/CD server. I implemented this using VLAN ACLs on my router, creating tiny, specific “holes” that allow dev VMs to communicate with necessary services like Git and DNS, while blocking everything else.
For DNS, I self-hosted Technitium, a lightweight DNS and DHCP server. Technitium handles internal domain resolution and provides a “Magic DNS” feature. When a new dev VM boots with a hostname like alpha, Technitium automatically creates a DNS record for alpha.dev.mydomain.net. This eliminates the need for manual DNS configuration and ensures that services can reliably resolve each other by name rather than IP address.
However, DHCP requests are broadcast packets, which do not cross VLAN boundaries. To solve this, I ran a small LXC container in the dev VLAN using dnsmasq as a DHCP relay. This relay forwards DHCP requests from the dev VLAN to the Technitium server in the srv VLAN. This setup ensures that every new VM automatically gets an IP address and a DNS record without manual intervention.
| Component | VLAN | Purpose | Isolation Benefit |
|---|---|---|---|
| Technitium DNS/DHCP | srv |
Internal name resolution | Prevents dev VMs from spoofing DNS |
| Forgejo Git | srv |
Code repository | Agents cannot access Git management API directly |
| Dev VMs | dev |
Rails project execution | Compromised VMs cannot scan srv VLAN |
| CI/CD Runner | isolated |
Build and test execution | Completely isolated from both srv and dev |
This architecture might seem overkill for a home setup, but for a senior team handling sensitive client code, the security posture is non-negotiable. The complexity of managing VLANs and ACLs is a one-time cost that pays off in reduced risk.
Self-Hosted Services: Git, CI/CD, and Automation
I chose Forgejo as my self-hosted Git solution. Forgejo is a lightweight, community-driven fork of Gitea, designed for self-hosting. It provides a familiar GitHub-like interface for managing repositories, pull requests, and issues. By self-hosting Git, I ensure that my code never leaves my network. This is crucial for proprietary Rails applications where intellectual property protection is paramount.
For CI/CD, I initially used Forgejo Actions, similar to GitHub Actions. However, I encountered a significant security issue. Forgejo Actions store secrets (like SSH keys for deployment) in the repository settings. An AI agent running in a dev VM could potentially access these secrets if it had the right permissions or if a prompt injection allowed it to read environment variables. To mitigate this, I moved deployment logic to Semaphore UI. Semaphore holds the private SSH keys and only executes deploys from the main branch after manual approval. This separation of duties ensures that even if an agent compromises a dev VM, it cannot trigger a production deploy or exfiltrate deployment keys.
The CI/CD runner itself runs in a completely isolated VLAN, separate from both srv and dev. This runner downloads code from Forgejo, executes tests, and pushes artifacts. Because it is isolated, a compromised runner cannot access the dev VMs or the management interfaces of other services. This layered defense ensures that no single point of failure can compromise the entire pipeline.
# Example: A simple Rake task to trigger a CI/CD pipeline
# This task is run inside the dev VM and calls the Semaphore API
namespace :ci do
desc "Trigger Semaphore CI/CD pipeline"
task :trigger do
require 'net/http'
uri = URI.parse("https://semaphore.mydomain.net/api/v1/projects/my-rails-app/pipelines")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req['Content-Type'] = 'application/json'
req['Authorization'] = "Bearer #{ENV['SEMAPHORE_API_KEY']}"
req.body = { branch: 'main' }.to_json
response = http.request(req)
puts "Pipeline triggered: #{response.code}"
end
endThis setup allows me to maintain a strict security boundary while still leveraging the automation benefits of CI/CD. The agents can commit code and trigger tests, but they cannot bypass the human-in-the-loop approval for production deploys. This is a critical control for any team using AI in their development workflow.
Managing AI Agents and Harnesses
The heart of this platform is the AI agent harness. I use Claude Code as my primary agent, but the setup is designed to be harness-agnostic. Each dev VM has a pre-configured environment with the necessary tools (Ruby, Rails, Postgres, Redis) and the AI agent CLI installed. The agents are given specific permissions and instructions to work within the project directory.
I explicitly decided against using third-party control panels for agents. Many of these tools are either vibe-coded or VC-funded, and I wanted to avoid building my workflow around a tool that might change, disappear, or introduce security vulnerabilities. Instead, I built a simple, custom harness that manages the lifecycle of the agents. This harness handles starting and stopping agents, logging their output, and capturing their changes.
The key to effective agent management is clear instructions and strict boundaries. I use a CLAUDE.md file in each project root to define the agent’s behavior. This file specifies which files it can modify, which commands it can run, and what the definition of “done” is for each task. For example, I might instruct the agent to only modify files in the app/ directory and to run bundle exec rspec after making changes.
# CLAUDE.md
## Project Overview
This is a Rails 8 application using Hotwire.
## Rules
1. Only modify files in the `app/` and `spec/` directories.
2. Do not modify `Gemfile` or `Gemfile.lock` without explicit permission.
3. Always run `bundle exec rspec` after making changes.
4. If a test fails, fix the code, not the test, unless the test is incorrect.
## Workflow
1. Read the task description.
2. Plan the changes.
3. Implement the changes.
4. Run tests.
5. Commit changes with a descriptive message.This structured approach ensures that the agents operate within a predictable framework. It reduces the risk of unintended side effects and makes it easier to review the changes they make. For senior Rails developers, this means less time spent debugging agent errors and more time reviewing high-level architectural decisions.
Security Considerations and Best Practices
Security is not an afterthought in this setup; it is the primary design constraint. Every component is chosen and configured with security in mind. Here are the key practices I follow:
- Least Privilege: Each agent runs with the minimum permissions necessary. They do not have root access, and they are restricted to specific directories and commands.
- Network Segmentation: As discussed, VLANs and ACLs prevent lateral movement. A compromised VM cannot access other VMs or sensitive services.
- Secret Management: Secrets are stored in a dedicated secrets manager (like Vault or a simple encrypted file) and are injected into the environment only when needed. They are never hardcoded in the codebase or committed to Git.
- Audit Logging: All agent actions are logged. This includes commands executed, files modified, and network requests made. These logs are reviewed regularly to detect any suspicious behavior.
- Regular Updates: All software, including the OS, Proxmox, and agent CLIs, is kept up to date with the latest security patches.
Verification note: The specific security impact of prompt injection attacks on agentic coding tools is an evolving field. While network segmentation and least privilege significantly reduce risk, no system is immune to all forms of attack. Teams should continuously monitor and update their security practices as new threats emerge.
By following these best practices, you can create a secure environment for AI-driven development. This allows you to leverage the productivity benefits of AI without compromising the security of your codebase or infrastructure.
Frequently asked questions
Can I use this setup for production workloads?
No, this setup is designed for development and testing only. Production workloads should run in a dedicated, highly available cloud or on-premises environment with appropriate redundancy and monitoring. The home server is not designed to handle production traffic or provide the required uptime guarantees.
How do I handle database migrations in isolated VMs?
Each VM has its own local PostgreSQL instance. Migrations are run locally within the VM. When code is merged to main, the CI/CD pipeline runs migrations in a staging environment. This ensures that migrations are tested in an isolated environment before being applied to production.
What if an agent deletes a file I need?
Since each VM is disposable, you can always restore the file from Git. If the file was not committed, you can restore it from a backup. To mitigate this risk, I recommend committing changes frequently and using Git as the source of truth. Additionally, you can configure the agent to avoid deleting files without explicit permission.
Is this setup cost-effective compared to cloud services?
The initial hardware cost is higher than a cloud subscription, but the ongoing costs are minimal (electricity and internet). For teams that run many concurrent development environments, the cost savings can be significant. However, you must factor in the time and effort required to set up and maintain the infrastructure.
Can I use this with other AI models?
Yes, the setup is harness-agnostic. You can use any AI model that has a CLI interface. The key is to configure the model with the appropriate permissions and instructions. The network and virtualization layers remain the same regardless of the AI model used.
Conclusion
Building a self-hosted Rails development platform is a significant investment of time and effort, but the payoff is a secure, isolated, and reproducible environment for AI-driven development. By using Proxmox for virtualization, VLANs for network segmentation, and self-hosted services for Git and CI/CD, you can create a “factory” where AI agents can work safely and efficiently.
This setup is not for everyone. It requires a certain level of technical expertise and a willingness to manage your own infrastructure. However, for senior Rails teams that value security, control, and cost predictability, it is a powerful solution. If you are interested in implementing a similar setup for your team, I recommend starting small. Begin with a single VM and a simple network configuration, and gradually add complexity as you become more comfortable with the tools.
For more insights on integrating AI into your Rails workflow, check out How Agentic Development Can Transform Your Rails Team’s Productivity and How to Build a Fail-Safe LLM Gateway in Rails for Multi-Provider AI Routing. If you are looking for expert guidance on implementing AI-powered development practices, book a discovery call to discuss how we can help your team build a secure and efficient AI development environment.
See the related service for hands-on help. Primary source: the official project page.


