File size: 1,334 Bytes
e3abc09
8981d3d
 
 
d995e98
8981d3d
 
 
 
 
7df36af
8981d3d
 
d995e98
 
 
 
 
 
 
 
 
6f52efc
d995e98
8981d3d
d995e98
 
 
 
 
6f52efc
6bc1136
d995e98
 
 
 
 
 
6bc1136
d995e98
 
8981d3d
 
 
 
 
d995e98
 
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
FROM python:3.12-slim

WORKDIR /app

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

# Create a non-root user
RUN groupadd --gid 1000 appuser && \
    useradd --uid 1000 --gid 1000 --create-home --shell /bin/bash appuser

# Set UV environment variables to use writable cache locations
ENV UV_CACHE_DIR=/tmp/uv-cache
ENV UV_TOOL_DIR=/tmp/uv-tools
ENV UV_PYTHON_INSTALL_DIR=/tmp/uv-python

# Install UV
RUN pip3 install uv

# Create cache directories with proper permissions
RUN mkdir -p /tmp/uv-cache /tmp/uv-tools /tmp/uv-python && \
    chown -R appuser:appuser /tmp/uv-cache /tmp/uv-tools /tmp/uv-python

# Copy requirements first for better Docker layer caching
COPY requirements.txt ./

# Switch to non-root user
USER appuser

# Create virtual environment and install dependencies
RUN uv venv /home/appuser/.venv
RUN uv pip install -r requirements.txt

# Copy application code
COPY --chown=appuser:appuser src/ ./src/

EXPOSE 8501

HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health

# Use the virtual environment directly
ENTRYPOINT ["/home/appuser/.venv/bin/python", "-m", "streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]