Build Log

Running a MacBook as a 24/7 Server (DevToolStack Dev Log #6)

7개 층을 쌓아 올리는 시리즈 커버 — 여섯 번째 층이 놓인 상태

In part 3, I decided to keep the admin panel on the MacBook at home. Once I'd ruled out renting a server, the writing side had to live on a machine of mine somewhere. This part covers how I made that one machine act like a server, and the bruises I picked up along the way. Not a single port on the router is open.

1. It's Not a Server, Just a MacBook

1.1 If It's Off, I Can't Write — But Readers Never Know

I already wrote about the weak point of this setup in part 3. If the MacBook is off, I can't do anything.

But it's different for readers. The blog is a static site hosted on Cloudflare, decoupled from my machine. Even if the MacBook is off, posts keep serving fine.

When the MacBook is off
Readers reading posts No impact
Me writing posts Can't
Publishing / deploying Can't

Since I'm the only one affected, I figured this tradeoff was acceptable.

1.2 Running for 32 Days Straight

In practice, the MacBook holds up better than I expected. As of writing this, it's been running for 32 days straight, with no reboots in between.

I haven't touched any power management settings — sleep is still at the macOS defaults. So this isn't a machine tuned to act like a server; it's closer to an everyday laptop that just happens to stay on.

2. Making Everything Start Itself on Boot

2.1 I Used to Start Things by Hand

For a while I started the servers by typing commands into the terminal myself. As long as everything kept running, it was fine.

The problem is what happens after a reboot. Turn the MacBook off and back on, and neither the admin panel nor the blog server comes back up. If I don't notice, the public site stays stuck on an old build, and anything I write never gets published. There's not even a signal that something's broken.

2.2 Registering Four Launch Agents

macOS has a mechanism for registering "launch this when the machine starts." I registered four.

Registered What it does When
Admin Writing interface Immediately on boot
Blog server Serves the built static files Immediately on boot
Tunnel Inbound path from outside Immediately on boot
Nightly batch Collects metrics & feedback Daily at 04:30

I set them to auto-restart if they die. For all three, if the process disappears, it's relaunched on a 20-second interval.

I actually killed the processes with kill -9 and confirmed they came back up with a new PID. I didn't bother testing an actual reboot — there's a command that boots them through the same path, so I used that instead.

3. Getting In From Outside

3.1 Not a Single Port Open

My first idea was to open a port on the router and connect via the public IP. But that cuts a door into my home network, and the IP changes anyway.

A tunnel works the opposite way. The MacBook initiates an outbound connection to Cloudflare first, and requests ride in over that connection. There's no door from the outside into the house.

flowchart LR
  me(("Phone")) --> cf["Cloudflare<br/>Access Auth"]
  cf --> tun["Tunnel"]
  mac["MacBook<br/>Admin :3000"] -.outbound connection.-> tun
  tun --> mac

3.2 Get the Order Wrong, and It's Open for That Instant

There's a trap here. Creating the tunnel and wiring up the domain, versus putting authentication in front of it, are two separate steps.

If you connect the domain first, the admin panel is exposed to the open internet right then and there. Even if you plan to add auth later, it's wide open in the gap.

So I locked in an order: create the tunnel → set the access policy first → then connect the domain. I wrote this order into the install script and the docs too.

3.3 Two Doors to Get Through

Getting in requires passing both.

  1. Cloudflare Access — Cloudflare verifies identity before any request reaches the admin screen
  2. Admin login — password + two-factor authentication

Hitting /admin, /api/posts, or /api/users without auth redirects to a login screen every time — not a single character of admin content leaks out.

The Cloudflare Access login screen shown when hitting the admin URL without auth
Result of visiting /admin from a browser with no cookies. Not a single character of admin content shows up. The blurred line in the middle is the Zero Trust team domain.

4. Burned by Running in Dev Mode

At first I ran the admin panel in dev mode. It was convenient — edit the code and the screen refreshed itself.

It worked fine at home. Accessing it from outside on my phone, things got weird — the screen stayed stuck on an old version, and buttons threw unrelated errors.

The cause was that hot reload doesn't connect reliably across the tunnel. The connection that notifies the browser of code changes was broken, while the page itself stayed open.

Now I run the built output. No hot reload means nothing to get out of sync. The tradeoff is that editing code requires a rebuild — but the startup script checks if the source is newer and rebuilds automatically before launching.

5. GitHub Doesn't Deploy Anything

This is something I got wrong along the way. With a setup like this, it's easy to assume that pushing to GitHub triggers Cloudflare to pick it up and build. That's not how it works here.

Building the blog requires fetching the posts, and the posts live inside the admin on the MacBook. Cloudflare's build servers can't reach that — it's sitting behind auth. Making it reachable would mean opening a separate public channel to pull posts out, which undoes the exact thing I locked down.

So I split the responsibilities.

Role
GitHub Code storage & version control only
MacBook Reads the posts, builds, and uploads the output
Cloudflare Serves the uploaded static files

6. The Numbers So Far

Whenever I publish or edit a post, the MacBook rebuilds the blog and uploads it. It's run 181 times so far.

Value
Deploy runs 181
Failures 2
Duration 1–14s

The build is fast because there are only four posts so far; that number will grow as content piles up. But even if that number grows, it's not time I actually wait on — hitting publish finishes the save instantly, and the build runs in the background.


That covers what I decided while building this. Next up: the things I didn't decide and got wrong — a roundup of the actual missteps I hit while writing this series.