wayne-chi commited on
Commit
0fc06cf
·
verified ·
1 Parent(s): 2723d19

Upload Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +64 -36
Dockerfile CHANGED
@@ -1,36 +1,64 @@
1
- FROM python:3.9-slim
2
-
3
- # Set working directory
4
- WORKDIR /app
5
-
6
- # Install system dependencies
7
- RUN apt-get update && apt-get install -y \
8
- build-essential \
9
- git \
10
- curl \
11
- && rm -rf /var/lib/apt/lists/*
12
-
13
- # Create /app and give ownership to the typical HF Spaces user (uid 1000)
14
- # Also allow read/write/execute for all users (just for runtime flexibility)
15
- RUN mkdir -p /app && chown -R 1000:1000 /app && chmod -R a+rw /app
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 all app files into container
24
- COPY . .
25
-
26
- # Make setup.sh executable
27
- RUN chmod +x setup.sh
28
-
29
- # Run setup.sh at build time so models are preloaded
30
- RUN ./setup.sh
31
-
32
- # Expose Streamlit port
33
- EXPOSE 7860
34
-
35
- # Run Streamlit app
36
- CMD ["streamlit", "run", "test_app.py", "--server.port=7860", "--server.address=0.0.0.0"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FROM python:3.10-slim
2
+
3
+ # # Set working directory
4
+ # WORKDIR /app
5
+
6
+ # # Copy everything into the container
7
+ # COPY . /app
8
+
9
+ # # Create a writable config directory for Matplotlib
10
+ # RUN mkdir -p /app/.config/matplotlib
11
+
12
+ # # Set environment variables for Hugging Face + Matplotlib
13
+ # ENV MPLCONFIGDIR=/app/.config/matplotlib \
14
+ # PYTHONUNBUFFERED=1 \
15
+ # PIP_NO_CACHE_DIR=1
16
+
17
+ # # Install dependencies
18
+ # RUN pip install --upgrade pip && \
19
+ # pip install -r requirements.txt
20
+
21
+ # # Run setup script (e.g., download models)
22
+ # RUN chmod +x setup.sh && ./setup.sh
23
+
24
+ # # Expose port for Streamlit
25
+ # EXPOSE 7860
26
+
27
+ # # Command to run Streamlit app
28
+ # CMD ["streamlit", "run", "streamlit_app.py", "--server.port=7860", "--server.address=0.0.0.0"]
29
+ # Start from NVIDIA’s CUDA image with cuDNN support
30
+ FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04
31
+
32
+ # Set working directory
33
+ WORKDIR /app
34
+
35
+ # Install Python + essentials
36
+ RUN apt-get update && \
37
+ apt-get install -y python3.10 python3.10-venv python3-pip && \
38
+ rm -rf /var/lib/apt/lists/*
39
+
40
+ # Copy everything into the container
41
+ COPY . /app
42
+
43
+ # Create a writable config directory for Matplotlib
44
+ RUN mkdir -p /app/.config/matplotlib
45
+
46
+ # Set environment variables
47
+ ENV MPLCONFIGDIR=/app/.config/matplotlib \
48
+ PYTHONUNBUFFERED=1 \
49
+ PIP_NO_CACHE_DIR=1
50
+
51
+ # Upgrade pip and install dependencies
52
+ RUN python3.10 -m pip install --upgrade pip && \
53
+ pip install -r requirements.txt
54
+
55
+ # Run setup script (e.g., download models)
56
+ RUN chmod +x setup.sh && ./setup.sh
57
+
58
+ # Expose Streamlit port
59
+ EXPOSE 7860
60
+
61
+ # Command to run Streamlit app
62
+ CMD ["streamlit", "run", "test_app.py", "--server.port=7860", "--server.address=0.0.0.0"]
63
+
64
+