saakshigupta commited on
Commit
710e59a
·
verified ·
1 Parent(s): 670d913

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -5
Dockerfile CHANGED
@@ -4,6 +4,8 @@ FROM python:3.10-slim
4
  RUN apt-get update && apt-get install -y \
5
  build-essential \
6
  git \
 
 
7
  && rm -rf /var/lib/apt/lists/*
8
 
9
  # Create a user with explicit UID 1000 (common for first non-root user)
@@ -12,14 +14,18 @@ RUN useradd -m -u 1000 appuser
12
  # Set working directory
13
  WORKDIR /app
14
 
15
- # Create directories for various caches with proper permissions
16
- RUN mkdir -p /app/.triton /app/.torch_cache && \
 
17
  chown -R appuser:appuser /app
18
 
19
- # Set environment variables for cache directories
20
  ENV TRITON_CACHE_DIR=/app/.triton
21
  ENV TORCH_HOME=/app/.torch_cache
22
  ENV TORCHINDUCTOR_CACHE_DIR=/app/.torch_cache/inductor
 
 
 
23
 
24
  # Copy requirements first to leverage Docker cache
25
  COPY requirements.txt .
@@ -30,6 +36,16 @@ RUN pip install --no-cache-dir -r requirements.txt
30
  # Copy the rest of the application
31
  COPY . .
32
 
 
 
 
 
 
 
 
 
 
 
33
  # Ensure proper ownership of all files
34
  RUN chown -R appuser:appuser /app
35
 
@@ -39,5 +55,5 @@ USER appuser
39
  # Expose the port Streamlit runs on
40
  EXPOSE 8501
41
 
42
- # Command to run the application
43
- CMD ["streamlit", "run", "app.py", "--server.address", "0.0.0.0"]
 
4
  RUN apt-get update && apt-get install -y \
5
  build-essential \
6
  git \
7
+ libgl1-mesa-glx \
8
+ libglib2.0-0 \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
  # Create a user with explicit UID 1000 (common for first non-root user)
 
14
  # Set working directory
15
  WORKDIR /app
16
 
17
+ # Create directories with proper permissions
18
+ RUN mkdir -p /app/.triton /app/.torch_cache /app/tmp && \
19
+ chmod 777 /app/tmp && \
20
  chown -R appuser:appuser /app
21
 
22
+ # Set environment variables for cache directories and temporary files
23
  ENV TRITON_CACHE_DIR=/app/.triton
24
  ENV TORCH_HOME=/app/.torch_cache
25
  ENV TORCHINDUCTOR_CACHE_DIR=/app/.torch_cache/inductor
26
+ ENV TEMP=/app/tmp
27
+ ENV TMP=/app/tmp
28
+ ENV TMPDIR=/app/tmp
29
 
30
  # Copy requirements first to leverage Docker cache
31
  COPY requirements.txt .
 
36
  # Copy the rest of the application
37
  COPY . .
38
 
39
+ # Create .streamlit directory and config file
40
+ RUN mkdir -p /app/.streamlit
41
+ RUN echo '[server]\nheaderless = true\nenableCORS = false\nenableXsrfProtection = false' > /app/.streamlit/config.toml
42
+ RUN chown -R appuser:appuser /app/.streamlit
43
+
44
+ # Create a streamlit credentials file to avoid warnings
45
+ RUN mkdir -p /home/appuser/.streamlit
46
+ RUN echo '[general]\nemail = ""' > /home/appuser/.streamlit/credentials.toml
47
+ RUN chown -R appuser:appuser /home/appuser/.streamlit
48
+
49
  # Ensure proper ownership of all files
50
  RUN chown -R appuser:appuser /app
51
 
 
55
  # Expose the port Streamlit runs on
56
  EXPOSE 8501
57
 
58
+ # Command to run the application with explicit disable of CORS protection
59
+ CMD ["streamlit", "run", "app.py", "--server.address=0.0.0.0", "--server.enableCORS=false", "--server.enableXsrfProtection=false", "--server.maxUploadSize=50"]