Hadiil commited on
Commit
10a0c25
·
verified ·
1 Parent(s): cdc5729

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +28 -27
Dockerfile CHANGED
@@ -1,41 +1,42 @@
1
- # Use an official Python runtime as the base image
2
- FROM python:3.9-slim
3
 
4
- # Set working directory in the container
5
- WORKDIR /app
 
 
 
6
 
7
- # Set environment variables
8
- ENV PYTHONUNBUFFERED=1 \
9
- PYTHONDONTWRITEBYTECODE=1 \
10
- HF_HOME=/tmp/huggingface_cache \
11
- UPLOAD_DIR=/tmp/uploads \
12
- PORT=7860
13
 
14
  # Install system dependencies
15
- RUN apt-get update && apt-get install -y \
 
16
  gcc \
17
- libpq-dev \
18
- libjpeg-dev \
19
- zlib1g-dev \
20
- libpng-dev \
21
- && apt-get clean \
22
  && rm -rf /var/lib/apt/lists/*
23
 
24
- # Copy the requirements file
 
 
 
25
  COPY requirements.txt .
26
 
27
- # Install Python dependencies
28
- RUN pip install --no-cache-dir -r requirements.txt
 
29
 
30
- # Copy the application code
31
  COPY . .
32
 
33
- # Create cache and upload directories and set permissions
34
- RUN mkdir -p /tmp/huggingface_cache /tmp/uploads \
35
- && chmod -R 777 /tmp/huggingface_cache /tmp/uploads
36
-
37
- # Expose the port the app runs on
38
  EXPOSE 7860
39
 
40
- # Command to run the application
41
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
 
1
+ # Use official Python image
2
+ FROM python:3.10-slim
3
 
4
+ # Environment variables
5
+ ENV PYTHONUNBUFFERED=1
6
+ ENV TRANSFORMERS_CACHE=/app/cache
7
+ ENV UPLOAD_DIR=/app/uploads
8
+ ENV PORT=7860
9
 
10
+ # Create directories
11
+ RUN mkdir -p /app/cache /app/uploads /app/static && \
12
+ chmod -R 777 /app
 
 
 
13
 
14
  # Install system dependencies
15
+ RUN apt-get update && \
16
+ apt-get install -y --no-install-recommends \
17
  gcc \
18
+ python3-dev \
 
 
 
 
19
  && rm -rf /var/lib/apt/lists/*
20
 
21
+ # Set working directory
22
+ WORKDIR /app
23
+
24
+ # Copy requirements first for better caching
25
  COPY requirements.txt .
26
 
27
+ # Install Pythonnnn dependencies
28
+ RUN pip install --no-cache-dir -U pip setuptools wheel && \
29
+ pip install --no-cache-dir -r requirements.txt
30
 
31
+ # Copy application files
32
  COPY . .
33
 
34
+ # Expose the port
 
 
 
 
35
  EXPOSE 7860
36
 
37
+ # Health check
38
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
39
+ CMD curl -f http://localhost:7860/health || exit 1
40
+
41
+ # Run the application
42
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]