货物建造 - 释放从Dockerfile跑步时找不到CMAKE

发布于 2025-02-12 17:09:24 字数 2999 浏览 0 评论 0原文

我正在使用使用“前列腺扩展”女巫在码头容器中运行的程序。当我运行货物构建时-Release从控制台中的所有内容都与cargo Run一起工作,但是当我尝试做docker build ./ i时获取此错误:

#15 160.6 error: failed to run custom build command for `prost-build v0.10.4`
#15 160.6
#15 160.6 Caused by:
#15 160.6   process didn't exit successfully: `/web_server/target/release/build/prost-build-b45bc4869a088027/build-script-build` (exit status: 101)
#15 160.6   --- stdout
#15 160.6   cargo:rerun-if-changed=/usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/prost-build-0.10.4/third-party/protobuf/cmake
#15 160.6   CMAKE_TOOLCHAIN_FILE_x86_64-unknown-linux-gnu = None
#15 160.6   CMAKE_TOOLCHAIN_FILE_x86_64_unknown_linux_gnu = None
#15 160.6   HOST_CMAKE_TOOLCHAIN_FILE = None
#15 160.6   CMAKE_TOOLCHAIN_FILE = None
#15 160.6   CMAKE_GENERATOR_x86_64-unknown-linux-gnu = None
#15 160.6   CMAKE_GENERATOR_x86_64_unknown_linux_gnu = None
#15 160.6   HOST_CMAKE_GENERATOR = None
#15 160.6   CMAKE_GENERATOR = None
#15 160.6   CMAKE_PREFIX_PATH_x86_64-unknown-linux-gnu = None
#15 160.6   CMAKE_PREFIX_PATH_x86_64_unknown_linux_gnu = None
#15 160.6   HOST_CMAKE_PREFIX_PATH = None
#15 160.6   CMAKE_PREFIX_PATH = None
#15 160.6   CMAKE_x86_64-unknown-linux-gnu = None
#15 160.6   CMAKE_x86_64_unknown_linux_gnu = None
#15 160.6   HOST_CMAKE = None
#15 160.6   CMAKE = None
#15 160.6   running: "cmake" "/usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/prost-build-0.10.4/third-party/protobuf/cmake" "-Dprotobuf_BUILD_TESTS=OFF" "-DCMAKE_INSTALL_PREFIX=/web_server/target/release/build/prost-build-5d68a19605f74072/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=Debug"
#15 160.6
#15 160.6   --- stderr
#15 160.6   thread 'main' panicked at '
#15 160.6   failed to execute command: No such file or directory (os error 2)
#15 160.6   is `cmake` not installed?
#15 160.6
#15 160.6   build script failed, must exit now', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.48/src/lib.rs:975:5
#15 160.6   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
#15 160.6 warning: build failed, waiting for other jobs to finish...
------
executor failed running [/bin/sh -c cargo build --release]: exit code: 101

我的dockerfile:

FROM rust:1.62 as build

RUN USER=root cargo new --bin web_server
WORKDIR /web_server

COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml


COPY ./src ./src
COPY build.rs build.rs
COPY ./proto ./proto


RUN cargo build --release

FROM debian:buster-slim


COPY --from=build /web_server/target/release/web_server .

CMD ["./web_server"]

我在Windows 10上,从VS代码工作,并且我确实有一个路径。 有人知道我可能在Dockerfile内做错了什么?

I am building a programm with uses the Prost extension witch should run in a docker container. When i run cargo build --release from the console everything works fine same with cargo run but when I try to do docker build ./ I get this Error:

