This guide explains how to create and use a Hetzner Cloud server for building KeyDB AMD64 Debian packages.
-
Install hcloud CLI:
# macOS brew install hcloud # Linux # Download from https://github.com/hetznercloud/cli/releases
-
Create Hetzner Cloud Account:
- Sign up at https://console.hetzner.cloud
- Create an API token in your project settings
-
Configure hcloud CLI:
hcloud context create keydb # Paste your API token when prompted -
Upload SSH Key (optional but recommended):
# Upload your public SSH key hcloud ssh-key create --name default --public-key-from-file ~/.ssh/id_rsa.pub
The build server uses these specifications (optimized for C++ compilation):
- Type: CCX13 (Dedicated vCPU)
- CPU: 4 dedicated vCores (AMD EPYC)
- RAM: 16 GB
- Storage: 80 GB NVMe SSD
- OS: Debian 12 (Bookworm)
- Location: Nuremberg (nbg1)
- Cost: ~€0.04/hour (~€30/month if left running)
Dedicated vCPU servers (CCX line) provide guaranteed CPU resources without "noisy neighbor" effects, ensuring consistent build times. This is crucial for CPU-intensive compilation tasks.
./hcloud-create-build-server.shThis script will:
- Create a Hetzner Cloud server named
keydb-build-amd64 - Install Docker, git, build tools, and security software
- Configure firewall (ufw) and fail2ban
- Optimize system for builds
- Display the server IP address
Wait 1-2 minutes after creation for cloud-init to complete the setup.
./hcloud-build-remote.shThis script will:
- Connect to your Hetzner Cloud server
- Clone the KeyDB repository
- Copy any local changes (version.h, build scripts, etc.)
- Run the Docker build process
- Copy the built .deb packages back to
built-packages/ - Clean up the build directory on the server
Build time: ~15-20 minutes for a full build
./hcloud-delete-build-server.shImportant: Remember to delete the server when you're done to avoid ongoing charges!
If you prefer to build manually:
# SSH to the server
ssh root@<SERVER_IP>
# Clone the repository
cd /root/builds
git clone --recursive https://github.com/ozanturksever/KeyDB.git
cd KeyDB
# Run the build
./pkg/deb/build-docker-24.04.sh
# Download packages from your local machine
scp root@<SERVER_IP>:/root/builds/KeyDB/pkg/deb/deb_files_generated/*.deb ./built-packages/Hetzner Cloud bills by the hour. To minimize costs:
-
Create server only when needed:
./hcloud-create-build-server.sh
-
Build packages:
./hcloud-build-remote.sh
-
Delete server immediately after:
./hcloud-delete-build-server.sh
Cost per build: ~€0.01-0.02 (15-20 minutes)
If you build frequently, keep the server running:
- Cost: ~€30/month
- Benefit: Instant builds, no setup wait
Edit hcloud-create-build-server.sh to customize:
- Server name: Change
SERVER_NAME - Server type: Change
SERVER_TYPE(e.g.,ccx23for 8 cores/32GB) - Location: Change
LOCATION(e.g.,fsn1,hel1,ash) - SSH key: Change
SSH_KEY_NAMEto match your uploaded key
The server is automatically configured with:
- UFW Firewall: Only SSH (port 22) is allowed
- Fail2ban: Automatic IP blocking after failed SSH attempts
- SSH Key Authentication: Password login should be disabled
# Check hcloud context
hcloud context list
# Check quota
hcloud server list# SSH to server and check logs
ssh root@<SERVER_IP>
cd /root/keydb-build
./pkg/deb/build-docker-24.04.sh# Get server status
hcloud server describe keydb-build-amd64
# Check if cloud-init is complete (wait 1-2 minutes after creation)
ssh root@<SERVER_IP> "cloud-init status"| Method | Build Time | Setup Time | Cost | Pros | Cons |
|---|---|---|---|---|---|
| Hetzner Cloud | 15-20 min | 2 min | €0.01/build | Fast, clean, reproducible | Requires hcloud setup |
| Local ARM64 + QEMU | 2-4 hours | 0 min | Free | No setup | Extremely slow |
| GitHub Actions | 15-20 min | 5 min | Free | Automated | Requires workflow setup |
| Existing Remote Server | 15-20 min | 0 min | Fixed | Always available | Requires maintenance |
- Always delete servers after use to avoid charges
- Use the automated scripts rather than manual setup
- Keep local changes minimal - commit to git when possible
- Verify packages locally after downloading
- Monitor build logs for any warnings or errors
- Set up GitHub Actions for automated builds
- Create a package repository for hosting .deb files
- Add ARM64 build server support