FROM rust:1.75 as builder

WORKDIR /app

RUN USER=root cargo new imspyder
WORKDIR /app/imspyder
RUN mkdir -p .cargo
COPY config.toml .cargo/
COPY Cargo.toml Cargo.lock ./

COPY ./src src
RUN cargo install --path . --color always

# Copy the app to an base Docker image, here we use distroless
FROM ubuntu:latest

RUN apt-get update
RUN apt-get install -y ca-certificates
RUN update-ca-certificates
RUN mkdir -p /cache
COPY --from=builder /usr/local/cargo/bin/imspyder /imspyder
USER 1000
ENTRYPOINT ["/imspyder"]