Raspberry Pi Setup¶
Deploy TruSpace on a Raspberry Pi for always-on, low-power edge deployments.
Supported Hardware¶
| Model | RAM | Support | Notes |
|---|---|---|---|
| Pi 5 | 4GB+ | Recommended | |
| Pi 4 | 4GB+ | Good performance | |
| Pi 4 | 2GB | No AI features | |
| Pi 3 | Any | Insufficient resources |
AI Features on Raspberry Pi
AI features require significant resources. On Pi 4 (4GB), use lightweight models like tinyllama or disable AI entirely with --no-ai.
Prerequisites¶
- Raspberry Pi ⅘ with 4GB+ RAM
- 32GB+ microSD card (64GB recommended)
- Raspberry Pi OS (64-bit) or Ubuntu 22.04 ARM64
- Ethernet or WiFi connection
Step 1: Prepare the Pi¶
Update System¶
Install Docker¶
# Install Docker
curl -fsSL https://get.docker.com | sh
# Add user to docker group
sudo usermod -aG docker $USER
# Log out and back in, then verify
docker --version
Install Docker Compose¶
Step 2: Clone and Configure¶
# Clone TruSpace
git clone https://github.com/openkfw/TruSpace.git
cd TruSpace
# Create environment file
cp .env.example .env
Configure for Local Network¶
Edit .env to use your Pi's hostname:
# Replace localhost with your Pi's hostname or IP
CORS_ORIGIN=http://raspberrypi.local:3000
OI_CORS_ALLOW_ORIGIN=http://raspberrypi.local:3000
Or use the helper script:
Step 3: Start TruSpace¶
First Start Takes Time
The first start will pull Docker images, which can take 10-30 minutes depending on your network speed.
Step 4: Access TruSpace¶
From another device on your network:
- URL:
http://raspberrypi.local:3000orhttp://<pi-ip>:3000
Performance Optimization¶
Enable Swap¶
For better stability with limited RAM:
# Check current swap
free -h
# Increase swap to 2GB
sudo dphys-swapfile swapoff
sudo nano /etc/dphys-swapfile
# Set CONF_SWAPSIZE=2048
sudo dphys-swapfile setup
sudo dphys-swapfile swapon
Use External SSD¶
For better IPFS performance, use an external SSD:
# Mount SSD (example)
sudo mkdir /mnt/ssd
sudo mount /dev/sda1 /mnt/ssd
# Move Docker data directory
sudo systemctl stop docker
sudo mv /var/lib/docker /mnt/ssd/docker
sudo ln -s /mnt/ssd/docker /var/lib/docker
sudo systemctl start docker
Resource Limits¶
Create docker-compose.override.yml:
version: '3.8'
services:
backend:
deploy:
resources:
limits:
memory: 256M
ipfs0:
deploy:
resources:
limits:
memory: 512M
environment:
- IPFS_PROFILE=lowpower
frontend:
deploy:
resources:
limits:
memory: 256M
Auto-Start on Boot¶
Using Systemd¶
Create a systemd service:
[Unit]
Description=TruSpace
Requires=docker.service
After=docker.service
[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=/home/pi/TruSpace
ExecStart=/usr/bin/docker compose up -d
ExecStop=/usr/bin/docker compose down
User=pi
[Install]
WantedBy=multi-user.target
Enable the service:
Monitoring¶
Check Resource Usage¶
Check Temperatures¶
Thermal Throttling
If temperatures exceed 80°C, consider adding a heatsink or fan. Throttling will impact performance.
Troubleshooting¶
Out of Memory¶
SD Card Issues¶
Network Discovery¶
If raspberrypi.local doesn't work:
Connecting Multiple Pis¶
Perfect use case for TruSpace! Connect multiple Raspberry Pis:
# On Pi 1: Generate connection details
./scripts/fetch-connection.sh -e
# Transfer .connection file to Pi 2
# On Pi 2: Connect
./scripts/connectPeer-automatic.sh .connection .connection.password