wolf1997 commited on
Commit
a2d3ad3
·
verified ·
1 Parent(s): 43c856b

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +34 -28
Dockerfile CHANGED
@@ -1,38 +1,44 @@
1
- # Use Python 3.13 slim image as base
2
  FROM python:3.13.2-slim
3
 
4
- # Set working directory
5
- WORKDIR /app
6
-
7
- # Set environment variables
8
- ENV PYTHONDONTWRITEBYTECODE=1 \
9
- PYTHONUNBUFFERED=1 \
10
- STREAMLIT_SERVER_PORT=8501 \
11
- STREAMLIT_SERVER_ADDRESS=0.0.0.0 \
12
- UV_CACHE_DIR=/tmp/uv-cache
13
-
14
- # Install system dependencies and uv
15
  RUN apt-get update && apt-get install -y \
16
- build-essential \
 
17
  curl \
18
- && rm -rf /var/lib/apt/lists/* \
19
- && curl -LsSf https://astral.sh/uv/install.sh | sh \
20
- && /root/.cargo/bin/uv --version
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
- # Add uv to PATH
23
- ENV PATH="/root/.cargo/bin:$PATH"
 
24
 
25
- # Copy project files
26
- COPY pyproject.toml uv.lock* ./
27
 
28
- # Install dependencies using uv with full path to ensure it's found
29
- RUN /root/.cargo/bin/uv sync --frozen --no-dev
30
 
31
- # Copy the rest of the application
32
- COPY . .
33
 
34
- # Expose the port Streamlit runs on
35
- EXPOSE 8501
 
36
 
37
- # Command to run the application using uv
38
- CMD ["uv", "run", "streamlit", "run", "app.py"]
 
1
+ # Use Python 3.13.2 as the base image
2
  FROM python:3.13.2-slim
3
 
4
+ # Install system dependencies as root first
 
 
 
 
 
 
 
 
 
 
5
  RUN apt-get update && apt-get install -y \
6
+ gcc \
7
+ g++ \
8
  curl \
9
+ build-essential \
10
+ && rm -rf /var/lib/apt/lists/*
11
+
12
+ # Install uv
13
+ COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
14
+
15
+ # Create user after system packages are installed
16
+ RUN useradd -m -u 1000 user
17
+ USER user
18
+
19
+ # Set home to the user's home directory
20
+ ENV HOME=/home/user \
21
+ PATH=/home/user/.local/bin:$PATH
22
+
23
+ # Set the working directory
24
+ WORKDIR $HOME/app
25
 
26
+ # Create directories with proper permissions for app data
27
+ RUN mkdir -p $HOME/app/logs $HOME/app/data $HOME/app/tmp && \
28
+ chmod -R 755 $HOME/app
29
 
30
+ # Copy pyproject.toml and uv.lock first to leverage Docker cache
31
+ COPY --chown=user:user pyproject.toml uv.lock ./
32
 
33
+ # Install Python dependencies using uv
34
+ RUN uv sync --frozen --no-dev
35
 
36
+ # Copy the application code
37
+ COPY --chown=user:user . $HOME/app
38
 
39
+ # Ensure all app files have proper permissions
40
+ RUN chmod -R 755 $HOME/app && \
41
+ find $HOME/app -type f -name "*.py" -exec chmod 644 {} \;
42
 
43
+ # Expose the port the app runs on
44
+ EXPOSE 8000