# --------------------
# STAGE 1: The Builder
FROM rust:1.96 as builder

WORKDIR /app
COPY Cargo.* ./

# Create a dummy main.rs so the dependencies can be compiled and cached
RUN mkdir src && \
    echo "fn main() { println!(\"dummy\"); }" > src/main.rs
RUN cargo build --release

# Copy in the real source code changes
COPY src ./src
# Run the real build command
RUN cargo build --release 

# --------------------
# STAGE 2: The Final, Minimal Image
FROM debian:stable-slim

WORKDIR /usr/src/druid

# Copy ONLY the compiled binary from the builder stage
COPY --from=builder /app/target/release/druid /usr/local/bin

ENV ROCKET_ADDRESS=0.0.0.0

# Define the command that runs your application
CMD ["/usr/local/bin/druid"] 