Home > Mobile >  Install rust on openjdk docker image
Install rust on openjdk docker image

Time:10-24

I'm trying to write a dockerfile to run a rust test suite that requires a jar to be running on a separate port. I've downloaded the jar into the project and would like to start with the openjdk docker image and download rust as well. That way I can use the java command to run the jar then cargo to run the tests.

# 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

I was hoping to download rust using the curl command provided on the website, passing all the options as cli arguments, but I still get the prompt. Running

curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable --default-host x86_64-unknown-linux-gnu --profile default

still produces the confirmation prompt.

I'm open to any solution here, including

  1. A one-line command to install rust
  2. Starting from the rust image a one-line command to install java.

CodePudding user response:

You can skip the confirmation prompt by adding the -y argument. This can be found in the help page of installer script.

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
  • Related