Files
OCR/DEPLOYMENT.md

2.6 KiB

OCR Application Deployment Guide

This guide describes how to deploy the OCR application on a Linux host (e.g., Ubuntu/Debian).

Architecture

  • Backend: Containerized (FastAPI, Python 3.9).
  • Database: Containerized (PostgreSQL 15).
  • Frontend: Static files (Angular) served by Host Nginx.
  • Reverse Proxy: Host Nginx proxies requests to Frontend (Static) and Backend (API).

Prerequisites

  • Docker & Docker Compose installed on the host.
  • Nginx installed on the host.
  • Node.js & NPM (for building Angular).

1. Full Stack Deployment (Docker)

The app connects to your existing Postgres container (postgres-db) in the arbit-app_arbit-network.

  1. Create the Database: Since we are using an existing postgres instance, we must manually create the ocr_db.

    # Run this on your host to create the DB inside the existing container
    docker exec -it postgres-db psql -U postgres -c "CREATE DATABASE ocr_db;"
    
  2. Navigate to project root:

    cd /path/to/OCR
    
  3. Verify Environment: Ensure .env.prod exists and points to DB_HOST=postgres-db. Also configure your Email credentials in .env.prod if you want the Mailbox feature to work (Gmail requires an App Password).

    cat .env.prod
    
  4. Start App Containers: This will start ocr_backend and ocr_frontend.

    # Build and start in detached mode
    docker-compose --env-file .env.prod up -d --build
    
  5. Verify Status:

    docker-compose ps
    

    You should see ocr_backend and ocr_frontend running.


2. Nginx Configuration (Host Reverse Proxy)

Since the Frontend is now running in a container on port 8080 (serving /ocrf/), we configure the Host Nginx to proxy traffic to it.

  1. Create Config File: Copy the provided config to /etc/nginx/sites-available/ocr.

    sudo cp deployment/nginx.conf /etc/nginx/sites-available/ocr
    
  2. Enable Site:

    sudo ln -s /etc/nginx/sites-available/ocr /etc/nginx/sites-enabled/
    
  3. Test & Reload:

    sudo nginx -t
    sudo systemctl reload nginx
    

3. Verification

  • Url: http://app.technobeesolutions.in/ocrf/ (Proxies to Frontend Container)
  • API: http://app.technobeesolutions.in/ocrb/ (Proxies to Backend Container)

4. Troubleshooting

  • Logs:
    docker-compose logs -f backend
    
  • Database: Connect via the existing container:
    docker exec -it postgres-db psql -U postgres -d ocr_db