Fred808 commited on
Commit
308ac61
·
verified ·
1 Parent(s): 2d3b3c6

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -13
Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- # Use Python 3.11 slim image
2
  FROM python:3.11-slim
3
 
4
  # Set working directory
@@ -11,37 +11,38 @@ 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
  RUN chmod -R 777 /app
33
 
34
- # Ensure the app runs as the same user as the Space UI
35
  RUN useradd -m -u 1000 user
36
  USER user
37
 
38
  # Expose port
39
  EXPOSE 7860
40
 
41
- # Health check
42
  HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
43
- CMD curl -f http://localhost:7860/health || exit 1
44
 
45
- # Run the application
46
  CMD ["python", "app.py"]
47
-
 
1
+ # Use slim Python 3.11 image
2
  FROM python:3.11-slim
3
 
4
  # Set working directory
 
11
 
12
  # Install system dependencies
13
  RUN apt-get update && apt-get install -y \
14
+ gcc curl \
15
  && rm -rf /var/lib/apt/lists/*
16
 
17
+ # Copy only 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 code
24
  COPY app.py .
 
 
 
25
 
26
+ # Copy templates and static directories
27
+ COPY templates/ templates/
28
+ COPY static/ static/
29
+
30
+ # Make sure necessary directories exist
31
  RUN mkdir -p downloads
32
 
33
+ # Set permissions
34
  RUN chmod -R 777 /app
35
 
36
+ # Create a user for safer container execution
37
  RUN useradd -m -u 1000 user
38
  USER user
39
 
40
  # Expose port
41
  EXPOSE 7860
42
 
43
+ # Health check (optional)
44
  HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
45
+ CMD curl -f http://localhost:7860/ || exit 1
46
 
47
+ # Start the app
48
  CMD ["python", "app.py"]