File size: 1,825 Bytes
6a535cf
770d0fa
6a535cf
770d0fa
 
 
710e59a
 
770d0fa
 
e84eb9a
 
 
6a535cf
 
 
710e59a
 
 
e84eb9a
7f0a708
710e59a
7f0a708
e84eb9a
 
710e59a
 
 
7f0a708
6a535cf
 
770d0fa
6a535cf
 
770d0fa
6a535cf
 
770d0fa
710e59a
 
 
 
 
 
 
 
 
 
e84eb9a
 
 
 
 
 
6a535cf
 
770d0fa
710e59a
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
FROM python:3.10-slim

# Install system dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    git \
    libgl1-mesa-glx \
    libglib2.0-0 \
    && rm -rf /var/lib/apt/lists/*

# Create a user with explicit UID 1000 (common for first non-root user)
RUN useradd -m -u 1000 appuser

# Set working directory
WORKDIR /app

# Create directories with proper permissions
RUN mkdir -p /app/.triton /app/.torch_cache /app/tmp && \
    chmod 777 /app/tmp && \
    chown -R appuser:appuser /app

# Set environment variables for cache directories and temporary files
ENV TRITON_CACHE_DIR=/app/.triton
ENV TORCH_HOME=/app/.torch_cache
ENV TORCHINDUCTOR_CACHE_DIR=/app/.torch_cache/inductor
ENV TEMP=/app/tmp
ENV TMP=/app/tmp
ENV TMPDIR=/app/tmp

# Copy requirements first to leverage Docker cache
COPY requirements.txt .

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application
COPY . .

# Create .streamlit directory and config file
RUN mkdir -p /app/.streamlit
RUN echo '[server]\nheaderless = true\nenableCORS = false\nenableXsrfProtection = false' > /app/.streamlit/config.toml
RUN chown -R appuser:appuser /app/.streamlit

# Create a streamlit credentials file to avoid warnings
RUN mkdir -p /home/appuser/.streamlit
RUN echo '[general]\nemail = ""' > /home/appuser/.streamlit/credentials.toml
RUN chown -R appuser:appuser /home/appuser/.streamlit

# Ensure proper ownership of all files
RUN chown -R appuser:appuser /app

# Switch to the appuser
USER appuser

# Expose the port Streamlit runs on
EXPOSE 8501

# Command to run the application with explicit disable of CORS protection
CMD ["streamlit", "run", "app.py", "--server.address=0.0.0.0", "--server.enableCORS=false", "--server.enableXsrfProtection=false", "--server.maxUploadSize=50"]