Skip to content

Simple Rails app to test OCR and queue processing

Notifications You must be signed in to change notification settings

am1re/ocr_queue

Repository files navigation

Rails + RabbitMQ + Tesseract

This is repo contains simple Rails API which receives image url and pushes it to RabbitMQ queue to later process it with tesseract

How to run

With Docker simply execute:

$ docker compose up -d

If needed environmental variables stored in .env file

Without Docker:

There are 3 services that should be running:

  1. Rails API
  2. Rails Worker
  3. RabbitMQ

All is needed is successfull connection to RabbitMQ and tesseract command line installed.

The default connection url will be tried by app is:

amqp://guest:guest@localhost:5672

If that's not your option, you can change it there:

config/initializers/sneakers.rb:1

Once you have everything required, go ahead and fire up RabbitMQ and then Rails API and Worker:

$ bin/rails s # for API
$ bin/rake sneakers:run # for worker

Docker infrastructure

There are 2 containers:

  1. Rails application

    • Rails API
    • Rails Worker

    multiple services in the same container, supervised by s6-overlay:

  2. RabbitMQ service

Tests

$ rspec

Usage

Make request to:

    POST localhost:3000/api/v1/media

with body like:

{
    "fileUrl": "https://i.stack.imgur.com/WiDpa.jpg"
}

the result will be logged by worker:

2022-09-09T19:34:04Z p-880 t-94c INFO: [OcrProcessJob(d5ce53fb)] result => some text extracted from image

Credits

About

Simple Rails app to test OCR and queue processing

Resources

Stars

Watchers

Forks