FROM rust:1.76-slim-bullseye as builder WORKDIR /usr/src/app COPY . . # Build the application RUN cargo build --release # Create a new stage with a minimal image FROM debian:bullseye-slim WORKDIR /usr/local/bin # Install necessary runtime dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates \ && rm -rf /var/lib/apt/lists/* # Copy the built binary from the builder stage COPY --from=builder /usr/src/app/target/release/hospitalapi . # Create a directory for the .env file RUN mkdir -p /usr/src/app WORKDIR /usr/src/app # Copy the .env file COPY .env . # Expose the port the app runs on EXPOSE 3000 # Run the application CMD ["./hospitalapi"]