# syntax=docker/dockerfile:1 # ---- Frontend build (Vite + React, pnpm) ---- FROM node:20-alpine AS frontend-build WORKDIR /app/frontend # Enable pnpm via Corepack RUN corepack enable # Install deps (cache-friendly) COPY frontend/package.json frontend/pnpm-lock.yaml ./ RUN pnpm install --frozen-lockfile # Build COPY frontend/ ./ RUN pnpm build # ---- Backend build (Rust + Actix) ---- FROM rust:1.92-bookworm AS backend-build WORKDIR /app # Cache Rust deps COPY Cargo.toml Cargo.lock ./ COPY src ./src COPY scp_core ./scp_core COPY .sqlx ./.sqlx COPY migrations ./migrations # If you have a workspace / extra crates, copy them too (adjust): # COPY crates ./crates ENV SQLX_OFFLINE=true RUN cargo build --release # ---- Runtime image ---- FROM debian:bookworm-slim AS runtime WORKDIR /app RUN apt-get update \ && apt-get install -y --no-install-recommends ca-certificates \ && rm -rf /var/lib/apt/lists/* # Adjust binary name COPY --from=backend-build /app/target/release/cupcontrol /app/cupcontrol COPY --from=backend-build /app/migrations /app/migrations # Match your Actix static path: ./frontend/dist COPY --from=frontend-build /app/frontend/dist /app/frontend/dist ENV RUST_LOG=info ENV HOST=0.0.0.0 EXPOSE 8080 CMD ["/app/cupcontrol"]