fokan commited on
Commit
14a7592
·
verified ·
1 Parent(s): 927edae

Upload 39 files

Browse files
Files changed (5) hide show
  1. Dockerfile +10 -15
  2. README.md +9 -9
  3. docker-compose.yml +3 -3
  4. main.py +1 -1
  5. verify_files.py +64 -0
Dockerfile CHANGED
@@ -47,33 +47,28 @@ RUN fc-cache -fv
47
  # Set working directory
48
  WORKDIR /app
49
 
50
- # Copy requirements and install Python dependencies
51
- COPY requirements.txt .
52
- RUN pip3 install --no-cache-dir -r requirements.txt
53
-
54
  # Create necessary directories
55
  RUN mkdir -p /tmp/libreoffice_conversion
56
 
57
  # Create static directory
58
  RUN mkdir -p static
59
 
60
- # Copy application files
61
- COPY app.py .
62
- COPY main.py .
63
- COPY arabic_fonts_setup.sh .
64
- COPY libreoffice_arabic_config.xml .
65
- COPY arial.ttf .
66
- COPY packages.txt .
67
 
68
- # Copy static files
69
- COPY static/index.html ./static/
70
 
71
  # Setup additional Arabic fonts
72
  RUN chmod +x arabic_fonts_setup.sh && \
73
  ./arabic_fonts_setup.sh
74
 
75
- # Expose port
76
- EXPOSE 8000
 
 
 
 
77
 
78
  # Run the application
79
  CMD ["python3", "main.py"]
 
47
  # Set working directory
48
  WORKDIR /app
49
 
 
 
 
 
50
  # Create necessary directories
51
  RUN mkdir -p /tmp/libreoffice_conversion
52
 
53
  # Create static directory
54
  RUN mkdir -p static
55
 
56
+ # Copy all files in a single command to avoid layering issues
57
+ COPY . .
 
 
 
 
 
58
 
59
+ # Install Python dependencies
60
+ RUN pip3 install --no-cache-dir -r requirements.txt
61
 
62
  # Setup additional Arabic fonts
63
  RUN chmod +x arabic_fonts_setup.sh && \
64
  ./arabic_fonts_setup.sh
65
 
66
+ # Expose port (Hugging Face Spaces requires port 7860)
67
+ EXPOSE 7860
68
+
69
+ # Health check (Hugging Face Spaces requires port 7860)
70
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
71
+ CMD curl -f http://localhost:7860/health || exit 1
72
 
73
  # Run the application
74
  CMD ["python3", "main.py"]
README.md CHANGED
@@ -35,7 +35,7 @@ pinned: false
35
  ## ✨ الميزات المحسنة للعربية
36
 
37
  - **🔤 تميز الخطوط**: توافق كامل مع الخطوط العربية (Traditional Arabic→Amiri، Arabic Typesetting→Noto Naskh، Simplified Arabic→Noto Naskh)
38
- - **📊 كمال الجداول**: يحافظ على المساحة الدقيقة للخلايا والحدود والمحاذاة وتنسيق النص
39
  - **🖼️ أقصى جودة للصور**: الحفاظ على 600 DPI بدون ضغط مدمر
40
  - **🌍 دعم العربية RTL**: عرض مثالي للنص من اليمين إلى اليسار مع خطوط Amiri و Noto
41
  - **🔍 التحقق من الجودة**: تحليل فوري للمستند والتحقق من التحويل
@@ -55,7 +55,7 @@ pinned: false
55
  ## 🚀 Usage
56
 
57
  ### Web Interface
58
- 1. Open your browser and go to `http://localhost:8000`
59
  2. Upload your `.docx` file using the drag-and-drop area
60
  3. Click "Convert to PDF" and wait for conversion to complete
61
  4. Download the generated PDF using the download button
@@ -65,16 +65,16 @@ You can also use the REST API directly:
65
 
