/ Dockerfile
Dockerfile
 1  # Multi-stage build for optimal image size
 2  # Stage 1: Builder
 3  FROM rust:1.75-slim as builder
 4  
 5  # Install build dependencies
 6  RUN apt-get update && apt-get install -y \
 7      pkg-config \
 8      libssl-dev \
 9      git \
10      && rm -rf /var/lib/apt/lists/*
11  
12  # Create app directory
13  WORKDIR /usr/src/gramr
14  
15  # Copy manifests
16  COPY Cargo.toml Cargo.lock ./
17  COPY lib/Cargo.toml lib/
18  COPY cli/Cargo.toml cli/
19  COPY wotan/Cargo.toml wotan/
20  COPY gramrup/Cargo.toml gramrup/
21  
22  # Copy source code
23  COPY lib/src lib/src
24  COPY cli/src cli/src
25  COPY wotan/src wotan/src
26  COPY gramrup/src gramrup/src
27  
28  # Build for release
29  RUN cargo build --release --all
30  
31  # Stage 2: Runtime
32  FROM debian:bookworm-slim
33  
34  # Install runtime dependencies
35  RUN apt-get update && apt-get install -y \
36      ca-certificates \
37      git \
38      curl \
39      && rm -rf /var/lib/apt/lists/*
40  
41  # Install Foundry
42  RUN curl -L https://foundry.paradigm.xyz | bash && \
43      /root/.foundry/bin/foundryup
44  
45  # Copy binaries from builder
46  COPY --from=builder /usr/src/gramr/target/release/gramr /usr/local/bin/
47  COPY --from=builder /usr/src/gramr/target/release/wotan /usr/local/bin/
48  COPY --from=builder /usr/src/gramr/target/release/gramrup /usr/local/bin/
49  
50  # Add foundry to PATH
51  ENV PATH="/root/.foundry/bin:${PATH}"
52  
53  # Create workspace directory
54  WORKDIR /workspace
55  
56  # Verify installations
57  RUN gramr --version && \
58      wotan --help > /dev/null && \
59      forge --version
60  
61  # Default command
62  CMD ["gramr", "--help"]