Skip to content

Commit 6fe0411

Browse files
feat: Enable backtraces for panics in the project template, being careful not to capture backtraces for normal errors in libraries such as anyhow. Update the command to force the toolchain install to work with the latest rustup version
1 parent fad70ef commit 6fe0411

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
# `cargo-chef` is a cargo-subcommand that provides
22
# enhanced Docker layer caching for Rust projects.
3-
FROM lukemathwalker/cargo-chef:latest as chef
3+
FROM lukemathwalker/cargo-chef:latest AS chef
44
WORKDIR /app
55
# Force `rustup` to sync the toolchain in the base `chef` layer
66
# so that it doesn't happen more than once
77
COPY rust-toolchain.toml .
8-
RUN cargo --version
8+
RUN rustup show active-toolchain
99

10-
FROM chef as planner
10+
FROM chef AS planner
1111
COPY . .
1212
# Compute a lock-like file for our project
1313
RUN cargo chef prepare --recipe-path recipe.json
1414

15-
FROM chef as builder
15+
FROM chef AS builder
1616
COPY --from=planner /app/recipe.json recipe.json
1717
# Build our project's dependencies, not our application!
1818
RUN cargo chef cook --release --recipe-path recipe.json
1919
COPY . .
2020
# Build our project
21-
RUN cargo build --release --bin server
21+
RUN cargo build --release --package server --bin server
2222

2323
FROM debian:bookworm-slim AS runtime
2424
WORKDIR /app
2525
COPY --from=builder /app/target/release/server bin
2626
COPY server/configuration server/configuration
27-
ENV APP_PROFILE production
27+
ENV APP_PROFILE=production
28+
# Enable backtraces to simplify debugging
29+
# production panics.
30+
ENV RUST_BACKTRACE=1
31+
# We don't want `anyhow` to capture backtraces for
32+
# "routine" errors. Just panics.
33+
ENV RUST_LIB_BACKTRACE=0
2834
ENTRYPOINT ["./bin"]

0 commit comments

Comments
 (0)