From 7a3e69d5725dbdb27639112f9db544856d730483 Mon Sep 17 00:00:00 2001 From: Denis-Cosmin NUTIU Date: Wed, 25 Dec 2024 20:22:19 +0200 Subject: [PATCH] Dockerize scrapper using cargo-chef --- .dockerignore | 1 + scrapper/docker/Dockerfile | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 .dockerignore create mode 100644 scrapper/docker/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..1de5659 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +target \ No newline at end of file diff --git a/scrapper/docker/Dockerfile b/scrapper/docker/Dockerfile new file mode 100644 index 0000000..83d3b26 --- /dev/null +++ b/scrapper/docker/Dockerfile @@ -0,0 +1,29 @@ +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 +FROM rust:1.83.0-bookworm AS runner +WORKDIR /app + +COPY --from=builder /app/target/release/scrapper /app/scrapper + +ENTRYPOINT /app/scrapper \ No newline at end of file