amine_dubs
		
	commited on
		
		
					Commit 
							
							·
						
						6241879
	
1
								Parent(s):
							
							d645d4c
								
Fix: Add python-multipart and set HF cache directory
Browse files- Dockerfile +26 -27
- backend/requirements.txt +2 -1
    	
        Dockerfile
    CHANGED
    
    | @@ -1,40 +1,39 @@ | |
| 1 | 
            -
            # Use an official Python  | 
| 2 | 
             
            FROM python:3.12-slim
         | 
| 3 |  | 
| 4 | 
             
            # Set the working directory in the container
         | 
| 5 | 
             
            WORKDIR /app
         | 
| 6 |  | 
| 7 | 
            -
            #  | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
            #  | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
            # Install Python dependencies
         | 
| 22 | 
            -
            RUN pip install --no-cache-dir --upgrade pip
         | 
| 23 | 
             
            RUN pip install --no-cache-dir -r requirements.txt
         | 
| 24 |  | 
| 25 | 
             
            # Copy the rest of the application code into the container
         | 
| 26 | 
            -
             | 
| 27 | 
            -
            COPY  | 
| 28 | 
            -
            COPY static/  | 
|  | |
| 29 |  | 
| 30 | 
            -
            # Create the  | 
| 31 | 
            -
            RUN mkdir -p /app/ | 
| 32 |  | 
| 33 | 
            -
            #  | 
| 34 | 
            -
            RUN chmod -R 777 /app/uploads
         | 
| 35 | 
            -
             | 
| 36 | 
            -
            # Make port 8000 available
         | 
| 37 | 
             
            EXPOSE 8000
         | 
| 38 |  | 
| 39 | 
            -
            #  | 
|  | |
|  | |
|  | |
|  | |
| 40 | 
             
            CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"]
         | 
|  | |
| 1 | 
            +
            # Use an official Python runtime as a parent image
         | 
| 2 | 
             
            FROM python:3.12-slim
         | 
| 3 |  | 
| 4 | 
             
            # Set the working directory in the container
         | 
| 5 | 
             
            WORKDIR /app
         | 
| 6 |  | 
| 7 | 
            +
            # --- Set Hugging Face cache directory ---
         | 
| 8 | 
            +
            # Create a cache directory within the working directory and set HF_HOME
         | 
| 9 | 
            +
            # This ensures the container has write permissions for downloading models/tokenizers
         | 
| 10 | 
            +
            RUN mkdir -p /app/.cache
         | 
| 11 | 
            +
            ENV HF_HOME=/app/.cache
         | 
| 12 | 
            +
            ENV TRANSFORMERS_CACHE=/app/.cache # Also set TRANSFORMERS_CACHE for good measure
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            # Copy the requirements file into the container at /app
         | 
| 15 | 
            +
            # Copy only requirements first to leverage Docker layer caching
         | 
| 16 | 
            +
            COPY backend/requirements.txt .
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            # Install any needed packages specified in requirements.txt
         | 
| 19 | 
            +
            # Add --no-cache-dir to reduce image size
         | 
|  | |
|  | |
|  | |
| 20 | 
             
            RUN pip install --no-cache-dir -r requirements.txt
         | 
| 21 |  | 
| 22 | 
             
            # Copy the rest of the application code into the container
         | 
| 23 | 
            +
            # Copy backend, static, and templates directories
         | 
| 24 | 
            +
            COPY backend/ ./backend
         | 
| 25 | 
            +
            COPY static/ ./static
         | 
| 26 | 
            +
            COPY templates/ ./templates
         | 
| 27 |  | 
| 28 | 
            +
            # Create the uploads directory (ensure it exists)
         | 
| 29 | 
            +
            RUN mkdir -p /app/uploads
         | 
| 30 |  | 
| 31 | 
            +
            # Make port 8000 available to the world outside this container
         | 
|  | |
|  | |
|  | |
| 32 | 
             
            EXPOSE 8000
         | 
| 33 |  | 
| 34 | 
            +
            # Define environment variable (optional, can be set in HF Spaces settings too)
         | 
| 35 | 
            +
            # ENV MODEL_NAME="Helsinki-NLP/opus-mt-en-ar"
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            # Run main.py when the container launches
         | 
| 38 | 
            +
            # Use the backend subdirectory path for the module
         | 
| 39 | 
             
            CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"]
         | 
    	
        backend/requirements.txt
    CHANGED
    
    | @@ -3,4 +3,5 @@ uvicorn | |
| 3 | 
             
            python-docx
         | 
| 4 | 
             
            PyMuPDF
         | 
| 5 | 
             
            transformers[torch]
         | 
| 6 | 
            -
            sentencepiece | 
|  | 
|  | |
| 3 | 
             
            python-docx
         | 
| 4 | 
             
            PyMuPDF
         | 
| 5 | 
             
            transformers[torch]
         | 
| 6 | 
            +
            sentencepiece
         | 
| 7 | 
            +
            python-multipart # Added for FastAPI form data handling
         |