Self-Hosting Guide

Deploy sarvaFeed on your own server for complete data ownership and privacy. This guide covers everything from initial setup to production-ready deployment.


Requirements

Before deploying sarvaFeed, ensure your server meets the following minimum requirements. These specifications are suitable for small to medium workloads. Larger deployments may need additional resources depending on usage patterns.

  • Linux server (Ubuntu 22.04+, Debian 12+, or equivalent)
  • Docker 20.10+ and Docker Compose v2.0+
  • 2 GB RAM minimum (4 GB recommended)
  • 10 GB free disk space
  • A domain name with DNS pointed to your server

sarvaFeed also supports deployment on cloud platforms such as AWS, Google Cloud, DigitalOcean, and Hetzner. Any environment that runs Docker will work.

Docker Setup

The recommended way to run sarvaFeed is with Docker. Pull the latest image and start a container with the following command:

docker pull sarvaos/sarvafeed

This pulls the latest stable release from the container registry. You can pin a specific version by appending a tag, for example docker pull sarvaos/sarvafeed:1.0.0. We recommend pinning versions in production to avoid unexpected changes during updates.

After pulling the image, run a quick test to verify the container starts correctly. Check the logs for any configuration warnings before proceeding to the Docker Compose setup below.

Docker Compose

For production deployments, we provide a docker-compose.yml file that bundles sarvaFeed with a PostgreSQL database and handles networking, volumes, and restart policies.

# Clone the repository
git clone https://github.com/sarvaos/sarvafeed.git
cd sarvafeed

# Copy the example environment file
cp .env.example .env

# Start all services
docker compose up -d

The Compose file creates two services: the sarvaFeed application and a PostgreSQL 15 database. Data is persisted in Docker volumes so it survives container restarts and upgrades.

To update to a newer version, pull the latest image and restart the services. Database migrations are applied automatically on startup.

Environment Variables

sarvaFeed is configured entirely through environment variables. The .env.example file in the repository documents every available option. Below are the most important variables you should set for a production deployment.

VariableDescriptionDefault
DATABASE_URLPostgreSQL connection string
SECRET_KEYSecret key for session encryption
BASE_URLPublic URL of your instancehttp://localhost:3000
PORTHTTP port the application listens on3000
LOG_LEVELLogging verbosity (debug, info, warn, error)info

Reverse Proxy

In production, you should run sarvaFeed behind a reverse proxy such as Nginx, Caddy, or Traefik. The reverse proxy handles TLS termination, HTTP/2, and can serve as a load balancer if you run multiple instances.

If you use Caddy, configuration is minimal. Caddy automatically obtains and renews TLS certificates from Let's Encrypt. Point your domain to the sarvaFeed container port and Caddy handles the rest.

For Nginx, ensure you set the proxy_pass directive to the application port and include headers for X-Forwarded-For, X-Forwarded-Proto, and Host so the application can correctly determine the client IP and protocol.

Backups

Regular backups are critical for any self-hosted deployment. The primary data to back up is the PostgreSQL database. Use pg_dump to create a consistent snapshot of your data that can be restored on any PostgreSQL instance.

# Create a compressed backup
docker compose exec db pg_dump -U postgres sarvafeed | gzip > backup-$(date +%Y%m%d).sql.gz

We recommend scheduling daily backups with a cron job and retaining at least 7 days of history. Store backups on a separate volume or offsite storage (S3, Backblaze B2, etc.) to protect against hardware failure.

In addition to database backups, back up your .env file and any uploaded assets stored on disk. The Docker volumes containing these files should be included in your backup strategy.