davanstrien HF Staff commited on
Commit
52ba85b
·
1 Parent(s): f0f897c

Update Dockerfile to specify Python 3.12 base image and enhance virtual environment setup

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -6
Dockerfile CHANGED
@@ -1,5 +1,5 @@
1
- # FROM python:3.13-slim
2
- FROM ghcr.io/astral-sh/uv:bookworm-slim
3
  # Set proper terminal environment for Textual
4
  ENV TERM=xterm-256color
5
  ENV COLORTERM=truecolor
@@ -8,24 +8,29 @@ ENV PYTHONUNBUFFERED=1
8
  # HF Spaces will set SPACE_HOST automatically, but we can provide a fallback
9
  ENV SPACE_HOST=${SPACE_HOST:-http://localhost:7860}
10
 
11
- # Install system dependencies
12
  RUN apt-get update && apt-get install -y \
13
- gcc \
14
  git \
15
  && rm -rf /var/lib/apt/lists/*
16
 
17
  # Create app directory
18
  WORKDIR /app
19
 
20
- # Copy requirements and install Python dependencies
 
 
 
21
  COPY requirements.txt .
22
  RUN uv pip install -r requirements.txt
23
 
24
  # Copy application files
25
  COPY serve.py .
26
 
 
 
 
27
  # Expose the port that HF Spaces expects
28
  EXPOSE 7860
29
 
30
- # Run the server
31
  CMD ["python", "serve.py"]
 
1
+ FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
2
+
3
  # Set proper terminal environment for Textual
4
  ENV TERM=xterm-256color
5
  ENV COLORTERM=truecolor
 
8
  # HF Spaces will set SPACE_HOST automatically, but we can provide a fallback
9
  ENV SPACE_HOST=${SPACE_HOST:-http://localhost:7860}
10
 
11
+ # Install system dependencies (git needed for GitHub installs)
12
  RUN apt-get update && apt-get install -y \
 
13
  git \
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
  # Create app directory
17
  WORKDIR /app
18
 
19
+ # Create a virtual environment using uv
20
+ RUN uv venv .venv
21
+
22
+ # Copy requirements and install Python dependencies into the venv
23
  COPY requirements.txt .
24
  RUN uv pip install -r requirements.txt
25
 
26
  # Copy application files
27
  COPY serve.py .
28
 
29
+ # Activate the virtual environment by putting it in PATH
30
+ ENV PATH="/app/.venv/bin:$PATH"
31
+
32
  # Expose the port that HF Spaces expects
33
  EXPOSE 7860
34
 
35
+ # Run the server with the venv's Python
36
  CMD ["python", "serve.py"]