add Dockerfile
This commit is contained in:
parent
1d4a776b8f
commit
a0235d20d8
1 changed files with 31 additions and 0 deletions
31
bot/docker/Dockerfile
Normal file
31
bot/docker/Dockerfile
Normal file
|
@ -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"]
|
Loading…
Reference in a new issue