AI made self-hosting fun again

本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。

AI made self-hosting fun again

I’ve been self-hosting things for many years. There were times when I was quite enthusiastic about it, constantly trying out new software and tinkering with my infrastructure. But at some point, that enthusiasm faded a bit.

我进行自托管服务已经很多年了。曾经有一段时间我对此充满热情,不断尝试新软件并折腾我的基础设施。但到了某个阶段,那种热情稍微减退了一些。

I never really stopped self-hosting, but I became less inclined to experiment with new things. Maintaining what I already had running was enough for me.

我从未真正停止过自托管,但我变得不太愿意尝试新事物了。维护现有的运行环境对我来说已经足够。

Over the last few months, however, I’ve found myself getting increasingly excited about self-hosting again. And, somewhat ironically, AI is a big reason for that.

然而,在过去的几个月里,我发现自己对自托管又重新燃起了浓厚的兴趣。讽刺的是,人工智能是其中的一个重要原因。

Most of my infrastructure configuration lives in Git repositories, mainly in the form of Docker Compose files, scripts, and other configuration files. This makes it possible to use AI coding agents to work on my infrastructure in much the same way as they would work on any other software project.

我的大部分基础设施配置都存放在 Git 仓库中,主要以 Docker Compose 文件、脚本和其他配置文件的形式存在。这使得我可以使用 AI 编程代理来处理我的基础设施,就像处理其他软件项目一样。

Whenever I want to try a new service, adjust an existing configuration, or automate something, I can now do so with considerably less effort.

每当我想尝试新服务、调整现有配置或实现自动化时,现在都能以少得多的精力完成。

In the past, I would sometimes put off certain changes simply because I didn’t feel like spending an evening reading changelogs and documentation or troubleshooting issues. It’s not that I couldn’t have done these things before. But often, the amount of effort required just wasn’t worth it to me.

过去,我有时会推迟某些更改,仅仅是因为不想花一晚上时间去阅读更新日志、文档或排查问题。并不是我以前做不到这些,但通常情况下,所需的精力投入对我来说并不划算。

Now, even relatively spontaneous ideas often end up becoming reality.

现在,即使是相对随性的想法,也经常能变成现实。

There are also technologies that I’ve always found interesting but never felt knowledgeable enough about to really make use of them.

还有一些技术我一直觉得很有趣,但总觉得自己知识储备不足,无法真正利用它们。

NixOS is a good example. I’ve always liked the idea of declaratively configuring an entire system; I even used it on my laptop during my Linux honeymoon phase. But getting everything configured the way I wanted was quite a hurdle. With the help of AI, I’m now making much more extensive use of NixOS on my home server.

NixOS 就是一个很好的例子。我一直很喜欢声明式配置整个系统的理念;在我的 Linux 蜜月期,我甚至在笔记本电脑上使用过它。但要按照我想要的方式配置好一切是一个相当大的障碍。在 AI 的帮助下,我现在正在我的家庭服务器上更广泛地使用 NixOS。

For my VPS infrastructure, I’ve also started building my own Debian-based bootc image (after thinking about it for some time).

对于我的 VPS 基础设施,我也开始构建自己的基于 Debian 的 bootc 镜像(在考虑了一段时间之后)。

Having my entire operating system configuration defined in a Git repository and automatically building a bootable container image from it is something I find really cool. But it’s also something I probably wouldn’t have invested enough time in to get working on my own before. Even with the help of AI, it still took me half a day when I set it up a few months ago. Without AI, it would probably have taken me at least a week.

将整个操作系统配置定义在 Git 仓库中,并从中自动构建可启动的容器镜像,我觉得这非常酷。但这也是我以前可能不会投入足够时间去实现的事情。即使在 AI 的帮助下,几个月前我设置它时仍然花了大半天时间。如果没有 AI,我可能至少需要一周。

AI makes experimenting with unfamiliar technologies much more approachable. I don’t necessarily need to understand every little detail before I can get started. I can learn about things along the way, ask questions, and gradually improve my configurations.

AI 让尝试不熟悉的技术变得更加容易。我不必在开始之前就理解每一个细节。我可以在过程中学习、提问,并逐步改进我的配置。

Something I’ve also finally managed to do is automate most of the build, update, and deployment processes for my infrastructure.

我终于做到的另一件事是实现了基础设施大部分构建、更新和部署流程的自动化。

A lot of the work involved in self-hosting isn’t particularly exciting. Keeping track of new releases, updating container image tags, building images, and deploying configuration changes are all things that need to be done regularly.

自托管涉及的许多工作并不是特别令人兴奋。跟踪新版本、更新容器镜像标签、构建镜像以及部署配置更改,这些都是需要定期完成的事情。

I still remember what updating a service used to look like: bumping the version and adjusting the Docker Compose file on my laptop, pushing the changes to the Git remote, SSHing into the server, pulling the changes, and finally deploying them. Now, a single Git push is enough. If a push is even necessary.

