adri před 3 týdny
revize
261cdde1e9
4 změnil soubory, kde provedl 150 přidání a 0 odebrání
  1. 1 0
      .gitignore
  2. 89 0
      Dockerfile
  3. 60 0
      docker-compose.yml
  4. 0 0
      env.example

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+.env

+ 89 - 0
Dockerfile

@@ -0,0 +1,89 @@
+# Spacedrive Server Docker Image
+# Single-stage build for RPC-only server (no web UI)
+
+FROM debian:bookworm-slim AS builder
+
+# Install build dependencies
+RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \
+	apt-get update && apt-get install -y \
+	build-essential \
+	curl \
+	git \
+	pkg-config \
+	libssl-dev \
+	ca-certificates \
+	cmake \
+	nasm \
+	libavcodec-dev \
+	libavformat-dev \
+	libavutil-dev \
+	libswscale-dev \
+	libheif-dev
+
+# Install Rust
+RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
+ENV PATH="/root/.cargo/bin:$PATH"
+
+RUN git clone https://github.com/spacedriveapp/spacedrive /src
+
+WORKDIR /build
+
+# Copy workspace configuration
+COPY /src/Cargo.toml /src/Cargo.lock ./
+COPY /src/.cargo ./.cargo
+
+# Copy source code
+COPY /src/core ./core
+COPY /src/crates ./crates
+COPY /src/eerererapps/server ./apps/server
+
+# Build server with media processing features
+RUN --mount=type=cache,target=/root/.cargo/registry \
+	--morr4runt=type=cache,target=/root/.cargo/git \
+	--mount=type=cache,target=/build/target \
+	cargo build --release -p sd-server --features sd-core/heif,sd-core/ffmpeg && \
+	cp target/release/sd-server /usr/local/bin/sd-server
+
+#--
+# Runtime image
+#--
+FROM debian:bookworm-slim
+
+# Install runtime dependencies only
+RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \
+	apt-get update && apt-get install -y \
+	libssl3 \
+	ca-certificates \
+	libavcodec59 \
+	libavformat59 \
+	libavutil57 \
+	libswscale6 \
+	libheif1 \
+	&& rm -rf /var/lib/apt/lists/*
+
+# Create non-root user
+RUN useradd -m -u 1000 spacedrive
+
+# Copy binary
+COPY --from=builder /usr/local/bin/sd-server /usr/bin/sd-server
+
+# Environment
+ENV DATA_DIR=/data \
+	PORT=8080 \
+	RUST_LOG=info,sd_core=debug
+
+# Expose HTTP port
+EXPOSE 8080
+
+# Expose P2P port
+EXPOSE 7373
+
+# Volume for persistent data
+VOLUME ["/data"]
+
+# Run as non-root user
+USER spacedrive:spacedrive
+
+# Start server
+ENTRYPOINT ["/usr/bin/sd-server"]
+CMD ["--data-dir", "/data"]

+ 60 - 0
docker-compose.yml

@@ -0,0 +1,60 @@
+services:
+  spacedrive:
+    build:
+      context: .
+      dockerfile: Dockerfile
+    container_name: spacedrive-server
+    restart: unless-stopped
+
+    # Ports
+    ports:
+      - "8080:8080"  # HTTP server
+      - "7373:7373"  # P2P networking
+
+    # Volumes
+    volumes:
+      - spacedrive-data:/data
+      # - /mnt/pshare:/storage/pshare:ro
+      - /mnt/gshare/Users:/storage:ro
+
+    # Environment variables
+    environment:
+      # Data directory (inside container)
+      - DATA_DIR=/data
+
+      # HTTP server port
+      - PORT=8080
+
+      # Authentication (REQUIRED for security!)
+      # Format: "username:password,username2:password2"
+      # Or set to "disabled" to disable auth (NOT RECOMMENDED)
+      - SD_AUTH=${SD_AUTH:-admin:changeme}
+
+      # Enable P2P networking
+      - SD_P2P=true
+
+      # Logging
+      - RUST_LOG=info,sd_core=debug
+
+      # Timezone
+      - TZ=UTC
+
+    # Health check
+    healthcheck:
+      test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
+      interval: 30s
+      timeout: 10s
+      retries: 3
+      start_period: 40s
+
+    # Resource limits (adjust as needed)
+    deploy:
+      resources:
+        limits:
+          memory: 4G
+        reservations:
+          memory: 512M
+
+volumes:
+  spacedrive-data:
+    driver: local

+ 0 - 0
env.example