Srevarshan1502 commited on
Commit
0a23aaf
·
1 Parent(s): 4dbcf14

added Docker file

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -15
Dockerfile CHANGED
@@ -7,36 +7,32 @@ WORKDIR /app
7
  # Set environment variables
8
  ENV PYTHONUNBUFFERED=1
9
  ENV PYTHONDONTWRITEBYTECODE=1
10
- ENV GRADIO_SERVER_NAME=0.0.0.0
11
- ENV GRADIO_SERVER_PORT=7860
12
 
13
- # Install system dependencies
 
14
  RUN apt-get update && apt-get install -y \
15
  gcc \
16
  g++ \
17
  && rm -rf /var/lib/apt/lists/*
18
 
19
- # Copy requirements first for better Docker layer caching
20
  COPY requirements.txt .
21
-
22
- # Install Python dependencies
23
  RUN pip install --no-cache-dir --upgrade pip && \
24
  pip install --no-cache-dir -r requirements.txt
25
 
26
- # Copy application code
27
  COPY app.py .
 
28
 
29
- # Create non-root user for security
30
  RUN useradd --create-home --shell /bin/bash app && \
31
  chown -R app:app /app
32
  USER app
33
 
34
- # Expose the port that Gradio will run on
35
  EXPOSE 7860
36
 
37
- # Health check
38
- HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
39
- CMD curl -f http://localhost:7860/health || exit 1
40
-
41
- # Run the application
42
- CMD ["python", "app.py"]
 
7
  # Set environment variables
8
  ENV PYTHONUNBUFFERED=1
9
  ENV PYTHONDONTWRITEBYTECODE=1
10
+ ENV FASTAPI_SERVER_NAME=0.0.0.0
11
+ ENV FASTAPI_SERVER_PORT=7860
12
 
13
+ # Install build dependencies for some Python packages (like uvicorn, fastapi)
14
+ # and for the signal handling
15
  RUN apt-get update && apt-get install -y \
16
  gcc \
17
  g++ \
18
  && rm -rf /var/lib/apt/lists/*
19
 
20
+ # Copy requirements.txt and install Python dependencies
21
  COPY requirements.txt .
 
 
22
  RUN pip install --no-cache-dir --upgrade pip && \
23
  pip install --no-cache-dir -r requirements.txt
24
 
25
+ # Copy the application files
26
  COPY app.py .
27
+ COPY index.html . # <--- ADDED THIS LINE to copy the HTML file
28
 
29
+ # Create a non-root user for security
30
  RUN useradd --create-home --shell /bin/bash app && \
31
  chown -R app:app /app
32
  USER app
33
 
34
+ # Expose the port FastAPI will run on
35
  EXPOSE 7860
36
 
37
+ # Command to run the FastAPI application using Uvicorn
38
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]