# Multi-stage build for LiteCloud # Stage 1: Build the Rust backend FROM rust:1.70-slim as rust-builder WORKDIR /app # Install build dependencies RUN apt-get update && apt-get install -y \ pkg-config \ libssl-dev \ && rm -rf /var/lib/apt/lists/* # Copy Rust project files COPY api /app # Build the Rust application in release mode RUN cargo build --release # Stage 2: Build the Flutter frontend FROM debian:bullseye-slim as flutter-builder WORKDIR /app # Install dependencies for Flutter RUN apt-get update && apt-get install -y \ curl \ git \ unzip \ xz-utils \ && rm -rf /var/lib/apt/lists/* # Install Flutter RUN git clone https://github.com/flutter/flutter.git /flutter ENV PATH="/flutter/bin:${PATH}" RUN flutter channel stable && flutter upgrade && flutter config --enable-web # Copy Flutter project files COPY lightcloud_app /app # Build Flutter web app RUN flutter build web --release # Stage 3: Final image FROM debian:bullseye-slim WORKDIR /app # Install runtime dependencies RUN apt-get update && apt-get install -y \ ca-certificates \ && rm -rf /var/lib/apt/lists/* # Create data directory RUN mkdir -p /data && chmod 755 /data # Copy the Rust binary from the rust-builder stage COPY --from=rust-builder /app/target/release/litecloud /app/litecloud # Copy the Flutter web build from the flutter-builder stage COPY --from=flutter-builder /app/build/web /app/static # Expose the port the server listens on EXPOSE 8082 # Set environment variables ENV RUST_LOG=info # Run the server CMD ["/app/litecloud"]