Skip to content

Ruby + Sidekiq Workers

Ruby/Sinatra API with Sidekiq for background job processing, demonstrating two services from one Docker image.

Overview

Tech Stack Ruby 3.3 / Sinatra + Sidekiq
Services 2 (api + worker)
Database PostgreSQL
Cache The managed Redis cache
Pattern Background workers

The appmecca.yaml

containers:
  - name: app
    dockerfile: Dockerfile
    context: .

deploy:
  - name: api
    container: app
    port: 4567
    health_check:
      path: /health

  - name: worker
    container: app
    command: "bundle exec sidekiq -r ./worker.rb"

database:
  enabled: true

redis:
  enabled: true

Key Concepts

Sidekiq Workers

Sidekiq is Ruby's most popular background job processor. It uses Redis as a message broker and processes jobs concurrently using threads. The worker service runs sidekiq -r ./worker.rb to load and execute worker classes.

Portless Worker Service

The worker has no port field, making it a portless service. AppMecca gives it no public hostname and no routing rule — nothing outside the platform can reach it. The worker only talks to PostgreSQL and Redis.

A portless service also needs no health_check block: omit it and AppMecca skips health checking for that service entirely.

Step-by-Step Deployment

1. Register the app

mecca register git@gitlab.com:appmecca-sample-apps/ruby-sidekiq-workers.git \
  -e dev

2. Build

mecca build trigger \
  -e dev \
  -g git@gitlab.com:appmecca-sample-apps/ruby-sidekiq-workers.git

3. Deploy

mecca app deploy -e dev ruby-sidekiq-workers

4. Verify

mecca app show -e dev ruby-sidekiq-workers
curl https://ruby-sidekiq-workers-api.dev.yourdomain.io/health

The worker has no URL — check it is alive with its logs instead:

mecca logs ruby-sidekiq-workers --service worker -e dev

What's Next