FROM rust:latest as builder
WORKDIR /usr/src/app
COPY . .
# Will build and cache the binary and dependent crates in release mode
RUN --mount=type=cache,target=/usr/local/cargo,from=rust:latest,source=/usr/local/cargo \
--mount=type=cache,target=target \
cargo build --release && mv ./target/release/server-rust ./server-rust
# Runtime image
FROM debian:bullseye-slim
RUN apt-get update && apt install -y openssl
# Run as "app" user
RUN useradd -ms /bin/bash app
USER app
WORKDIR /app
# Get compiled binaries from builder's cargo install directory
COPY --from=builder /usr/src/app/server-rust /app/server-rust
# set production env config as the app config
COPY production.env /app/.env
# Run the app
CMD ./server-rust /app/
This is the docker file I’ve been using for a couple months now without a problem. The only recent change (after I started getting the error) was adding the RUN apt-get update && apt install -y openssl, which doesn’t seem to fix the problem.
rust:latest is now pointing at bookworm: Docker . Bookworm was released in late June and sometime in the past two month a new rust image must have been released. Previously it undoubtedly was using bullseye.
It will be a while until the next Debian release, so try:
FROM rust:bookworm as builder
. . .
FROM debian:bookworm-slim