Pavithiran commited on
Commit
19303ae
·
verified ·
1 Parent(s): 617f1bc

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +49 -2
Dockerfile CHANGED
@@ -1,3 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  FROM nvidia/cuda:12.1.1-runtime-ubuntu22.04
2
  ENV DEBIAN_FRONTEND=noninteractive
3
 
@@ -9,6 +40,9 @@ RUN apt-get update && apt-get install -y \
9
  && apt-get clean \
10
  && rm -rf /var/lib/apt/lists/*
11
 
 
 
 
12
  # Create a working directory
13
  WORKDIR /app
14
 
@@ -17,15 +51,28 @@ COPY requirements.txt .
17
  RUN pip3 install --no-cache-dir -r requirements.txt
18
 
19
  # Copy the application code
20
- COPY app.py .
 
 
 
 
 
 
21
 
22
  # Set environment variables
23
  ENV PYTHONUNBUFFERED=1
24
  ENV GRADIO_SERVER_NAME=0.0.0.0
25
  ENV GRADIO_SERVER_PORT=7860
 
 
 
 
 
 
 
26
 
27
  # Expose the port
28
  EXPOSE 7860
29
 
30
  # Command to run the application
31
- CMD ["python3", "app.py"]
 
1
+ # FROM nvidia/cuda:12.1.1-runtime-ubuntu22.04
2
+ # ENV DEBIAN_FRONTEND=noninteractive
3
+
4
+ # # Install system dependencies
5
+ # RUN apt-get update && apt-get install -y \
6
+ # python3 python3-pip git \
7
+ # ffmpeg libsm6 libxext6 \
8
+ # --no-install-recommends \
9
+ # && apt-get clean \
10
+ # && rm -rf /var/lib/apt/lists/*
11
+
12
+ # # Create a working directory
13
+ # WORKDIR /app
14
+
15
+ # # Copy requirements and install dependencies
16
+ # COPY requirements.txt .
17
+ # RUN pip3 install --no-cache-dir -r requirements.txt
18
+
19
+ # # Copy the application code
20
+ # COPY app.py .
21
+
22
+ # # Set environment variables
23
+ # ENV PYTHONUNBUFFERED=1
24
+ # ENV GRADIO_SERVER_NAME=0.0.0.0
25
+ # ENV GRADIO_SERVER_PORT=7860
26
+
27
+ # # Expose the port
28
+ # EXPOSE 7860
29
+
30
+ # # Command to run the application
31
+ # CMD ["python3", "app.py"]
32
  FROM nvidia/cuda:12.1.1-runtime-ubuntu22.04
33
  ENV DEBIAN_FRONTEND=noninteractive
34
 
 
40
  && apt-get clean \
41
  && rm -rf /var/lib/apt/lists/*
42
 
43
+ # Create a non-root user
44
+ RUN useradd -m -u 1000 user
45
+
46
  # Create a working directory
47
  WORKDIR /app
48
 
 
51
  RUN pip3 install --no-cache-dir -r requirements.txt
52
 
53
  # Copy the application code
54
+ COPY app.py download_model.py start.sh ./
55
+ RUN chmod +x start.sh
56
+
57
+ # Create cache directories with proper permissions
58
+ RUN mkdir -p /tmp/transformers_cache /tmp/hf_home /tmp/hf_hub_cache /tmp/matplotlib_config
59
+ RUN chown -R user:user /app /tmp/transformers_cache /tmp/hf_home /tmp/hf_hub_cache /tmp/matplotlib_config
60
+ RUN chmod 777 /tmp/transformers_cache /tmp/hf_home /tmp/hf_hub_cache /tmp/matplotlib_config
61
 
62
  # Set environment variables
63
  ENV PYTHONUNBUFFERED=1
64
  ENV GRADIO_SERVER_NAME=0.0.0.0
65
  ENV GRADIO_SERVER_PORT=7860
66
+ ENV TRANSFORMERS_CACHE=/tmp/transformers_cache
67
+ ENV HF_HOME=/tmp/hf_home
68
+ ENV HUGGINGFACE_HUB_CACHE=/tmp/hf_hub_cache
69
+ ENV MPLCONFIGDIR=/tmp/matplotlib_config
70
+
71
+ # Switch to non-root user
72
+ USER user
73
 
74
  # Expose the port
75
  EXPOSE 7860
76
 
77
  # Command to run the application
78
+ CMD ["./start.sh"]