#15 160.6 error: failed to run custom build command for `prost-build v0.10.4`
#15 160.6
#15 160.6 Caused by:
#15 160.6   process didn't exit successfully: `/web_server/target/release/build/prost-build-b45bc4869a088027/build-script-build` (exit status: 101)
#15 160.6   --- stdout
#15 160.6   cargo:rerun-if-changed=/usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/prost-build-0.10.4/third-party/protobuf/cmake
#15 160.6   CMAKE_TOOLCHAIN_FILE_x86_64-unknown-linux-gnu = None
#15 160.6   CMAKE_TOOLCHAIN_FILE_x86_64_unknown_linux_gnu = None
#15 160.6   HOST_CMAKE_TOOLCHAIN_FILE = None
#15 160.6   CMAKE_TOOLCHAIN_FILE = None
#15 160.6   CMAKE_GENERATOR_x86_64-unknown-linux-gnu = None
#15 160.6   CMAKE_GENERATOR_x86_64_unknown_linux_gnu = None
#15 160.6   HOST_CMAKE_GENERATOR = None
#15 160.6   CMAKE_GENERATOR = None
#15 160.6   CMAKE_PREFIX_PATH_x86_64-unknown-linux-gnu = None
#15 160.6   CMAKE_PREFIX_PATH_x86_64_unknown_linux_gnu = None
#15 160.6   HOST_CMAKE_PREFIX_PATH = None
#15 160.6   CMAKE_PREFIX_PATH = None
#15 160.6   CMAKE_x86_64-unknown-linux-gnu = None
#15 160.6   CMAKE_x86_64_unknown_linux_gnu = None
#15 160.6   HOST_CMAKE = None
#15 160.6   CMAKE = None
#15 160.6   running: "cmake" "/usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/prost-build-0.10.4/third-party/protobuf/cmake" "-Dprotobuf_BUILD_TESTS=OFF" "-DCMAKE_INSTALL_PREFIX=/web_server/target/release/build/prost-build-5d68a19605f74072/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=Debug"
#15 160.6
#15 160.6   --- stderr
#15 160.6   thread 'main' panicked at '
#15 160.6   failed to execute command: No such file or directory (os error 2)
#15 160.6   is `cmake` not installed?
#15 160.6
#15 160.6   build script failed, must exit now', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.48/src/lib.rs:975:5
#15 160.6   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
#15 160.6 warning: build failed, waiting for other jobs to finish...
------
executor failed running [/bin/sh -c cargo build --release]: exit code: 101

My Dockerfile:

FROM rust:1.62 as build

RUN USER=root cargo new --bin web_server
WORKDIR /web_server

COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml


COPY ./src ./src
COPY build.rs build.rs
COPY ./proto ./proto


RUN cargo build --release

FROM debian:buster-slim


COPY --from=build /web_server/target/release/web_server .

CMD ["./web_server"]

I'm on Windows 10 and work from VS Code and i do have Cmake istalled an pathed.
Anybody know what i might have done wrong inside the Dockerfile?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

殊姿 2025-02-19 17:09:24

从stderr docker构建日志中,您需要在图像构建过程中安装cmake依赖项

#15 160.6   --- stderr
#15 160.6   thread 'main' panicked at '
#15 160.6   failed to execute command: No such file or directory (os error 2)
#15 160.6   is `cmake` not installed?

RUN apt-get install -y cmake && cargo build --release

取决于其他构建依赖关系,您可能需要安装其他软件包。


根据您的评论,有些动机是为何需要的:

我在Windows 10上,从VS代码工作,并且我确实有一个路径。有人知道我可能在Dockerfile内做错了什么?

您可能已经在本地安装了CMAKE,但是在构建图像时看起来并不像已安装Cmake。 Docker Image构建环境有些“沙盒”,它无法访问任何本地安装的程序,例如本地CMAKE。您可以在此处阅读有关Docker Image概念的更多信息: https://docs.docks.docker.com /启动/概述/#图像

From your stderr Docker build logs, you need to install cmake dependency during the image build.

#15 160.6   --- stderr
#15 160.6   thread 'main' panicked at '
#15 160.6   failed to execute command: No such file or directory (os error 2)
#15 160.6   is `cmake` not installed?

rust:1.62 is ubuntu based, so installing that dependency would look like:

RUN apt-get install -y cmake && cargo build --release

Depending on your other build dependencies, you may need to install other packages.


Some motivation why this is needed, based on your comment:

I'm on Windows 10 and work from VS Code and i do have Cmake istalled an pathed. Anybody know what i might have done wrong inside the Dockerfile?

You may have cmake locally installed but it does not look like you have cmake installed while the image is being built. The Docker image build environment is somewhat "sandboxed", it doesn't have access to any locally installed programs like your local cmake. You can read more about Docker image concepts here: https://docs.docker.com/get-started/overview/#images

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文