generated from opentensor/bittensor-subnet-template
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathDockerfile
54 lines (41 loc) · 1.38 KB
/
Dockerfile
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
# Build stage for compiling dependencies
FROM --platform=linux/amd64 python:3.12-slim as builder
# Upgrade pip
RUN pip install --no-cache-dir --upgrade pip
# Install build dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
build-essential \
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 working directory
WORKDIR /app
# Copy requirements
COPY requirements.txt .
# Install CPU-only PyTorch first to avoid duplicate installations
RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
# Install remaining dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Final stage
FROM --platform=linux/amd64 python:3.12-slim
# Install runtime dependencies only
RUN apt-get update && apt-get install -y \
libssl-dev \
git \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy installed packages from builder
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONPATH=/app \
USE_TORCH=1
# Command to run the application
CMD ["sh", "-c", "python -m neurons.${ROLE}"]