Akshay1014 commited on
Commit
a3c65e3
·
verified ·
1 Parent(s): a8d6a16

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +25 -8
Dockerfile CHANGED
@@ -1,18 +1,35 @@
1
- # Dockerfile
2
  FROM python:3.9-slim
3
 
4
- # Set a working directory
5
- # WORKDIR /app
6
 
7
- # Copy dependency definitions and install them
 
 
 
 
 
 
 
8
  COPY requirements.txt .
9
- RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
 
 
 
10
 
11
  # Copy the application code
12
- COPY . .
13
 
14
- # Expose the port that uvicorn will listen on (Hugging Face Spaces uses port 7860)
 
 
 
15
  EXPOSE 7860
16
 
17
- # Start the FastAPI app with uvicorn
 
 
 
 
18
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use Python 3.9 slim base image for a smaller footprint
2
  FROM python:3.9-slim
3
 
4
+ # Set working directory
5
+ WORKDIR /app
6
 
7
+ # Install system dependencies required for Pillow and Gradio
8
+ RUN apt-get update && apt-get install -y --no-install-recommends \
9
+ libjpeg-dev \
10
+ zlib1g-dev \
11
+ libpng-dev \
12
+ && rm -rf /var/lib/apt/lists/*
13
+
14
+ # Copy requirements.txt first to leverage Docker caching
15
  COPY requirements.txt .
16
+
17
+ # Upgrade pip and install Python dependencies
18
+ RUN pip install --upgrade pip && \
19
+ pip install --no-cache-dir -r requirements.txt
20
 
21
  # Copy the application code
22
+ COPY image_upload_app.py .
23
 
24
+ # Create directories for image storage
25
+ RUN mkdir -p cloud_storage/temp cloud_storage/permanent cloud_storage/thumbs
26
+
27
+ # Expose port 7860 for Gradio/FastAPI
28
  EXPOSE 7860
29
 
30
+ # Set environment variables for better Python performance
31
+ ENV PYTHONDONTWRITEBYTECODE=1
32
+ ENV PYTHONUNBUFFERED=1
33
+
34
+ # Run the application with Uvicorn
35
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]