FROM rust:1.98-trixie as builder

WORKDIR /app

COPY Cargo.toml Cargo.lock ./
COPY crates/ crates/

RUN cargo build --release --package steep-server


FROM debian:trixie-slim


RUN apt-get update && apt-get install -y --no-install-recommends \
    ca-certificates \
    git \
    libssl3t64 \
    libzstd1 \
    zlib1g \
    && rm -rf /var/lib/apt/lists/*


WORKDIR /app
COPY --from=builder /app/target/release/steep-server ./steep-server

COPY crates/steep-server/toasty ./toasty
ENV MIGRATIONS_DIR=/app/toasty

CMD ["sh", "-c", "./steep-server migration apply && exec ./steep-server"]
