From a0235d20d8e2c1ba1348131edc8ca7808919f506 Mon Sep 17 00:00:00 2001 From: Denis-Cosmin NUTIU Date: Mon, 30 Dec 2024 19:03:52 +0200 Subject: [PATCH] add Dockerfile --- bot/docker/Dockerfile | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 bot/docker/Dockerfile diff --git a/bot/docker/Dockerfile b/bot/docker/Dockerfile new file mode 100644 index 0000000..f107f3b --- /dev/null +++ b/bot/docker/Dockerfile @@ -0,0 +1,31 @@ +FROM rust:1.83.0-bookworm AS planner +RUN cargo install cargo-chef + +WORKDIR /app +# Copy the whole project +COPY . . +# Prepare a build plan ("recipe") +RUN cargo chef prepare --recipe-path recipe.json + +FROM rust:1.83.0-bookworm AS builder +RUN cargo install cargo-chef +WORKDIR /app + +# Copy the build plan from the previous Docker stage +COPY --from=planner /app/recipe.json recipe.json + +# Build dependencies - this layer is cached as long as `recipe.json` +# doesn't change. +RUN cargo chef cook --recipe-path recipe.json + +# Build the whole project +COPY . . +RUN cargo build --profile release + +# Run the project +FROM rust:1.83.0-bookworm AS runner +WORKDIR /app + +COPY --from=builder /app/target/release/bot /app/bot + +ENTRYPOINT ["/app/bot"] \ No newline at end of file