Improving My Remote Code Server

After my primary laptop died, I had to really make coding on my iPad work. This resulted in a re-architecting of how my development server was set up, switching to Docker and a Raspberry Pi in the process.

Last time on Andreas Tinkers…

In my last article on coding with an iPad, I wrote about an (admittedly) complicated way to set up a VSCode server to use so that I could code from my iPad.

Since then, my main beast of a MacBook Pro (2019 16”, 64GB RAM, 1TB SSD) died due to bad memory sectors, and it was either “fix it for $700” or “get $690 in credit.” So, I decided to make the jump (and my wife lovingly supported me switching) to a 12.9” iPad Pro M1. It has been my main computer for about a month now, and it’s been great! Well, flawed, but great. That’s another article.

But anyway, because of my dead laptop, and because the nature of my work is writing code, I gained some serious incentive to improve my server setup. The ultimate trigger was when 3 power outages happened at my home in one week, which meant my old Windows laptop would shut down and not turn back on. A fact I would only realize when I was out of the house, leaving me dead in the water. The machine that showed itself to be more reliable? My Raspberry Pi 4.

The Idea

I had originally tried to build my dev server on the Raspberry Pi, but LocalWP and DevKinsta didn’t have arm64 versions of their software. And the LAMP stack was pretty limited… I was running into problems where I couldn’t change the default /www/ directory, install multiple separate instances (so I could have completely separate WordPress sites), or access certain directories over SSH. All problematic, all harder to deal with than my current setup, and figuring out how to fix it would take too long. So I stuck with my old Windows laptop.

But then I had an idea… could I run Docker on my Pi? Well, apparently, yes!

Okay, interesting. I had used Docker in the past but I had some issues when it came to volumes, networking, all that stuff. It was just too complicated, especially when LocalWP and DevKinsta exist. But, I knew WordPress had a Docker image, and I knew I just needed a dockerfile YAML config. If I could figure out how to set that up, maybe I could figure out a solution.

I had Googled this all before and couldn’t seem to get anywhere. After being frustrated that technology couldn’t work for me and I was instead its slave, a lightbulb went off… why not try to have technology work for me and use ChatGPT to build me a custom docker-compose file? It couldn’t be worse than what I currently had, which was nothing.

The Execution

And uh, it worked VERY well. ChatGPT not only made me a working file, but it told me how to use it. I only had to make a few changes, like switching from using mySQL to using MariaDB, but it was literally a drop in replacement. After some testing, I dropped the file onto my Pi and it worked flawlessly. I tinkered within ChatGPT a little more: “Make the database save to a volume.” “Add a volume for the wp-content folder.” It obliged. I Googled around a little bit and made it so the script would always start up if the machine shut down.

Within an hour or two, I had a file and directory structure I could use to quickly whip up WordPress instances! It’s much easier to use than LocalWP too, with one of the benefits being that I could set my own ports to something I could remember.

So, sweet! I cloned the template I made, set the ports to something I could remember, and set up WordPress. Importantly, I set up the site from the Pi’s Tailscale IP, not localhost. That way the site would create itself in a manner where I could access it wherever I was. I cloned down some of my GitHub projects and added some demo data. It worked! Restarting the device also successfully brought the sites back up without me having to intervene.

The one thing I haven’t added (but might in the future) is an admin interface for the database, but I’m not doing any content development (it’s just demo data from FakerPress), I’m not too concerned.

What hasn’t changed

For this server setup I’m still using Tailwind, Ubuntu, and Tmux. On my iPad I’m using VSCode’s web app and the amazing Secure ShellFish app, which integrates with Tmux. I’m also experimenting with using Secure ShellFish and Runestone to offer a native iPad editing experience, as part of an exploration in more native iPad experiences.

Why’s that? Well, as great as VSCode is, even on the M1 iPad it can still lose connection when switching between apps. I have also had some major issues with it and my Magic Keyboard, where CMD+Tabbing between apps would sometimes lose keyboard focus in VSCode. Fixing it would require either detaching and reattaching the keyboard, reloading the window, or selecting another file in the list, going back to the file I was in, and then selecting the code editor. It definitely made it hard to stay focused on what I was doing.

One last haggle with coding on the iPad: I use the Web Inspector app to access dev tools in Safari. When I reload the page, the fly-out window doesn’t stay open. Additionally, the fly-out window cannot be resized. Instead, it’s stuck at like 85% of the page’s height, which means I can’t see anything when it’s open. It’s not ideal.

Summary

I’m very happy with this new setup. It’s simpler, more reliable, and easier to use. All good things!

You can download my docker-compose template here:

And here’s a summary of my current iPad development stack:

The Server

The Client

As always, if you have any ideas for improvements, let me know in the comments!

Leave a Reply