66
  ```bash
67
  # Convert a DOCX file
68
- curl -X POST "http://localhost:8000/convert" \
69
  -H "accept: application/json" \
70
  -H "Content-Type: multipart/form-data" \
71
  -F "file=@/path/to/document.docx"
72
 
73
  # Health check
74
- curl -X GET "http://localhost:8000/health" -H "accept: application/json"
75
 
76
  # API Documentation
77
- # Visit http://localhost:8000/docs for interactive API documentation
78
  ```
79
 
80
  ## 🔧 Technical Excellence
@@ -114,7 +114,7 @@ curl -X GET "http://localhost:8000/health" -H "accept: application/json"
114
  # Build and run the container
115
  docker-compose up --build
116
 
117
- # The application will be available at http://localhost:8000
118
  ```
119
 
120
  ### Direct Installation
@@ -134,8 +134,8 @@ pip install -r requirements.txt
134
  # Run the FastAPI app
135
  python main.py
136
 
137
- # The application will be available at http://localhost:8000
138
- # API documentation at http://localhost:8000/docs
139
  ```
140
 
141
  For Hugging Face Spaces deployment, all system dependencies are automatically installed via the enhanced `packages.txt`.
@@ -156,4 +156,4 @@ Creates DOCX to PDF conversions so accurate that users cannot tell the differenc
156
 
157
  ---
158
 
159
- **Built for Hugging Face Spaces** | Enterprise-Grade • Pixel-Perfect • Uncompromising Quality
 
35
  ## ✨ الميزات المحسنة للعربية
36
 
37
  - **🔤 تميز الخطوط**: توافق كامل مع الخطوط العربية (Traditional Arabic→Amiri، Arabic Typesetting→Noto Naskh، Simplified Arabic→Noto Naskh)
38
+ - **📊 كمال الجداول**: يحافظ على المساحة الدقة للخلايا والحدود والمحاذاة وتنسيق النص
39
  - **🖼️ أقصى جودة للصور**: الحفاظ على 600 DPI بدون ضغط مدمر
40
  - **🌍 دعم العربية RTL**: عرض مثالي للنص من اليمين إلى اليسار مع خطوط Amiri و Noto
41
  - **🔍 التحقق من الجودة**: تحليل فوري للمستند والتحقق من التحويل
 
55
  ## 🚀 Usage
56
 
57
  ### Web Interface
58
+ 1. Open your browser and go to `http://localhost:7860` <!-- Changed from 8000 to 7860 -->
59
  2. Upload your `.docx` file using the drag-and-drop area
60
  3. Click "Convert to PDF" and wait for conversion to complete
61
  4. Download the generated PDF using the download button
 
65
 
66
  ```bash
67
  # Convert a DOCX file
68
+ curl -X POST "http://localhost:7860/convert" \ <!-- Changed from 8000 to 7860 -->
69
  -H "accept: application/json" \
70
  -H "Content-Type: multipart/form-data" \
71
  -F "file=@/path/to/document.docx"
72
 
73
  # Health check
74
+ curl -X GET "http://localhost:7860/health" -H "accept: application/json" <!-- Changed from 8000 to 7860 -->
75
 
76
  # API Documentation
77
+ # Visit http://localhost:7860/docs for interactive API documentation <!-- Changed from 8000 to 7860 -->
78
  ```
79
 
80
  ## 🔧 Technical Excellence
 
114
  # Build and run the container
115
  docker-compose up --build
116
 
117
+ # The application will be available at http://localhost:7860 <!-- Changed from 8000 to 7860 -->
118
  ```
119
 
120
  ### Direct Installation
 
134
  # Run the FastAPI app
135
  python main.py
136
 
137
+ # The application will be available at http://localhost:7860 <!-- Changed from 8000 to 7860 -->
138
+ # API documentation at http://localhost:7860/docs <!-- Changed from 8000 to 7860 -->
139
  ```
140
 
141
  For Hugging Face Spaces deployment, all system dependencies are automatically installed via the enhanced `packages.txt`.
 
156
 
157
  ---
158
 
159
+ **Built for Hugging Face Spaces** | Enterprise-Grade • Pixel-Perfect • Uncompromising Quality
docker-compose.yml CHANGED
@@ -5,7 +5,7 @@ services:
5
  build: .
