Docs

Backend Setup

Deploy the Grovs backend with Docker Compose — includes the API server, database, Redis, and background workers.

The Grovs backend is a Ruby on Rails application that handles API requests, link redirects, SDK communication, and background processing. This guide walks you through deploying it with Docker Compose.

Prerequisites

1

Clone the repository

Bash
git clone https://github.com/grovs-io/backend.git
cd backend
2

Create the environment file

Copy the example environment file:

Bash
cp .env.example .env
3

Generate encryption keys

Rails requires encryption keys for securing sensitive data. Generate them with:

Bash
docker compose run --rm web bin/rails db:encryption:init

This outputs three keys. Add them to your .env file:

Bash
ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY=generated_key_here
ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY=generated_key_here
ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT=generated_key_here
4

Configure your domain

Set the host variables in your .env file to match your domain:

Bash
# Backend
SERVER_HOST_PROTOCOL=https://
SERVER_HOST=yourdomain.com
 
# Dashboard (where the frontend will be hosted)
REACT_HOST_PROTOCOL=https://
REACT_HOST=app.yourdomain.com

The backend uses subdomain routing. Make sure you configure DNS records for api., sdk., go., and preview. subdomains — all pointing to the same server running the backend.

5

Start the services

Build and start all containers:

Bash
docker compose up --build

This starts:

  • PostgreSQL 16 — database
  • Redis 6 — cache and job queues
  • Rails web server — on port 8765
  • 5 Sidekiq workers — background job processing
6

Set up the database

In a new terminal, create and seed the database:

Bash
docker compose exec web bundle exec rails db:create db:migrate db:seed

The seed process creates:

  • A default OAuth application (used by the dashboard to authenticate)
  • A default domain and project configuration
7

Retrieve the OAuth credentials

The dashboard needs OAuth credentials to connect to the backend. Open a Rails console to retrieve them:

Bash
docker compose exec web bundle exec rails console

Then run:

Ruby
app = Doorkeeper::Application.first
puts "Client ID: #{app.uid}"
puts "Client Secret: #{app.secret}"

Save these values — you'll need them when setting up the dashboard.

Verify the deployment

Once the services are running, check that the backend is healthy:

Bash
curl http://localhost:8765/up

You should receive a 200 OK response.

Environment variables reference

Required

VariableDescriptionExample
ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEYPrimary encryption keyGenerated in step 3
ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEYDeterministic encryption keyGenerated in step 3
ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALTKey derivation saltGenerated in step 3
SERVER_HOST_PROTOCOLBackend protocolhttps://
SERVER_HOSTBackend domainyourdomain.com
REACT_HOST_PROTOCOLDashboard protocolhttps://
REACT_HOSTDashboard domainapp.yourdomain.com
REDIS_URLRedis connection URLredis://redis:6379/0

Optional integrations

VariableDescription
AWS_S3_KEY_ID, AWS_S3_ACCESS_KEY, AWS_S3_REGION, AWS_S3_BUCKETFile storage via AWS S3
SENDGRID_API_KEYTransactional emails via SendGrid
STRIPE_API_KEY, STRIPE_STANDARD_PRICE_ID, STRIPE_WEBHOOK_SECRETBilling via Stripe
GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRETGoogle SSO login
MICROSOFT_CLIENT_ID, MICROSOFT_CLIENT_SECRETMicrosoft SSO login
OTEL_EXPORTER, OTEL_SERVICE_NAME, OTEL_EXPORTER_OTLP_ENDPOINTOpenTelemetry observability

Background workers

The backend runs five specialized Sidekiq processes:

WorkerConcurrencyPurpose
scheduler1Scheduled/cron jobs
worker20SDK event ingestion
batch3Batch event processing
device_updates3Device metadata updates
maintenance5Backfills and housekeeping

All workers are started automatically by Docker Compose.

DNS configuration

Point the following subdomains to the server running the backend:

SubdomainPurpose
api.yourdomain.comDashboard API
sdk.yourdomain.comMobile SDK endpoints
go.yourdomain.comShort link redirects
preview.yourdomain.comLink preview pages

If you use a reverse proxy (nginx, Caddy, Traefik), make sure it forwards all four subdomains to port 8765 on the backend container.

Production deployment with Kamal

For production deployments, Grovs supports Kamal — a zero-downtime deployment tool from the Rails team:

Bash
cp config/deploy.yml.example config/deploy.yml
# Edit config/deploy.yml with your server details
bundle exec kamal setup
bundle exec kamal deploy

Next step

Set up the dashboard →