Dockerize scrapper using cargo-chef

This commit is contained in:
Denis-Cosmin NUTIU 2024-12-25 20:22:19 +02:00
parent 2dc963a915
commit 7a3e69d572
2 changed files with 30 additions and 0 deletions

1
.dockerignore Normal file
View file

@ -0,0 +1 @@
target

View file

@ -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