Skip to content
← Back to writing

September 12, 2025

The 3 AM Linux deploy

I started at 3 AM. By 7:30 AM the binary was running on a real Linux VM. Cross-compilation failed, CORS was wrong, paths were hardcoded. But it worked.

3 AM

The repo's first two commits, pinned in git: "Working HomelabARR PE with Samba/NFS services," September 12, 2025, 11:19 PM — 1,346 files landing in one commit.

The insomnia was productive for once. I'd been building HomelabARR PE for six weeks on my Windows desktop, cross-compiling for Linux, and I'd never once run it on Linux. The target hardware was a UGREEN DXP8800 Plus, the test environment a Proxmox VM, and I'd put off actually running it long enough.

VM 104 on my Proxmox server. Ubuntu 25.04. IP 192.168.1.229. I SSH'd in and started trying to get the binary over there.

Cross-compilation, a comedy of errors

First attempt: cross-compile from Windows with GOOS=linux GOARCH=amd64 go build. The binary built. I copied it to the VM. It wouldn't execute. I checked the file header and it said MZ. That's a Windows executable. The cross-compile had silently produced a Windows binary anyway.

Second attempt, different flags, same result: an MZ header and another Windows binary.

Third attempt: I gave up on cross-compiling, installed Go directly on the Ubuntu VM, cloned the repo, and built natively. This time it was an ELF header, and it ran.

Cross-compilation from Windows to Linux is supposed to work. When the build environment is misconfigured or CGo sneaks in, it silently hands you the wrong thing, and you don't find out until the kernel refuses to run it. Building on the target itself is slower, and it doesn't have that failure mode.

Four bugs in four hours

The binary ran. The server came up on port 8080. I opened http://192.168.1.229:8080 in Chrome, and the React dashboard loaded, partially, before the console filled with errors.

Bug one was the static files. The server was serving from the wrong directory. The Vite build output landed in web/static/, but the Go file server was pointed somewhere else, so the page came up empty. The fix was one line in simple-server.go:

// simple-server.go, the static handler
fileServer := http.FileServer(http.Dir("./web/static/"))
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
	enableCORS(w, r)
	if r.Method == "OPTIONS" {
		w.WriteHeader(http.StatusOK)
		return
	}
	fileServer.ServeHTTP(w, r)
})

Point it at the directory the build actually writes to, and the dashboard loaded.

Bug two was API path duplication. The frontend was calling /api/api/system instead of /api/system. The base URL was already /api, and the request layer prepended /api again. Every system and storage endpoint came back 404 until the base URL stopped being double-counted.

Bug three was CORS. The server only trusted http://localhost:5173, the Vite dev server. A browser hitting http://192.168.1.229:8080 is not localhost, so every call that got past the path bug was then blocked by CORS. The fix was to stop hardcoding one dev origin and load an allowlist that actually included the VM:

{
  "AllowedOrigins": [
    "http://localhost:5173",
    "http://127.0.0.1:5173",
    "http://192.168.1.229:8080",
    "http://192.168.1.229:5173",
    "http://192.168.1.229"
  ],
  "AllowedMethods": ["GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"],
  "AllowCredentials": true
}

That 192.168.1.229:8080 line is the whole bug, written down. Six weeks of building and the one origin that mattered, the box it was actually going to run on, was never in the list.

Bug four was the hardcoded localhost. Some of the frontend still pointed at localhost:8080 for API calls. When you only ever load the app from your own machine, that works fine and you never notice. The fix was to derive the API URL from wherever the page is being served instead of assuming it's local:

// api.ts — production: use the current origin, not localhost
const origin = window.location.origin.replace(/:\d+$/, '') + ':8080';
return `${origin}/api`;

If the browser is on the VM, the API is on the VM, rather than wherever the developer's laptop happens to be.

7:30 AM

Four and a half hours, four bugs, and every one of them came from the same place: the gap between the machine I built on and the machine it had to run on. A single test deploy any time in the previous six weeks would have caught all four, and I never ran one.

By 7:30 AM the dashboard was up. Containers were loading. Docker was being managed. The React UI was rendering on a real Linux box on my real network. Not localhost, not a dev server. A Go binary serving an embedded React frontend, managing real Docker containers, on hardware I could touch.

I took a screenshot. It wasn't pretty. There were still API errors in the console, the storage page wasn't loading, and the frontend was stuck showing demo data, but the bones were there. The first commit of that working state went in at 11:19 PM that same day, with a message that admits as much: "Working HomelabARR PE with Samba/NFS services, Frontend still showing Demo Mode issue."

Six weeks earlier I didn't know how to code. Now there was a NAS operating system running on Linux, broken in places and rough at every edge, but actually running on a real machine doing real things.

I filed the remaining bugs and went to bed. It was 8 AM, and my kid would be up in an hour. I'd built NAS software in my parents' house, starting at 3 AM because my brain wouldn't let me sleep.

homelabarr.com · mjashley.com