StudioSaiens commited on
Commit
86cc085
·
verified ·
1 Parent(s): 9486a0e

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +42 -0
Dockerfile ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 1. Start with a CUDA-enabled base image (Required for Unsloth to utilize GPUs properly)
2
+ FROM nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04
3
+
4
+ # 2. Avoid interactive timezone/keyboard prompts during apt installation
5
+ ENV DEBIAN_FRONTEND=noninteractive
6
+
7
+ # 3. Install core system dependencies required by Unsloth's install.sh
8
+ RUN apt-get update && apt-get install -y \
9
+ curl \
10
+ git \
11
+ python3 \
12
+ python3-pip \
13
+ python3-venv \
14
+ build-essential \
15
+ nodejs \
16
+ npm \
17
+ && rm -rf /var/lib/apt/lists/*
18
+
19
+ # 4. Hugging Face Spaces require running containers as a non-root user (UID 1000)
20
+ RUN useradd -m -u 1000 user
21
+ USER user
22
+
23
+ # 5. Set environment variables
24
+ ENV HOME=/home/user
25
+ # Ensure the newly installed Unsloth CLI binary is in the system PATH
26
+ ENV PATH="$HOME/.local/bin:$PATH"
27
+ # Point Hugging Face model cache to /data so you can use Persistent Storage without overriding the installation
28
+ ENV HF_HOME=/data/huggingface
29
+
30
+ WORKDIR $HOME
31
+
32
+ # 6. Execute the official Unsloth installation script.
33
+ # This will download PyTorch, Unsloth, Node/Bun, and compile the frontend during the Docker build.
34
+ RUN curl -fsSL https://unsloth.ai/install.sh | sh
35
+
36
+ # 7. Expose the port we defined in our README.md
37
+ EXPOSE 7860
38
+
39
+ # 8. Start the Unsloth Studio server
40
+ # -H 0.0.0.0 : Binds the server to all network interfaces (required for Docker/HF Spaces)
41
+ # -p 7860 : Binds it to the Hugging Face expected port
42
+ CMD ["unsloth", "studio", "-H", "0.0.0.0", "-p", "7860"]