File size: 2,124 Bytes
52a0fe9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Alldocex - Deployment Guide

This guide provides three main options for deploying the Alldocex application to a production environment.

## 🏗️ Option 1: Docker (Recommended)

Docker is the best choice because it packages all the AI models, dependencies, and system libraries into a single container.

### 1. Build the image
```bash
docker build -t alldocex-app .
```

### 2. Run with Docker Compose
```bash
docker-compose up -d
```
The application will be available at `http://localhost:8000`.

---

## ☁️ Option 2: Cloud Deployment (Render / Railway / Fly.io)

### **Render Deployment (Recommended)**
1.  **Connect GitHub**: Push your code to a GitHub repository.
2.  **Create Web Service**: Select "Web Service" in Render.
3.  **Docker Environment**: Render will automatically detect the `Dockerfile`.
4.  **Resource Plan**: Ensure you select a plan with at least **4GB RAM** (e.g., Starter or Pro).
5.  **Environment Variables**: Add `PORT = 8000` if required.

---

## 🖥️ Option 3: Manual Deployment (Ubuntu/Debian Server)

If you are deploying directly to a Linux VPS (without Docker):

### 1. Install System Dependencies
```bash
sudo apt-get update
sudo apt-get install -y tesseract-ocr libgl1-mesa-glx libglib2.0-0 build-essential python3-venv
```

### 2. Set Up Environment
```bash
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python -m spacy download en_core_web_sm
```

### 3. Run with Gunicorn (Production Server)
```bash
pip install gunicorn
gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app --bind 0.0.0.0:8000
```

---

## ⚠️ Important Considerations

*   **RAM**: AI models (EasyOCR, Torch, spaCy) are memory-intensive. Do NOT deploy on a "Free Tier" instance with only 512MB or 1GB of RAM.
*   **Disk Space**: The first time you run the app, it will download several hundred megabytes of model weights.
*   **Permissions**: Ensure the `uploads/` directory has write permissions for the user running the application.
*   **Reverse Proxy**: For public deployment, it is highly recommended to use **Nginx** as a reverse proxy with SSL (Let's Encrypt).