Sanket17 commited on
Commit
f82d1ce
·
verified ·
1 Parent(s): 07a7f47

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +24 -21
Dockerfile CHANGED
@@ -1,32 +1,35 @@
1
- # Use a specific version of Python (e.g., Python 3.9 for better compatibility with PyTorch)
2
  FROM python:3.9-slim
3
 
4
- # Set environment variables to avoid interactive prompts
5
- ENV DEBIAN_FRONTEND=noninteractive
6
 
7
- RUN apt-get update && apt-get install -y \
8
- libgl1-mesa-glx \ # For OpenCV compatibility
9
- libglib2.0-0 \ # For OpenCV compatibility
10
- build-essential \ # For building certain Python packages \
11
  && rm -rf /var/lib/apt/lists/*
12
 
 
 
13
 
14
- # Set the working directory
15
- WORKDIR /app
16
-
17
- # Copy requirements file
18
- COPY requirements.txt .
19
 
20
- # Install Python dependencies
21
- RUN python -m pip install --upgrade pip && \
22
- python -m pip install torch torchvision -f https://download.pytorch.org/whl/cpu/torch_stable.html && \
23
- python -m pip install -r requirements.txt
24
 
25
- # Copy the application code
26
- COPY . .
 
 
 
 
 
 
27
 
28
- # Expose the application port
29
  EXPOSE 8000
30
 
31
- # Command to run the application
32
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
 
1
+ # Use an official Python runtime as a parent image
2
  FROM python:3.9-slim
3
 
4
+ # Set the working directory in the container
5
+ WORKDIR /app
6
 
7
+ # Install system dependencies required for OpenCV
8
+ RUN apt-get update && apt-get install -y --no-install-recommends \
9
+ libgl1-mesa-glx \
10
+ libglib2.0-0 \
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
+ # Copy the requirements.txt into the container at /app
14
+ COPY requirements.txt /app/
15
 
16
+ # Install any needed Python dependencies
17
+ RUN pip install --no-cache-dir -r requirements.txt
 
 
 
18
 
19
+ # Create writable directories for caching and configuration
20
+ RUN mkdir -p /app/cache /app/config && chmod -R 777 /app/cache /app/config
 
 
21
 
22
+ # Set environment variables
23
+ ENV HF_HOME=/app/cache \
24
+ MPLCONFIGDIR=/app/config/matplotlib \
25
+ YOLO_CONFIG_DIR=/app/config/ultralytics
26
+
27
+ ENV HUGGINGFACE_HUB_ENABLE_HF_UPGRADE_CHECK=false
28
+ # Copy the current directory contents into the container at /app
29
+ COPY . /app/
30
 
31
+ # Expose port 8000 for the FastAPI app
32
  EXPOSE 8000
33
 
34
+ # Run FastAPI app using uvicorn
35
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]