trioskosmos commited on
Commit
38c0aff
·
verified ·
1 Parent(s): 3da000a

Upload Dockerfile with huggingface_hub

Browse files
Files changed (1) hide show
  1. Dockerfile +53 -0
Dockerfile ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use Python 3.12 slim for a smaller image
2
+ FROM python:3.12-slim
3
+
4
+ # Set environment variables
5
+ ENV PYTHONDONTWRITEBYTECODE=1
6
+ ENV PYTHONUNBUFFERED=1
7
+ ENV PORT=7860
8
+
9
+ # Install system dependencies including Rust toolchain requirements and build tools
10
+ RUN apt-get update && apt-get install -y --no-install-recommends \
11
+ build-essential \
12
+ curl \
13
+ git \
14
+ pkg-config \
15
+ libssl-dev \
16
+ && rm -rf /var/lib/apt/lists/*
17
+
18
+ # Install Rust
19
+ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
20
+ ENV PATH="/root/.cargo/bin:${PATH}"
21
+
22
+ # Set the working directory
23
+ WORKDIR /app
24
+
25
+ # Copy dependency files
26
+ COPY pyproject.toml ./
27
+
28
+ # Install Python dependencies
29
+ # Using uv for faster builds
30
+ RUN pip install --no-cache-dir uv && \
31
+ uv pip install --system --no-cache .
32
+
33
+ # Copy the rest of the application
34
+ COPY . .
35
+
36
+ # Build the Rust engine
37
+ RUN maturin develop --manifest-path engine_rust_src/Cargo.toml --release
38
+
39
+ # Compile card data
40
+ RUN python -m compiler.main
41
+
42
+ # Create a non-privileged user (required for some HF Space environments)
43
+ RUN useradd -m -u 1000 user
44
+ USER user
45
+ ENV HOME=/home/user \
46
+ PATH=/home/user/.local/bin:$PATH
47
+
48
+ # Expose the port used by Hugging Face Spaces
49
+ EXPOSE 7860
50
+
51
+ # Run the server
52
+ # HF Spaces expects the app to listen on 0.0.0.0:7860
53
+ CMD ["python", "backend/server.py"]