# SPDX-FileCopyrightText: 2023-2026 Sayantan Santra # SPDX-License-Identifier: MIT FROM docker.io/lukemathwalker/cargo-chef:latest-rust-slim AS chef WORKDIR /chhoto-url FROM chef AS planner COPY ./backend/Cargo.toml ./backend/Cargo.lock ./ COPY ./backend/src ./src RUN cargo chef prepare --recipe-path recipe.json FROM chef AS builder ARG target=x86_64-unknown-linux-musl RUN apt-get update && apt-get install -y musl-tools RUN rustup target add $target COPY --from=planner /chhoto-url/recipe.json recipe.json # Build dependencies - this is the caching Docker layer RUN cargo chef cook --release --target=$target --recipe-path recipe.json COPY ./backend/Cargo.toml ./backend/Cargo.lock ./ COPY ./backend/src ./src # Build application RUN cargo build --release --target=$target --locked --bin chhoto-url RUN cp /chhoto-url/target/$target/release/chhoto-url /chhoto-url/release RUN mkdir -p /frontend-final FROM scratch COPY --from=builder /chhoto-url/release /app/chhoto-url COPY ./frontend /app/frontend/base COPY --from=builder /frontend-final /frontend/final WORKDIR /app ENTRYPOINT ["/app/chhoto-url"]