Complete these tasks to reinforce what you learned in this module.
Write a Dockerfile that (1) uses FROM rust:1-bookworm AS builder, sets WORKDIR /app, copies Cargo.toml and src/, and runs cargo build --release. (2) Uses FROM debian:bookworm-slim, copies the binary from the builder stage to /usr/local/bin/, and sets CMD to run it. Use the binary name for this crate (e.g. the package name or the default binary name). No need to run Docker in the task; just produce the Dockerfile.
cargo build --release) and a run stage with a slim image. Copy only the binary from the builder; set CMD to run it. The theory shows the structure.// Task 1: Write minimal Dockerfile. See tasks/TASKS.md.
// Produce the Dockerfile in this crate directory (e.g. 34_docker/Dockerfile.task1).
fn main() {
println!("See tasks/TASKS.md: write a minimal Dockerfile");
}
Extend the Dockerfile so that the build stage first copies only Cargo.toml and Cargo.lock (create a minimal Cargo.lock if needed), then copies a dummy src/main.rs (e.g. fn main() {}), runs cargo build --release, then copies the real src/ and runs cargo build --release again. The goal is to cache the dependency compilation layer. Document in a comment why the dummy copy is used.
// Task 2: Add dependency caching to Dockerfile. See tasks/TASKS.md.
fn main() {
println!("See tasks/TASKS.md: extend Dockerfile with dependency caching");
}