# Multi-stage build for FlyingCarpet (TAURI) app
FROM rust:1.94.0-bookworm AS builder
# Install build dependencies
RUN apt-get update -y && \
apt-get install -y --no-install-recommends curl ca-certificates build-essential pkg-config \
libssl-dev nodejs npm libgtk-3-dev libsoup-3.0-dev libwebkit2gtk-4.1-dev && \
rm -rf /var/lib/apt/lists/*
WORKDIR /workspace
# Copy source and build the workspace in release mode
COPY . .
RUN cargo build --workspace --release
# Collect release artifacts into a known directory
RUN mkdir -p /workspace/release
RUN sh -lc 'for f in /workspace/target/release/*; do if [ -x "$f" ]; then cp "$f" "/workspace/release/"; fi; done'
FROM debian:bookworm-slim AS runtime
# Runtime dependencies for a GTK/WebKit TAURI app
RUN apt-get update -y && \
apt-get install -y --no-install-recommends \
libgtk-3-0 libwebkit2gtk-4.1-0 libsoup-3.0-0 ca-certificates libssl3 && \
rm -rf /var/lib/apt/lists/*
# Copy the release artifacts from builder
COPY --from=builder /workspace/release /workspace/release
# Wrapper script to execute the released binary
RUN printf '#!/bin/sh\nset -e\nBIN_DIR="/workspace/release"\nfor f in "$BIN_DIR"/*; do\n if [ -x "$f" ]; then\n exec "$f" "$@"\n fi\ndone\nexit 1\n' > /usr/local/bin/run-flyingcarpet.sh && \
chmod +x /usr/local/bin/run-flyingcarpet.sh
# Run the app (wrapper will pick the executable in the release dir)
CMD ["/usr/local/bin/run-flyingcarpet.sh"]