# Build stage FROM rust:1.79-slim AS builder WORKDIR /usr/src/app # Install build dependencies RUN apt-get update && apt-get install -y \ pkg-config \ libsqlite3-dev \ && rm -rf /var/lib/apt/lists/* # Copy manifests COPY Cargo.toml ./ COPY crates ./crates COPY apps ./apps # Build the application (release mode for smaller binary) RUN cargo build --release --bin ${BIN_NAME} # Runtime stage FROM debian:trixie-slim AS runtime # Install runtime dependencies RUN apt-get update && apt-get install -y \ ca-certificates \ libsqlite3-0 \ && rm -rf /var/lib/apt/lists/* # Create app user RUN useradd -m -u 1000 appuser WORKDIR /app # Copy binary from builder COPY --from=builder /usr/src/app/target/release/${BIN_NAME} ./${BIN_NAME} # Switch to non-root user USER appuser # Run the binary CMD ["./${BIN_NAME}"]