-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.worker.gpu
More file actions
121 lines (100 loc) · 3.32 KB
/
Dockerfile.worker.gpu
File metadata and controls
121 lines (100 loc) · 3.32 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# =============================================================================
# BitSage GPU Worker - Production Docker Image
# =============================================================================
#
# One-command deployment:
# docker compose -f docker-compose.worker.yml up
#
# Features:
# - NVIDIA CUDA 12.4 runtime
# - GPU-accelerated STWO proving (50-174x speedup)
# - Auto wallet generation (account abstraction)
# - Auto faucet claim (testnet)
# - Auto coordinator registration
#
# =============================================================================
# -----------------------------------------------------------------------------
# Stage 1: Build
# -----------------------------------------------------------------------------
FROM rust:1.77-bookworm AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
pkg-config \
libssl-dev \
libpq-dev \
clang \
libclang-dev \
protobuf-compiler \
cmake \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
# Copy Cargo files first (for caching)
COPY Cargo.toml Cargo.lock ./
COPY ../libs ./libs
# Create dummy src for dependency caching
RUN mkdir -p src/bin && \
echo "fn main() {}" > src/bin/sage_worker.rs && \
echo "pub fn dummy() {}" > src/lib.rs
# Build dependencies (cached layer)
RUN cargo build --release --bin sage-worker 2>/dev/null || true
# Copy actual source
COPY src ./src
COPY migrations ./migrations
COPY config ./config
# Build the real binary
RUN cargo build --release --bin sage-worker && \
cp target/release/sage-worker /sage-worker && \
strip /sage-worker
# Also build proof CLI
RUN cargo build --release --bin bitsage-proof && \
cp target/release/bitsage-proof /bitsage-proof && \
strip /bitsage-proof
# -----------------------------------------------------------------------------
# Stage 2: Runtime with CUDA
# -----------------------------------------------------------------------------
FROM nvidia/cuda:12.4-runtime-ubuntu22.04
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
libpq5 \
curl \
jq \
openssl \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd -m -s /bin/bash -u 1000 bitsage
# Copy binaries
COPY --from=builder /sage-worker /usr/local/bin/sage-worker
COPY --from=builder /bitsage-proof /usr/local/bin/bitsage-proof
# Copy entrypoint script
COPY scripts/docker-entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# Create directories
RUN mkdir -p /app/data /app/keys /app/config && \
chown -R bitsage:bitsage /app
# Copy default config
COPY config/worker.toml /app/config/worker.toml 2>/dev/null || true
# Environment defaults
ENV RUST_LOG=info \
BITSAGE_NETWORK=sepolia \
COORDINATOR_URL=https://coordinator.bitsage.network \
STARKNET_RPC_URL=https://rpc.starknet-testnet.lava.build \
AUTO_SETUP=true \
AUTO_WALLET=true \
AUTO_FAUCET=true \
AUTO_REGISTER=true \
GPU_ENABLED=true \
CONFIG_DIR=/app/data \
KEYS_DIR=/app/keys
# Expose ports
EXPOSE 8081 9001
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:8081/health || exit 1
# Run as non-root
USER bitsage
WORKDIR /app
# Entrypoint handles all auto-setup
ENTRYPOINT ["/entrypoint.sh"]