wolf1997 commited on
Commit
8dc6099
·
verified ·
1 Parent(s): b082984

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -14
Dockerfile CHANGED
@@ -1,33 +1,37 @@
1
- # Use Python 3.13.2 slim image for efficiency
2
  FROM python:3.13.2-slim
3
 
4
- # Install system dependencies and uv
5
  RUN apt-get update && apt-get install -y \
6
- git \
 
7
  curl \
 
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
  # Install uv
11
  COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
12
 
13
- # Set working directory
14
- WORKDIR /app
 
15
 
16
- # Set environment variables
17
- ENV PYTHONUNBUFFERED=1
18
- ENV PYTHONDONTWRITEBYTECODE=1
19
 
20
- # Copy project configuration files first to leverage Docker layer caching
21
- COPY pyproject.toml uv.lock ./
 
 
 
22
 
23
  # Install Python dependencies using uv
24
  RUN uv sync --frozen --no-dev
25
 
26
- # Copy application files
27
- COPY src/ ./src/
28
 
29
- # Create directories that might be needed
30
- RUN mkdir -p notebooks
31
 
32
  # Expose the port that Gradio will run on
33
  EXPOSE 7860
 
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
+ # Copy pyproject.toml and uv.lock first to leverage Docker cache
27
+ COPY --chown=user:user pyproject.toml uv.lock ./
28
 
29
  # Install Python dependencies using uv
30
  RUN uv sync --frozen --no-dev
31
 
32
+ # Copy the application code
33
+ COPY --chown=user:user . $HOME/app
34
 
 
 
35
 
36
  # Expose the port that Gradio will run on
37
  EXPOSE 7860