我还记得过去更新服务是什么样子:在笔记本电脑上提升版本并调整 Docker Compose 文件,将更改推送到远程 Git,通过 SSH 连接到服务器,拉取更改,最后进行部署。现在,一次 Git push 就足够了。如果甚至还需要 push 的话。

With Renovate, I no longer need to actively keep track of most software updates. It creates pull requests for me, and often, all I need to do is review and merge them. I can even do that on my phone while sitting on the sofa.

有了 Renovate,我不再需要主动跟踪大多数软件更新。它会为我创建合并请求(pull requests),通常我只需要审查并合并它们即可。我甚至可以在坐在沙发上时用手机完成这些操作。

Pushing changes or merging a pull request triggers the corresponding GitHub Actions or Forgejo Actions workflows, which take care of building and deploying everything.

推送更改或合并合并请求会触发相应的 GitHub Actions 或 Forgejo Actions 工作流,由它们负责构建和部署一切。

Of course, there’s nothing particularly groundbreaking about any of this. DevOps has been around for a long time, and none of these automation tools require AI. But AI has helped me put all these pieces together in a way that I previously never quite got around to doing.

当然,这些并没有什么特别开创性的地方。DevOps 已经存在很长时间了,这些自动化工具都不需要 AI。但 AI 帮助我以一种我以前从未真正实现过的方式将所有这些部分整合在了一起。

And the nice thing about automating these tasks is that the benefits extend well beyond the initial setup. I now have less tedious work to do every time I want to change something or update a service.

自动化这些任务的好处在于,其收益远不止于初始设置。现在,每当我想要更改某些内容或更新服务时,需要做的繁琐工作都变少了。

As I’ve started hosting more things again, I’ve also moved more of my services from my VPS to my home server.

随着我开始再次托管更多内容,我也将更多的服务从 VPS 迁移到了家庭服务器上。

For a while, I was using an HP t640 thin client as my home server. However, with more things I wanted to run, I decided to switch back to my ASRock DeskMini A300, which had been sitting unused for some time. I’m thinking about repurposing the t640 as a “router on a stick”, though.

有一段时间,我一直使用 HP t640 精简客户端作为家庭服务器。然而,随着我想运行的东西越来越多,我决定换回闲置已久的 ASRock DeskMini A300。不过,我正在考虑将 t640 改造成“单臂路由”。

I even took the opportunity to upgrade its CPU from an AMD Ryzen 5 2400G to a Ryzen 5 PRO 4650G and replaced the stock AMD cooler with a quieter Noctua cooler. Noise was the main reason I switched to the t640 in the first place.

我甚至借此机会将其 CPU 从 AMD Ryzen 5 2400G 升级到了 Ryzen 5 PRO 4650G,并将原装 AMD 散热器更换为更安静的猫头鹰(Noctua)散热器。当初我换用 t640 的主要原因就是噪音问题。

It’s nice to put some hardware I already owned back to use rather than buying an entirely new machine. I also managed to get both the CPU and the cooler for a good price through a classifieds site.

能重新利用我已有的硬件,而不是购买一台全新的机器,感觉真好。我还通过分类广告网站以不错的价格买到了 CPU 和散热器。

Having some additional computing power available gives me more room to experiment. And there’s something quite satisfying about having a small box at home running a growing collection of services that I use in my everyday life.

拥有额外的计算能力为我提供了更多的实验空间。家里有一个小盒子运行着我日常生活中使用的一系列不断增长的服务,这让人感到非常满足。

But it’s not just about self-hosting existing software. AI has also changed how I approach problems for which there isn’t an existing piece of software that does exactly what I want.

但这不仅仅是关于自托管现有的软件。AI 也改变了我处理问题的方式,特别是当没有现成的软件能完全满足我的需求时。

Previously, I would often spend quite some time searching for a suitable open-source project, comparing different alternatives, and figuring out how to make one of them work for my particular use case.

以前,我经常会花很多时间寻找合适的开源项目,比较不同的替代方案,并研究如何让其中一个方案适用于我的特定用例。

These days, for smaller problems, building my own solution has become a much more attractive option.

如今,对于较小的问题,构建自己的解决方案已成为一个更具吸引力的选择。

I’ve recently built tools to automatically download invoices, e-papers or Linux ISOs.

我最近构建了一些工具,用于自动下载发票、电子报纸或 Linux ISO 镜像。

I can build (or have AI build) these tools in Go, my preferred programming language, and tailor them to my exact needs.

我可以用我首选的编程语言 Go 构建(或让 AI 构建)这些工具,并根据我的确切需求进行定制。

They don’t need to support every possible use case, have an elaborate user interface.

它们不需要支持所有可能的用例,也不需要拥有复杂的图形用户界面。