我正在尝试编写一个 dockerfile 来运行一个 Rust 测试套件,该套件需要一个 jar 在单独的端口上运行。我已将 jar 下载到项目中,并希望从 openjdk docker 镜像开始并下载 rust。这样我就可以使用 java 命令运行 jar,然后使用 Cargo 来运行测试。
# Start with java
FROM openjdk:latest
# Add rust
RUN <one line command to download rust>
# Install production dependencies and build a release artifact.
RUN cargo build --release
# Start chromedriver, geckodriver, and selenium standalone binary
RUN ./thirtyfour/tests/binaries_and_jars/chromedriver
RUN ./thirtyfour/tests/binaries_and_jars/geckodriver
RUN java -jar ./thirtyfour/tests/binaries_and_jars/selenium.jar standalone --port 1234
# Run the tests
RUN cargo test
我希望使用网站上提供的curl命令下载rust,将所有选项作为cli参数传递,但我仍然收到提示。运行
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable --default-host x86_64-unknown-linux-gnu --profile default
仍然会产生确认提示。
我愿意接受这里的任何解决方案,包括
- 安装 Rust 的一行命令
- 从 rust 镜像开始 + 一行命令来安装 java。
最佳答案
您可以通过添加 -y
参数来跳过确认提示。这可以在安装程序脚本的帮助页面中找到。
The installer for rustup
USAGE:
rustup-init [FLAGS] [OPTIONS]
FLAGS:
-v, --verbose Enable verbose output
-q, --quiet Disable progress output
-y Disable confirmation prompt.
--no-modify-path Don't configure the PATH environment variable
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
--default-host <default-host> Choose a default host triple
--default-toolchain <default-toolchain> Choose a default toolchain to install
--default-toolchain none Do not install any toolchains
--profile [minimal|default|complete] Choose a profile
-c, --component <components>... Component name to also install
-t, --target <targets>... Target name to also install
关于java - 在 openjdk docker 镜像上安装 Rust,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74174766/