# Dockerfile for building synor-crypto-wasm WASM module # Produces optimized WASM binaries for web wallet integration # ============================================================================= # Stage 1: Build WASM Module # ============================================================================= FROM rust:1.85-bookworm AS builder # Install wasm-pack and build dependencies RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh && \ apt-get update && apt-get install -y \ cmake \ clang \ libclang-dev \ pkg-config \ && rm -rf /var/lib/apt/lists/* # Create app directory WORKDIR /app # Copy manifests (for caching) COPY Cargo.toml Cargo.lock ./ COPY crates/ crates/ # Build WASM module for bundlers (Vite/Webpack) WORKDIR /app/crates/synor-crypto-wasm RUN wasm-pack build \ --target bundler \ --out-dir /output/pkg \ --out-name synor_crypto \ --release # Also build for direct web import (no bundler) RUN wasm-pack build \ --target web \ --out-dir /output/pkg-web \ --out-name synor_crypto \ --release # ============================================================================= # Stage 2: Output Stage (minimal image with just the artifacts) # ============================================================================= FROM alpine:3.19 AS output # Copy WASM artifacts COPY --from=builder /output /wasm-output # Create a simple script to copy files out RUN echo '#!/bin/sh' > /copy-wasm.sh && \ echo 'cp -r /wasm-output/* /dest/' >> /copy-wasm.sh && \ chmod +x /copy-wasm.sh # Default: list what's available CMD ["ls", "-la", "/wasm-output/pkg"]