File size: 2,487 Bytes
969d89a
 
 
 
de31f38
969d89a
de31f38
969d89a
 
 
 
 
 
50c981b
 
67834d2
b03a9b5
50c981b
 
 
 
eea83f8
50c981b
eea83f8
 
 
 
50c981b
 
 
 
 
 
 
 
 
 
7269025
769f59f
 
 
 
7269025
50c981b
 
 
 
7269025
50c981b
 
 
 
 
 
 
cdd854f
 
 
 
 
50c981b
 
 
cdd854f
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
53
54
55
56
57
58
59
60
61
62
63
64
65
FROM ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive

# Install Python 3.12, pip, curl, build-essential, cmake, and SSL dev libraries for Rust
RUN apt-get update && apt-get install -y \
    python3 python3-pip python3-venv curl build-essential cmake pkg-config libssl-dev \
    && rm -rf /var/lib/apt/lists/*

# Create a virtual environment so pip installs work smoothly
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

# Set up a new user named "user" with user ID 1000 (Required for HF Spaces)
# Ubuntu 24.04 comes with a default "ubuntu" user with UID 1000. We must delete it first to avoid conflicts.
RUN userdel -r ubuntu || true && useradd -m -u 1000 user && chown -R user:user /opt/venv

# Switch to the "user" user
USER user

# Set home to the user's home directory and add Rust/Cargo to PATH
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:/home/user/.cargo/bin:$PATH

# Install Rust for the specific user
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y

# Set the working directory to the user's home directory
WORKDIR $HOME/app

# Copy the current directory contents into the container at $HOME/app setting the owner to the user
COPY --chown=user . $HOME/app

# Build the Rust engine
RUN cd neural_engine && cargo build --release

# Download all model weights from our model repository directly into the root folder
RUN curl -L -o ./model.onnx "https://huggingface.co/dpv007/Neurex-Weights/resolve/main/model.onnx?v=5" || true
RUN curl -L -o ./model.onnx.data "https://huggingface.co/dpv007/Neurex-Weights/resolve/main/model.onnx.data?v=5" || true
RUN curl -L -o ./model_int8.onnx "https://huggingface.co/dpv007/Neurex-Weights/resolve/main/model_int8.onnx?v=5" || true
RUN curl -L -o ./model_int8.onnx.data "https://huggingface.co/dpv007/Neurex-Weights/resolve/main/model_int8.onnx.data?v=5" || true

# Prepare the Neurex_Engine folder
RUN mkdir -p Neurex_Engine && \
    cp neural_engine/target/release/neural_engine Neurex_Engine/Neurex && \
    cp model.onnx Neurex_Engine/ || true && \
    cp model_int8.onnx Neurex_Engine/ || true && \
    cp vocab.json Neurex_Engine/ || true

# Make engines executable
RUN chmod +x Neurex_Engine/Neurex && \
    chmod +x VeloCT_Ultimate || true

# Install requirements
RUN pip install --no-cache-dir -r requirements.txt && \
    pip install --no-cache-dir -r lichess-bot/requirements.txt

# Copy and make start script executable
RUN chmod +x start.sh

EXPOSE 7860

CMD ["./start.sh"]