# Stage 1: Build WASM package FROM rust:1.82-slim AS wasm-builder RUN apt-get update && apt-get install -y curl pkg-config libssl-dev && rm -rf /var/lib/apt/lists/* RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh WORKDIR /app COPY Cargo.toml Cargo.lock ./ COPY crates/ crates/ RUN wasm-pack build crates/mass-driver-wasm --target web --out-dir pkg # Stage 2: Build SvelteKit frontend FROM node:22-slim AS frontend-builder WORKDIR /app/frontend COPY frontend/package.json frontend/package-lock.json ./ RUN npm ci COPY --from=wasm-builder /app/crates/mass-driver-wasm/pkg ./node_modules/mass-driver-wasm COPY frontend/ ./ RUN npm run build # Stage 3: Serve with nginx FROM nginx:alpine COPY --from=frontend-builder /app/frontend/build /usr/share/nginx/html COPY nginx.conf /etc/nginx/nginx.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]