Devam0 commited on
Commit
c0e2fd2
Β·
1 Parent(s): 355774b

corrections

Browse files
Files changed (5) hide show
  1. DEPLOYMENT.md +31 -0
  2. Dockerfile +7 -3
  3. Dockerfile.alternative +38 -0
  4. fix_build.py +65 -0
  5. requirements.txt +2 -2
DEPLOYMENT.md CHANGED
@@ -148,6 +148,37 @@ python test_server.py
148
  - Verify port configuration (should be 7860)
149
  - Check logs for runtime errors
150
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  ### Debug Commands
152
 
153
  ```bash
 
148
  - Verify port configuration (should be 7860)
149
  - Check logs for runtime errors
150
 
151
+ ### 🐳 Docker Build Issues
152
+
153
+ #### Package Installation Errors
154
+ If you encounter errors like:
155
+ ```
156
+ Package 'libgl1-mesa-glx' is not available
157
+ ```
158
+
159
+ **Solution 1**: Use the updated Dockerfile with minimal dependencies
160
+ **Solution 2**: Try the alternative Dockerfile:
161
+ ```bash
162
+ # Rename the alternative Dockerfile
163
+ mv Dockerfile Dockerfile.backup
164
+ mv Dockerfile.alternative Dockerfile
165
+ git add .
166
+ git commit -m "Use alternative Dockerfile for compatibility"
167
+ git push
168
+ ```
169
+
170
+ **Solution 3**: Use a different base image in your Dockerfile:
171
+ ```dockerfile
172
+ FROM python:3.9-bullseye
173
+ # or
174
+ FROM python:3.9-buster
175
+ ```
176
+
177
+ #### OpenCV Compatibility Issues
178
+ If OpenCV fails to install or work:
179
+ - The project now uses `opencv-python-headless` which is more Docker-friendly
180
+ - This version doesn't require GUI libraries
181
+
182
  ### Debug Commands
183
 
184
  ```bash
Dockerfile CHANGED
@@ -1,10 +1,13 @@
1
  # Base image
2
  FROM python:3.9-slim
3
 
4
- # Install system dependencies
5
  RUN apt-get update && apt-get install -y \
6
- libgl1-mesa-glx \
7
  libglib2.0-0 \
 
 
 
 
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
  # Set working directory
@@ -12,7 +15,8 @@ WORKDIR /app
12
 
13
  # Copy and install dependencies
14
  COPY requirements.txt .
15
- RUN pip install --no-cache-dir --upgrade -r requirements.txt
 
16
 
17
  # Copy project files
18
  COPY . .
 
1
  # Base image
2
  FROM python:3.9-slim
3
 
4
+ # Install minimal system dependencies
5
  RUN apt-get update && apt-get install -y \
 
6
  libglib2.0-0 \
7
+ libsm6 \
8
+ libxext6 \
9
+ libxrender1 \
10
+ libgomp1 \
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
  # Set working directory
 
15
 
16
  # Copy and install dependencies
17
  COPY requirements.txt .
18
+ RUN pip install --no-cache-dir --upgrade pip && \
19
+ pip install --no-cache-dir -r requirements.txt
20
 
21
  # Copy project files
22
  COPY . .
