# Stage 1: Build Rust WASM components FROM rust:1.75 AS rust-builder WORKDIR /app # Install wasm-pack RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh # Copy Rust source code COPY rust/ ./rust/ # Build WASM components WORKDIR /app/rust/rhai-codemirror RUN wasm-pack build --target web --out-dir "../../webui/src/wasm/rhai-codemirror" WORKDIR /app/rust/runner RUN wasm-pack build --target web --out-dir "../../webui/src/wasm/runner" # Stage 2: Build and run Next.js application FROM node:18-alpine AS app WORKDIR /app # Install Bun RUN npm install -g bun # Copy webui package files COPY webui/package.json webui/bun.lock* ./webui/ # Install dependencies WORKDIR /app/webui RUN bun install --frozen-lockfile # Copy webui source code COPY webui/ ./ # Copy built WASM files from rust-builder stage COPY --from=rust-builder /app/webui/src/wasm/ ./src/wasm/ # Build the application RUN bun run build # Create data directory for scripts RUN mkdir -p ../data/scripts # Expose port EXPOSE 3000 # Start the application CMD ["bun", "start"]