Complete implementation of the Synor Storage Layer (L2) for decentralized content storage. This enables permanent, censorship-resistant storage of any file type including Next.js apps, Flutter apps, and arbitrary data. Core modules: - cid.rs: Content addressing with Blake3/SHA256 hashing (synor1... format) - chunker.rs: File chunking for parallel upload/download (1MB chunks) - erasure.rs: Reed-Solomon erasure coding (10+4 shards) for fault tolerance - proof.rs: Storage proofs with Merkle trees for verification - deal.rs: Storage deals and market economics (3 pricing tiers) Infrastructure: - node/: Storage node service with P2P networking and local storage - gateway/: HTTP gateway for browser access with LRU caching - Docker deployment with nginx load balancer Architecture: - Operates as L2 alongside Synor L1 blockchain - Storage proofs verified on-chain for reward distribution - Can lose 4 shards per chunk and still recover data - Gateway URLs: /synor1<cid> for content access All 28 unit tests passing.
74 lines
1.7 KiB
Docker
74 lines
1.7 KiB
Docker
# Synor Storage Node Dockerfile
|
|
# Multi-stage build for optimized production image
|
|
|
|
# Stage 1: Build
|
|
FROM rust:1.83-bookworm AS builder
|
|
|
|
WORKDIR /build
|
|
|
|
# Install dependencies for libp2p and rocksdb
|
|
RUN apt-get update && apt-get install -y \
|
|
cmake \
|
|
libclang-dev \
|
|
libssl-dev \
|
|
pkg-config \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy workspace files
|
|
COPY Cargo.toml Cargo.lock ./
|
|
COPY crates/ ./crates/
|
|
|
|
# Build the storage node binary
|
|
RUN cargo build --release -p synor-storage --bin synor-storage-node
|
|
|
|
# Stage 2: Runtime
|
|
FROM debian:bookworm-slim
|
|
|
|
RUN apt-get update && apt-get install -y \
|
|
ca-certificates \
|
|
libssl3 \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create non-root user
|
|
RUN useradd -m -u 1000 synor
|
|
|
|
# Create data directories
|
|
RUN mkdir -p /data/storage /config && chown -R synor:synor /data /config
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy the built binary
|
|
COPY --from=builder /build/target/release/synor-storage-node /app/synor-storage-node
|
|
|
|
# Copy configuration template
|
|
COPY docker/storage-node/config.toml /config/config.toml
|
|
|
|
# Make binary executable
|
|
RUN chmod +x /app/synor-storage-node && chown synor:synor /app/synor-storage-node
|
|
|
|
USER synor
|
|
|
|
# Storage node ports
|
|
# 4001: P2P (libp2p)
|
|
# 5001: API (internal)
|
|
# 8080: Gateway (HTTP)
|
|
EXPOSE 4001 5001 8080
|
|
|
|
# Environment defaults
|
|
ENV RUST_LOG=info
|
|
ENV DATA_DIR=/data/storage
|
|
ENV GATEWAY_ENABLED=true
|
|
ENV GATEWAY_ADDR=0.0.0.0:8080
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
CMD curl -f http://localhost:8080/health || exit 1
|
|
|
|
# Data volume
|
|
VOLUME ["/data/storage"]
|
|
|
|
# Entry point
|
|
ENTRYPOINT ["/app/synor-storage-node"]
|
|
CMD ["--config", "/config/config.toml", "--data-dir", "/data/storage"]
|