File size: 1,262 Bytes
c6eb9ce
 
2db3081
c6eb9ce
2db3081
 
c6eb9ce
2db3081
 
c6eb9ce
 
2db3081
 
c6eb9ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2db3081
c6eb9ce
 
2db3081
c6eb9ce
 
2db3081
c6eb9ce
 
2db3081
c6eb9ce
 
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
# Use Python 3.11 slim image
FROM python:3.11-slim

# Set working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    git \
    curl \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# Install UV package manager
RUN pip install uv

# Copy UV configuration files first for better caching
COPY pyproject.toml uv.lock ./

# Install Python dependencies using UV
RUN uv venv /opt/venv && \
    . /opt/venv/bin/activate && \
    uv sync --frozen

# Set the virtual environment as the default Python
ENV PATH="/opt/venv/bin:$PATH"

# Copy application code
COPY . .

# Create a non-root user
RUN useradd -m -u 1000 user
USER user

# Set environment variables
ENV HOME=/home/user \
    PATH="/opt/venv/bin:/home/user/.local/bin:$PATH" \
    PYTHONPATH=/app

# Change to user's home directory
WORKDIR $HOME/app

# Copy app to user directory
COPY --chown=user . $HOME/app

# Expose the port Streamlit runs on
EXPOSE 7860

# Health check
HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health

# Run the Streamlit application
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0", "--server.headless=true", "--server.fileWatcherType=none", "--browser.gatherUsageStats=false"]