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.
-
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;" -
Navigate to project root:
cd /path/to/OCR -
Verify Environment: Ensure
.env.prodexists and points toDB_HOST=postgres-db. Also configure your Email credentials in.env.prodif you want the Mailbox feature to work (Gmail requires an App Password).cat .env.prod -
Start App Containers: This will start
ocr_backendandocr_frontend.# Build and start in detached mode docker-compose --env-file .env.prod up -d --build -
Verify Status:
docker-compose psYou should see
ocr_backendandocr_frontendrunning.
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.
-
Create Config File: Copy the provided config to
/etc/nginx/sites-available/ocr.sudo cp deployment/nginx.conf /etc/nginx/sites-available/ocr -
Enable Site:
sudo ln -s /etc/nginx/sites-available/ocr /etc/nginx/sites-enabled/ -
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