File size: 1,198 Bytes
c64c726
 
 
 
 
 
e515409
 
 
 
 
 
 
c64c726
 
 
 
 
 
 
 
745484d
 
c64c726
 
 
745484d
 
 
5a63400
 
 
745484d
 
 
 
c64c726
 
 
 
 
 
 
 
 
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
# Use Python 3.9 slim image
FROM python:3.9-slim

# Set working directory
WORKDIR /app

# Copy requirements and packages list for better caching
COPY packages.txt requirements.txt ./

# Install system dependencies from packages.txt (HuggingFace Spaces compatible)
RUN apt-get update && \
    xargs -r -a packages.txt apt-get install -y && \
    rm -rf /var/lib/apt/lists/*

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy source code
COPY . .

# Create necessary directories
RUN mkdir -p csgo/spawn config checkpoints cache && \
    mkdir -p /tmp/torch /tmp/huggingface /tmp/transformers

# Set environment variables
ENV PYTHONPATH=/app/src:/app
ENV OMP_NUM_THREADS=2
ENV MKL_NUM_THREADS=2

# Don't set CUDA_VISIBLE_DEVICES="" - let HF Spaces GPU be detected
# ENV CUDA_VISIBLE_DEVICES=""  # Removed - this disables GPU!

# Set cache directories to writable locations
ENV TORCH_HOME=/tmp/torch
ENV HF_HOME=/tmp/huggingface
ENV TRANSFORMERS_CACHE=/tmp/transformers

# Expose port
EXPOSE 7860

# Health check
HEALTHCHECK CMD curl --fail http://localhost:7860/ || exit 1

# Run the application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]