File size: 1,222 Bytes
38c0aff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23592d5
be91153
38c0aff
23592d5
 
 
be91153
38c0aff
 
 
23592d5
 
 
38c0aff
 
 
23592d5
 
 
38c0aff
 
 
23592d5
38c0aff
 
 
 
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
49
50
51
52
# Use Python 3.12 slim for a smaller image
FROM python:3.12-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PORT=7860

# Install system dependencies including Rust toolchain requirements and build tools
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    curl \
    git \
    pkg-config \
    libssl-dev \
    && rm -rf /var/lib/apt/lists/*

# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"

# Set the working directory
WORKDIR /app

# Copy the entire application early
COPY . .

# Ensure the user owns the app directory
RUN chown -R 1000:1000 /app

# Install Python dependencies and build the Rust engine
RUN pip install --no-cache-dir uv && \
    uv pip install --system --no-cache .

# Diagnostic: Verify files are present
RUN ls -la /app && ls -la /app/ai || echo "AI DIR MISSING"

# Compile card data
RUN python -m compiler.main

# Create a non-privileged user
RUN useradd -m -u 1000 user_tmp || true
USER 1000
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Expose the port
EXPOSE 7860

# Run the server
CMD ["python", "backend/server.py"]