feliksius commited on
Commit
ca32686
·
verified ·
1 Parent(s): a50bc7d

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +26 -26
Dockerfile CHANGED
@@ -1,40 +1,40 @@
1
- # Use official Python 3.10 slim image for a smaller footprint
2
  FROM python:3.10-slim
3
 
4
- # Set environment variables
5
- ENV TRANSFORMERS_CACHE=/app/cache \
6
- HF_HOME=/app/cache \
7
- USE_QUANTIZATION=0 \
8
- DEVICE=-1 \
9
- MAX_TEXT_LENGTH=5000
10
-
11
  # Set working directory
12
  WORKDIR /app
13
 
14
- # Create the /app directory explicitly to avoid copy errors
15
- RUN mkdir -p /app
16
-
17
- # Copy requirements file
18
- COPY requirements.txt .
19
 
20
- # Install system dependencies and Python packages
21
- # Note: libgomp1 is required for PyTorch
 
 
 
 
 
 
 
22
  RUN apt-get update && apt-get install -y \
23
- gcc \
24
- libgomp1 \
25
- && rm -rf /var/lib/apt/lists/* \
26
- && pip install --no-cache-dir --upgrade pip \
 
 
 
27
  && pip install --no-cache-dir -r requirements.txt
28
 
29
  # Copy application code
30
  COPY app.py .
31
 
32
- # Create cache and logs directories with write permissions
33
- RUN mkdir -p /app/cache /app/logs \
34
- && chmod -R 777 /app/cache /app/logs
 
35
 
36
- # Expose port for FastAPI
37
- EXPOSE 8000
38
 
39
- # Run Uvicorn server
40
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
 
 
1
  FROM python:3.10-slim
2
 
 
 
 
 
 
 
 
3
  # Set working directory
4
  WORKDIR /app
5
 
6
+ # Create necessary directories
7
+ RUN mkdir -p /app/cache /app/logs
 
 
 
8
 
9
+ # Set environment variables
10
+ ENV PYTHONUNBUFFERED=1
11
+ ENV HF_HOME=/app/cache
12
+ ENV TRANSFORMERS_CACHE=/app/cache
13
+ ENV MAX_TEXT_LENGTH=5000
14
+ ENV GRADIO_SERVER_NAME=0.0.0.0
15
+ ENV GRADIO_SERVER_PORT=7860
16
+
17
+ # Install system dependencies
18
  RUN apt-get update && apt-get install -y \
19
+ build-essential \
20
+ curl \
21
+ && rm -rf /var/lib/apt/lists/*
22
+
23
+ # Copy requirements and install Python dependencies
24
+ COPY requirements.txt .
25
+ RUN pip install --no-cache-dir --upgrade pip \
26
  && pip install --no-cache-dir -r requirements.txt
27
 
28
  # Copy application code
29
  COPY app.py .
30
 
31
+ # Create a non-root user for security
32
+ RUN useradd -m -u 1000 user
33
+ RUN chown -R user:user /app
34
+ USER user
35
 
36
+ # Expose port
37
+ EXPOSE 7860
38
 
39
+ # Run the application
40
+ CMD ["python", "app.py"]