Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use Dockerfile to build image of rust-kafka #687

Open
uamself opened this issue May 27, 2024 · 1 comment
Open

how to use Dockerfile to build image of rust-kafka #687

uamself opened this issue May 27, 2024 · 1 comment

Comments

@uamself
Copy link

uamself commented May 27, 2024

No description provided.

@Guyzeroth
Copy link

Guyzeroth commented May 30, 2024

Here's an example dockerfile I use with cargo-chef for faster builds . just place it in the root of your codebase in Dockerfile . replace your_binary with whatever your built artifact is called.

FROM rust:bookworm as chef

RUN cargo install cargo-chef

WORKDIR app
FROM chef as planner 

COPY . .

RUN cargo chef prepare  --recipe-path recipe.json

FROM chef AS builder

COPY --from=planner /app/recipe.json recipe.json

#Build deps (Cached)

RUN cargo chef cook --release --recipe-path recipe.json
#Build application
COPY . .

RUN cargo build --release

FROM debian:bookworm as runtime

WORKDIR /app/

COPY --from=builder /app/target/release/YOUR_BINARY

CMD ["/app/YOUR_BINARY"]

build with something like docker build -t YOUR_DOCKER_REPO/YOUR_APP:latest .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants