Fred808 commited on
Commit
5ff7bd7
·
verified ·
1 Parent(s): 74f7b0e

Upload Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +30 -6
Dockerfile CHANGED
@@ -1,17 +1,41 @@
 
1
  FROM python:3.11-slim
2
 
 
3
  WORKDIR /app
4
- COPY . /app
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  RUN pip install --no-cache-dir -r requirements.txt
7
 
8
- # Make the entire /app directory fully writeable for all users
9
- RUN chmod -R 777 /app
 
 
 
10
 
11
- # Ensure the app runs as the same user as the Space UI
12
- RUN useradd -m -u 1000 user
13
- USER user
14
 
 
15
  EXPOSE 7860
16
 
 
 
 
 
 
17
  CMD ["python", "app.py"]
 
 
1
+ # Use Python 3.11 slim image
2
  FROM python:3.11-slim
3
 
4
+ # Set working directory
5
  WORKDIR /app
 
6
 
7
+ # Set environment variables
8
+ ENV PYTHONDONTWRITEBYTECODE=1
9
+ ENV PYTHONUNBUFFERED=1
10
+ ENV PORT=7860
11
+
12
+ # Install system dependencies
13
+ RUN apt-get update && apt-get install -y \
14
+ gcc \
15
+ && rm -rf /var/lib/apt/lists/*
16
+
17
+ # Copy requirements first for better caching
18
+ COPY requirements.txt .
19
+
20
+ # Install Python dependencies
21
  RUN pip install --no-cache-dir -r requirements.txt
22
 
23
+ # Copy application files
24
+ COPY app.py .
25
+ COPY index.html .
26
+ COPY style.css .
27
+ COPY script.js .
28
 
29
+ # Create necessary directories
30
+ RUN mkdir -p downloads
 
31
 
32
+ # Expose port
33
  EXPOSE 7860
34
 
35
+ # Health check
36
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
37
+ CMD curl -f http://localhost:7860/health || exit 1
38
+
39
+ # Run the application
40
  CMD ["python", "app.py"]
41
+