
Introduction to my new project: Lightweight Homelab
The idea for this project came to me when I had to spend some time in an off-grid environment with power outages and unstable internet connection. After some time, I decided to implement a project that could provide me with a minimal set of services which I use for my daily work:
- Private docker registry
- Complete mirror of Ubuntu repository
- Local copy of Stack Overflow, Stack Exchange, etc.
- A service that will automatically download all these resources and keep them up to date
- Scripts that would download the most frequently used docker images and save them to my private offline registry
- A DNS resolver for all these services
Another functional requirement was to have the ability to run all of these on at least two architectures: arm64 (routers and SBCs) and amd64.
The implementation of all these features was easy to do because I had already configured most of them in the past as parts of more complex systems. As a result, I created a set of scripts that will make it easy to bootstrap this seed ecosystem and pushed them all to GitHub.
Cloning the repository and building images
git clone https://github.com/Denrox/lightweight-homelab.git;
cd lightweight-homelab;
./build.sh;
That’s it - you now have images built for amd64 and arm64. After this, I suggest copying the whole “lightweight-homelab” to a USB drive. The USB drive should be at least 1TB, because a full Ubuntu mirror takes more than 500GB.
Bootstrapping this setup on target machine
First, we need to connect the external drive to the target machine and figure out its label.
fdisk -l;
Then we create a mount point and mount the drive.
mkdir /infra;
mount -t ext4 /dev/sdX1 /infra;
For permanent mounting, we need to add this to the /etc/fstab
file.
/dev/sdX1 /infra ext4 defaults 0 2
Then we can start up the system.
cd /infra/lightweight-homelab;
./startup.sh --ip 192.168.0.1 --dns --dnsport 53 --os --reg;
The ”./startup.sh” command defines the architecture of your machine, picks proper images, and starts containers. Flag “—os” tells the script to download the latest stable Ubuntu and Debian images. Flag “—reg” tells the script to clone docker images specified in the “scripts/images.txt” file and save them to the private registry. Flag “—dns” tells the script to start the DNS resolver, and “—ip” sets the IP address of your machine for the resolver.
Downloading Kiwix ZIM files and apt-mirror packages takes time. It is performed in the background by the “downloader” container. This container also runs the download task in cron to keep ZIM files and deb packages up to date.
What’s next?
I am planning to add at least two more features:
- A home page that will show links to all services and present downloader logs
- A simple UI for browsing the private docker registry