Files
spacedrive/apps/server/Dockerfile
Jamie Pine 4db6a83a45 refactor(Docker): remove legacy Docker setup and streamline server deployment
This commit removes the outdated Dockerfile, docker-compose.yml, and related documentation for the Spacedrive server, consolidating the deployment process into a single Dockerfile located in the apps/server directory. The new setup supports multi-architecture builds and includes enhanced media processing capabilities. Additionally, a self-hosting guide is introduced to assist users in deploying the server on their infrastructure, ensuring a more efficient and user-friendly experience.
2026-01-11 20:14:29 -08:00

88 lines
1.9 KiB
Docker

# 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"
WORKDIR /build
# Copy workspace configuration
COPY Cargo.toml Cargo.lock ./
COPY .cargo ./.cargo
# Copy source code
COPY core ./core
COPY crates ./crates
COPY apps/server ./apps/server
# Build server with media processing features
RUN --mount=type=cache,target=/root/.cargo/registry \
--mount=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"]