forked from hongkongkiwi/docx-mcp
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
95 lines (73 loc) · 3.14 KB
/
Dockerfile
File metadata and controls
95 lines (73 loc) · 3.14 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
# =============================================================================
# docx-mcp Full Stack Dockerfile
# Builds MCP server and CLI with embedded Rust storage (single binary)
# =============================================================================
# Stage 1: Build Rust staticlib
FROM rust:1.93-slim-bookworm AS rust-builder
WORKDIR /rust
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
protobuf-compiler \
&& rm -rf /var/lib/apt/lists/*
# Copy Rust workspace files
COPY Cargo.toml Cargo.lock ./
COPY proto/ ./proto/
COPY crates/ ./crates/
# Build the staticlib for embedding
RUN --mount=type=cache,id=cargo-mcp,target=/usr/local/cargo/registry \
cargo build --release --package docx-storage-local --lib
# Stage 2: Build .NET MCP server and CLI with embedded Rust storage
FROM mcr.microsoft.com/dotnet/sdk:10.0-preview AS dotnet-builder
# NativeAOT requires clang as the platform linker
RUN apt-get update && \
apt-get install -y --no-install-recommends clang zlib1g-dev && \
rm -rf /var/lib/apt/lists/*
WORKDIR /src
# Copy Rust staticlib from builder
COPY --from=rust-builder /rust/target/release/libdocx_storage_local.a /rust-lib/
# Copy .NET source
COPY DocxMcp.sln ./
COPY proto/ ./proto/
COPY src/ ./src/
COPY tests/ ./tests/
# Build MCP server with embedded storage
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \
dotnet publish src/DocxMcp/DocxMcp.csproj \
--configuration Release \
-p:RustStaticLibPath=/rust-lib/libdocx_storage_local.a \
-o /app
# Build CLI with embedded storage
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \
dotnet publish src/DocxMcp.Cli/DocxMcp.Cli.csproj \
--configuration Release \
-p:RustStaticLibPath=/rust-lib/libdocx_storage_local.a \
-o /app/cli
# Stage 3: Runtime (single binary, no separate storage process)
FROM mcr.microsoft.com/dotnet/runtime-deps:10.0-preview AS runtime
# Install curl (health checks) and grpcurl (gRPC debugging)
RUN apt-get update && \
apt-get install -y --no-install-recommends curl ca-certificates && \
ARCH=$(dpkg --print-architecture) && \
case "$ARCH" in amd64) GRPC_ARCH=x86_64 ;; arm64) GRPC_ARCH=arm64 ;; *) GRPC_ARCH=x86_64 ;; esac && \
curl -sL "https://github.com/fullstorydev/grpcurl/releases/download/v1.9.1/grpcurl_1.9.1_linux_${GRPC_ARCH}.tar.gz" | tar xz -C /usr/local/bin grpcurl && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy binaries from builder (no docx-storage-local needed!)
COPY --from=dotnet-builder /app/docx-mcp ./
COPY --from=dotnet-builder /app/cli/docx-cli ./
# Create directories
RUN mkdir -p /app/data && \
chown -R app:app /app/data
# Volumes for data persistence
VOLUME /app/data
USER app
# Environment variables
ENV LOCAL_STORAGE_DIR=/app/data
# Default entrypoint is the MCP server
ENTRYPOINT ["./docx-mcp"]
# =============================================================================
# Alternative entrypoints:
# - CLI: docker run --entrypoint ./docx-cli ...
# - Remote storage mode: docker run -e STORAGE_GRPC_URL=http://host:50051 ...
# =============================================================================