FROM rust:latest AS builder WORKDIR /app # Copy the Cargo.toml and build the project to cache dependencies COPY Cargo.toml . RUN mkdir src &&\ echo "fn main() {}" > src/main.rs RUN cargo build --release # Copy the rest of the source code then build the project COPY src src RUN touch src/main.rs RUN cargo build --release # Strip the binaries to reduce size RUN strip target/release/botdiscord #FROM alpine:latest as release FROM gcr.io/distroless/cc-debian12 WORKDIR /app # Copy each binary from the builder stage, all needed for different stages COPY --from=builder /app/target/release/server . # Copy the resource folder that containt default configuration files COPY ./resource ./resource ENV PORT 5437 EXPOSE 5437 CMD ["./botdiscord"]