GitSpot - Code Better!

Sidekiq is not running and is needed for the app to function properly. Use bin/startup-local to start the application properly.
Admin McAdmin
Admin McAdmin

Posted on

Forem on Oracle Cloud with ARM Ubuntu 24.04

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

4. Configure Environment Variables

Copy the example environment file and edit it:

cp .env.sample .env
nano .env
Enter fullscreen mode Exit fullscreen mode

Set values for:

  • APP_DOMAIN (your domain or IP)
  • SECRET_KEY_BASE (generate with openssl 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
Enter fullscreen mode Exit fullscreen mode

If you encounter architecture issues, add the following to your Dockerfile(s):

FROM --platform=linux/arm64 ruby:3.2
Enter fullscreen mode Exit fullscreen mode

6. Start Forem Services

docker-compose up -d
Enter fullscreen mode Exit fullscreen mode

Check logs for errors:

docker-compose logs -f
Enter fullscreen mode Exit fullscreen mode

7. Database Setup

Run database migrations and seed data:

docker-compose exec web rails db:setup
Enter fullscreen mode Exit fullscreen mode

8. Access Forem

  • Visit http://<your-server-ip>:3000 in 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
Enter fullscreen mode Exit fullscreen mode

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;
    }
}
Enter fullscreen mode Exit fullscreen mode

Reload Nginx:

sudo systemctl reload nginx
Enter fullscreen mode Exit fullscreen mode

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)