My deploys have started to fail when built from a Dockerfile with the following error:
#16 6.991 error[E0463]: can't find crate for `core`
#16 6.991 |
#16 6.991 = note: the `x86_64-unknown-linux-musl` target may not be installed
#16 6.991 = help: consider downloading the target with `rustup target add x86_64-unknown-linux-musl`
#16 6.991
#16 6.991 error[E0463]: can't find crate for `compiler_builtins`
#16 6.991
#16 6.992 For more information about this error, try `rustc --explain E0463`.
#16 6.995 error: could not compile `cfg-if` (lib) due to 2 previous errors
#16 6.995 warning: build failed, waiting for other jobs to finish...
#16 7.315 error: failed to compile `cargo-leptos v0.1.11`, intermediate artifacts can be found at `/tmp/cargo-installLOJZbB`
#16 7.322 ERROR Cargo errored! ExitStatus(unix_wait_status(25856))
#16 7.324 ERROR Fatal error:
#16 7.324 binstall::subprocess
#16 7.324
#16 7.324 × subprocess /usr/local/rustup/toolchains/1.71.0-x86_64-unknown-linux-gnu/
#16 7.324 │ bin/cargo install cargo-leptos --version 0.1.11 --target x86_64-unknown-
#16 7.324 │ linux-musl errored with exit status: 101
I haven’t made any changes to the deployment and re-running a previously successful version also fails now fails.
Any help?
pavel
September 20, 2023, 11:15am
2
Hi @JonRCahill
Can you share your Dockerfile?
Hi @pavel here is my Dockerfile:
FROM lukemathwalker/cargo-chef:latest-rust-1.71.0 as chef
WORKDIR /app
RUN apt update && apt install lld clang -y
FROM chef as planner
COPY . .
# Compute a lock-like file for dependencies
RUN cargo chef prepare --recipe-path recipe.json
FROM chef as builder
# Install cargo binstall
RUN wget https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz
RUN tar -xvf cargo-binstall-x86_64-unknown-linux-musl.tgz
RUN cp cargo-binstall /usr/local/cargo/bin
# Install cargo leptos
RUN cargo binstall cargo-leptos -y
# Need wasm target to build the frontend
RUN rustup target add wasm32-unknown-unknown
# Install NodeJS
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
RUN apt-get update
RUN apt-get install -y nodejs
# Install Yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb http://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update
RUN apt-get install -y yarn
# Build dependencies from the lock-like file
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
# Copy just the package.json
WORKDIR /app/
COPY package.json yarn.lock ./
# Install the Node dependencies
RUN yarn install
# Copy the source files
COPY . .
# Run Tailwind to generate our CSS
RUN yarn tailwind
ENV SQLX_OFFLINE=true
# Build Luminoid
RUN cargo leptos build --release -vv
############# RUNNER #############
FROM debian:bullseye-slim
RUN apt-get update -y \
&& apt-get install -y libpq5 \
&& apt-get install -y ca-certificates \
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
# Copy all the required files to run Luminoid
COPY --from=builder /app/target/server/release/luminoid /app/
COPY --from=builder /app/target/site /app/site
COPY --from=builder /app/Cargo.toml /app/
COPY --from=builder /app/.env /app/
WORKDIR /app
# Production ENV settings
ENV RUST_LOG="info"
ENV APP_ENVIRONMENT="production"
ENV LEPTOS_SITE_ADDR="0.0.0.0:3000"
ENV LEPTOS_SITE_ROOT="site"
ENV LEPTOS_OUTPUT_NAME="luminoid"
EXPOSE 3000
CMD ["/app/luminoid"]
Thanks
pavel
September 21, 2023, 8:39am
4
@JonRCahill
There was a cargo-binstall
update 4 days ago. The new version includes this commit: feat `detect-targets`: Improve support of non-std glibc/musl (#1343) · cargo-bins/cargo-binstall@0fa3157 · GitHub
I suspect this is what causing the issues.
Your build environment (lukemathwalker/cargo-chef:latest-rust-1.71.0
) is based on Debian, which uses GLibc, but you are installing cargo-binstall
for musl-based distros.
Try to install cargo-binstall-x86_64-unknown-linux-gnu.tgz
instead and see if this helps.
Thanks @pavel
This didn’t work and it still tried to install with the x86_64-unknown-linux-musl
target but I removed binstall from the Dockerfile and just installed leptos using cargo install
and it is working now.
Very much appreciate your help!