ayush2917 commited on
Commit
d8f6a05
·
verified ·
1 Parent(s): acc8efa

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -3
Dockerfile CHANGED
@@ -1,3 +1,4 @@
 
1
  FROM python:3.9-slim-buster
2
 
3
  # Set environment variables
@@ -7,21 +8,30 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
7
  HUGGINGFACE_HUB_DISABLE_XET=1 \
8
  PIP_NO_CACHE_DIR=1
9
 
 
10
  WORKDIR /app
11
 
12
  # Install system dependencies
13
  RUN apt-get update && apt-get install -y --no-install-recommends \
14
  build-essential \
 
 
15
  && rm -rf /var/lib/apt/lists/*
16
 
 
 
 
17
  # Copy requirements first for better caching
18
  COPY requirements.txt .
19
- RUN pip install --no-cache-dir -r requirements.txt
 
 
 
20
 
21
  # Create necessary directories
22
  RUN mkdir -p /app/data
23
 
24
- # Copy all files
25
  COPY . .
26
 
27
  # Create non-root user and set permissions
@@ -29,7 +39,8 @@ RUN useradd -m myuser && \
29
  chown -R myuser:myuser /app
30
  USER myuser
31
 
 
32
  EXPOSE 8000
33
 
34
- # Start with fewer workers to reduce memory usage
35
  CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "1", "--timeout", "120", "app:app"]
 
1
+ # Use a slim Python 3.9 base image
2
  FROM python:3.9-slim-buster
3
 
4
  # Set environment variables
 
8
  HUGGINGFACE_HUB_DISABLE_XET=1 \
9
  PIP_NO_CACHE_DIR=1
10
 
11
+ # Set working directory
12
  WORKDIR /app
13
 
14
  # Install system dependencies
15
  RUN apt-get update && apt-get install -y --no-install-recommends \
16
  build-essential \
17
+ gcc \
18
+ g++ \
19
  && rm -rf /var/lib/apt/lists/*
20
 
21
+ # Upgrade pip to the latest version
22
+ RUN pip install --upgrade pip
23
+
24
  # Copy requirements first for better caching
25
  COPY requirements.txt .
26
+
27
+ # Install dependencies from requirements.txt
28
+ # Split installation to isolate torch with custom index URL if needed
29
+ RUN pip install --no-cache-dir -r requirements.txt || { echo "Failed to install requirements"; exit 1; }
30
 
31
  # Create necessary directories
32
  RUN mkdir -p /app/data
33
 
34
+ # Copy all project files
35
  COPY . .
36
 
37
  # Create non-root user and set permissions
 
39
  chown -R myuser:myuser /app
40
  USER myuser
41
 
42
+ # Expose port for Gunicorn
43
  EXPOSE 8000
44
 
45
+ # Start Gunicorn with a single worker to reduce memory usage
46
  CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "1", "--timeout", "120", "app:app"]