Dockerfile.alternative ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Alternative Dockerfile using Ubuntu base
2
+ FROM ubuntu:20.04
3
+
4
+ # Prevent interactive prompts during package installation
5
+ ENV DEBIAN_FRONTEND=noninteractive
6
+
7
+ # Install Python and system dependencies
8
+ RUN apt-get update && apt-get install -y \
9
+ python3.9 \
10
+ python3.9-dev \
11
+ python3.9-distutils \
12
+ python3-pip \
13
+ libglib2.0-0 \
14
+ libsm6 \
15
+ libxext6 \
16
+ libxrender1 \
17
+ libgomp1 \
18
+ && rm -rf /var/lib/apt/lists/*
19
+
20
+ # Create symlink for python command
21
+ RUN ln -s /usr/bin/python3.9 /usr/bin/python
22
+
23
+ # Set working directory
24
+ WORKDIR /app
25
+
26
+ # Copy and install dependencies
27
+ COPY requirements.txt .
28
+ RUN pip3 install --no-cache-dir --upgrade pip && \
29
+ pip3 install --no-cache-dir -r requirements.txt
30
+
31
+ # Copy project files
32
+ COPY . .
33
+
34
+ # Expose Hugging Face Space port
35
+ EXPOSE 7860
36
+
37
+ # Start FastAPI server
38
+ CMD ["python", "-m", "uvicorn", "inference_server:app", "--host", "0.0.0.0", "--port", "7860"]
fix_build.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Quick fix script for Docker build issues
4
+ """
5
+
6
+ import os
7
+ import subprocess
8
+
9
+ def run_command(command, description):
10
+ """Run a command and handle errors"""
11
+ print(f"πŸ”„ {description}...")
12
+ try:
13
+ result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
14
+ print(f"βœ… {description} completed successfully")
15
+ return result.stdout
16
+ except subprocess.CalledProcessError as e:
17
+ print(f"❌ {description} failed:")
18
+ print(f"Error: {e.stderr}")
19
+ return None
20
+
21
+ def main():
22
+ print("πŸ”§ Docker Build Fix for Devam Jersey Server")
23
+ print("=" * 50)
24
+
25
+ print("\n🚨 The build failed due to package compatibility issues.")
26
+ print("I've already fixed the Dockerfile, but here are your options:")
27
+
28
+ print("\nπŸ“‹ Option 1: Use the Fixed Dockerfile (Recommended)")
29
+ print("The Dockerfile has been updated with compatible packages.")
30
+ print("Just push the changes:")
31
+ print(" git add .")
32
+ print(" git commit -m 'Fix Dockerfile for package compatibility'")
33
+ print(" git push")
34
+
35
+ print("\nπŸ“‹ Option 2: Use Alternative Dockerfile")
36
+ print("If the main Dockerfile still has issues:")
37
+ print(" mv Dockerfile Dockerfile.backup")
38
+ print(" mv Dockerfile.alternative Dockerfile")
39
+ print(" git add .")
40
+ print(" git commit -m 'Use alternative Dockerfile'")
41
+ print(" git push")
42
+
43
+ print("\nπŸ“‹ Option 3: Manual Fix")
44
+ print("Edit Dockerfile and change the base image to:")
45
+ print(" FROM python:3.9-bullseye")
46
+ print(" # or")
47
+ print(" FROM python:3.9-buster")
48
+
49
+ print("\nπŸ” What was fixed:")
50
+ print("- Removed problematic 'libgl1-mesa-glx' package")
51
+ print("- Added minimal OpenCV dependencies")
52
+ print("- Changed to 'opencv-python-headless' in requirements.txt")
53
+ print("- Created alternative Dockerfile with Ubuntu base")
54
+
55
+ print("\nπŸ’‘ Pro tip:")
56
+ print("The 'opencv-python-headless' package is more Docker-friendly")
57
+ print("and doesn't require GUI libraries that cause build issues.")
58
+
59
+ print("\nπŸš€ After fixing, monitor the build:")
60
+ print("1. Go to your HF Space")
61
+ print("2. Check 'Settings' β†’ 'Build logs'")
62
+ print("3. Wait for successful build completion")
63
+
64
+ if __name__ == "__main__":
65
+ main()
requirements.txt CHANGED
@@ -5,8 +5,8 @@ ultralytics>=8.0.0
5
  transformers>=4.30.0
6
  Pillow>=9.0.0
7
 
8
- # Computer Vision
9
- opencv-python>=4.8.0
10
 
11
  # Vector search
12
  faiss-cpu>=1.7.0
 
5
  transformers>=4.30.0
6
  Pillow>=9.0.0
7
 
8
+ # Computer Vision - using headless version for Docker
9
+ opencv-python-headless>=4.8.0
10
 
11
  # Vector search
12
  faiss-cpu>=1.7.0