Rate This Document
Findability
Accuracy
Completeness
Readability

Deploying the Tool Using a Dockerfile

If you need to use the Dockerfile to create a DevKit image in a container and use this image to deploy the DevKit CLI, perform the following operations.

  1. Obtain the DevKit command line tool following instructions in Obtaining the Tool and download the BiSheng JDK software package.
  2. Create a Dockerfile on your local PC. Example file:
    # Create a base image, for example, for openEuler 22.03 LTS SP2.
    from openeuler-22.03-lts-sp2:latest 
    ARG package_name=DevKit-CLI-xxx-Linux-Kunpeng
    
    # Copy the resource package.
    COPY $package_name.tar.gz bisheng-jdk-17.0.10-linux-aarch64.tar.gz /usr/local/
    
    # Extract the resource package, modify the permission and owner group, and create a soft link.
    RUN cd /usr/local/ && tar xvf $package_name.tar.gz && tar xvf bisheng-jdk-17.0.10-linux-aarch64.tar.gz && chown -R root:root /usr/local/$package_name/ && chown -R root:root /usr/local/bisheng-jdk-17.0.10/ && chmod -R 755 /usr/local/$package_name/ && chmod -R 755 /usr/local/bisheng-jdk-17.0.10 && ln -s /usr/local/$package_name/devkit /usr/local/bin && ln -s /usr/local/bisheng-jdk-17.0.10/bin/java /usr/local/bin
    
    # To enable SSH login to the container, perform the following steps. Otherwise, skip this step. Ensure that the Internet connection is available.
    RUN yum install -y net-tools shadow-utils passwd openssh-server && ssh-keygen -A
    # If you need to use a common user account, perform the following step. Otherwise, skip this step. Replace the user name (jenkins) and password (123456xx) with the actual ones.
    RUN useradd jenkins && echo "123456xx" | passwd jenkins --stdin && chown -R jenkins:jenkins /usr/local/$package_name/
    
    # Cancel bash timeout.
    RUN sed -i '/^export TMOUT=.*/d' /etc/bashrc
    • package_name indicates the name of the extracted command line tool package.
    • x.x.x in DevKit-CLI-x.x.x-Linux-Kunpeng indicates the version.
  3. After the download is complete, upload the BiSheng JDK 17, DevKit tool software package, and Dockerfile to the same directory on the worker node.

    Directory structure:

  4. Perform the build operation.
    1
    docker build -t devkit-cli -f ./Dockerfile .
    

    devkit-cli is the image name, which can be customized.

    Build process:

    If the following information is displayed, the build is successful.

  5. View the built image.
    1
    docker image list
    

    Image information:

  6. (Optional) Enable sshd.
    1. Create a container. Replace the example container name devkit-cli-container with the actual one.
      1
      docker run -it -d --name devkit-cli-container devkit-cli /bin/bash
      

      If the following information is displayed, the creation is successful.

    2. Access the container. Replace the example container name devkit-cli-container with the actual one.
      1
      docker exec -it devkit-cli-container /bin/bash 
      

      If the following information is displayed, the container is successfully accessed.

    3. Enable SSH access.
      1
      /usr/sbin/sshd
      
    4. Press Ctrl+D to exit the container and check whether the SSH connection is normal.
      1
      ssh jenkins@172.17.0.5
      
      • Check that the user name (jenkins) must be the same as that in the Dockerfile.
      • Run the ifconfig command to view the container IP address. Replace the example address 172.17.0.5 with the actual one.

      If the following information is displayed, the SSH connection is successful.