6
  container_name: docx-pdf-converter-arabic
7
  ports:
8
- - "8000:8000"
9
  environment:
10
  - LANG=ar_SA.UTF-8
11
  - LC_ALL=ar_SA.UTF-8
@@ -16,8 +16,8 @@ services:
16
  - ./test_results:/app/test_results
17
  restart: unless-stopped
18
  healthcheck:
19
- test: ["CMD", "curl", "-f", "http://localhost:8000/"]
20
  interval: 30s
21
  timeout: 10s
22
  retries: 3
23
- start_period: 40s
 
5
  build: .
6
  container_name: docx-pdf-converter-arabic
7
  ports:
8
+ - "7860:7860" # Changed from 8000:8000 to 7860:7860 for Hugging Face Spaces compatibility
9
  environment:
10
  - LANG=ar_SA.UTF-8
11
  - LC_ALL=ar_SA.UTF-8
 
16
  - ./test_results:/app/test_results
17
  restart: unless-stopped
18
  healthcheck:
19
+ test: ["CMD", "curl", "-f", "http://localhost:7860/"] # Changed from 8000 to 7860
20
  interval: 30s
21
  timeout: 10s
22
  retries: 3
23
+ start_period: 40s
main.py CHANGED
@@ -305,7 +305,7 @@ if __name__ == "__main__":
305
  uvicorn.run(
306
  "main:app",
307
  host="0.0.0.0",
308
- port=8000,
309
  reload=True,
310
  log_level="info"
311
  )
 
305
  uvicorn.run(
306
  "main:app",
307
  host="0.0.0.0",
308
+ port=7860, # Changed from 8000 to 7860 for Hugging Face Spaces compatibility
309
  reload=True,
310
  log_level="info"
311
  )
verify_files.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Script to verify that all necessary files are present for the Docker build
4
+ """
5
+
6
+ import os
7
+ import sys
8
+ from pathlib import Path
9
+
10
+ def check_file_exists(filepath, description):
11
+ """Check if a file exists and print status"""
12
+ if os.path.exists(filepath):
13
+ print(f"✅ {description} - Found")
14
+ return True
15
+ else:
16
+ print(f"❌ {description} - Missing")
17
+ return False
18
+
19
+ def main():
20
+ """Main function to verify all required files"""
21
+ print("Verifying required files for Docker build...")
22
+
23
+ # List of required files
24
+ required_files = [
25
+ ("requirements.txt", "Python dependencies file"),
26
+ ("app.py", "Main application logic"),
27
+ ("main.py", "FastAPI application"),
28
+ ("Dockerfile", "Docker configuration"),
29
+ ("packages.txt", "System packages for Hugging Face"),
30
+ ("arabic_fonts_setup.sh", "Arabic fonts setup script"),
31
+ ("libreoffice_arabic_config.xml", "LibreOffice configuration"),
32
+ ("arial.ttf", "Arial font file"),
33
+ ("static/index.html", "Web interface"),
34
+ ]
35
+
36
+ # Check each file
37
+ all_files_found = True
38
+ for filepath, description in required_files:
39
+ if not check_file_exists(filepath, description):
40
+ all_files_found = False
41
+
42
+ # Check if static directory exists
43
+ if os.path.exists("static") and os.path.isdir("static"):
44
+ print("✅ Static directory - Found")
45
+ # Check if index.html exists in static directory
46
+ if os.path.exists("static/index.html"):
47
+ print("✅ Static index.html - Found")
48
+ else:
49
+ print("❌ Static index.html - Missing")
50
+ all_files_found = False
51
+ else:
52
+ print("❌ Static directory - Missing")
53
+ all_files_found = False
54
+
55
+ # Print summary
56
+ if all_files_found:
57
+ print("\n🎉 All required files are present!")
58
+ return 0
59
+ else:
60
+ print("\n💥 Some required files are missing!")
61
+ return 1
62
+
63
+ if __name__ == "__main__":
64
+ sys.exit(main())