Hosting Forem on ARM Ubuntu 24.04
Forem is an open-source platform for building communities, best known for powering DEV.to. With the rise of ARM-based servers and single-board computers like Raspberry Pi, hosting Forem on ARM Ubuntu 24.04 is both cost-effective and energy-efficient. This article provides a step-by-step guide to deploying Forem on an ARM Ubuntu 24.04 server.
Prerequisites
- ARM-based server or SBC (e.g., Raspberry Pi 4, AWS Graviton, Oracle Ampere)
- Ubuntu 24.04 LTS (ARM64)
- At least 4GB RAM (8GB recommended)
- Domain name (optional, for production)
- Basic knowledge of Linux and Docker
1. Update System Packages
sudo apt update && sudo apt upgrade -y
2. Install Docker and Docker Compose
Forem uses Docker for deployment. Ubuntu 24.04 supports Docker on ARM out of the box.
sudo apt install -y docker.io docker-compose
sudo systemctl enable --now docker
sudo usermod -aG docker $USER
Log out and back in to apply the group change.
3. Clone the Forem Repository
git clone https://github.com/forem/forem.git
cd forem
4. Configure Environment Variables
Copy the example environment file and edit it:
cp .env.sample .env
nano .env
Set values for:
-
APP_DOMAIN(your domain or IP) -
SECRET_KEY_BASE(generate withopenssl rand -hex 64) -
POSTGRES_PASSWORD(choose a strong password) -
REDIS_URL(default is fine for local)
5. Build Docker Images for ARM
Forem's Docker images are multi-arch, but you may need to build them locally for ARM:
docker-compose build
If you encounter architecture issues, add the following to your Dockerfile(s):
FROM --platform=linux/arm64 ruby:3.2
6. Start Forem Services
docker-compose up -d
Check logs for errors:
docker-compose logs -f
7. Database Setup
Run database migrations and seed data:
docker-compose exec web rails db:setup
8. Access Forem
- Visit
http://<your-server-ip>:3000in your browser. - Register the first user (becomes admin).
9. (Optional) Set Up a Reverse Proxy with Nginx
For production, use Nginx to proxy traffic and enable SSL:
sudo apt install nginx
Sample Nginx config:
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Reload Nginx:
sudo systemctl reload nginx
10. Troubleshooting
- Docker build fails on ARM: Ensure all images use ARM64 base images.
- Out of memory: Increase swap or use a device with more RAM.
- Ports in use: Make sure nothing else is running on port 3000.
11. Production Considerations
- Use SSL (Let's Encrypt)
- Set up backups for PostgreSQL
- Monitor resource usage
- Regularly update Forem and dependencies
Conclusion
Hosting Forem on ARM Ubuntu 24.04 is straightforward with Docker. This setup is ideal for self-hosted communities, hobby projects, or low-cost production deployments. For more advanced scaling, consider managed databases and cloud load balancers.
References:
Top comments (0)