Skip to content
Snippets Groups Projects
Select Git revision
  • 737b28e18b9e840f5fd9ec0a2d8e1f28a9e0f6bb
  • main default protected
2 results

README_oldversion.md

Blame
  • How to run a Java program in DevContainer on the LIS Cluster

    Getting started

    Reclaim: This tutorials is written for Ubuntu users.

    Tutorial source:

    Step by step

    Installation

    Eclipse IDE

    1. Download the installer here.
    2. Extract the archive file, e.g. the 64-bit version:
      tar xf eclipse-inst-linux64.tar.gz
    3. Run the installer:
      cd eclipse-installer
      ./eclipse-inst # or sudo ./eclipse-inst

    DCLI

    Installation Guildline

    Docker

    Installation Guildline

    Import Java Project

    Open Eclipse, create your own project or import the devs-dclitest project here.

    Install Eclipse Docker Tooling

    Option 1: Download from the Eclipse Marketplace

    1. Go to HelpEclipse Marketplace...

    2. Search for Docker Tooling then click Install.

    Option 2: Download manually

    If unsuccessfully, install manually follow these steps:

    1. Go to HelpInstall New Software...

    2. Click Add...

    3. Enter the following:

      Then click Add.

    4. Check the Docker Tooling option and install.

    Write Dockerfile script

    Create and file named Dockerfile under the project folder, and insert this script:

    FROM openjdk:17
    COPY src/ /devs-dclitest/src/
    COPY lib/ /devs-dclitest/lib/
    COPY input/ /devs-dclitest/input/
    COPY output/ /devs-dclitest/output/
    WORKDIR /devs-dclitest
    RUN mkdir -p /devs-dclitest/bin
    RUN javac -cp "/devs-dclitest/lib/fwkdevs-v0.7" -d /devs-dclitest/bin /devs-dclitest/src/*.java
    CMD ["java", "-cp", "/devs-dclitest/bin:/devs-dclitest/lib/fwkdevs-v0.7", "Simulator"]

    Create docker image

    Right click to DockerfileRun AsDocker Image Build.

    alt text

    Write Image Name, e.g. devs-dcli:test.

    Wait for the image built succesfully. E.g. Build process of image devs-dcli:test

    Step 1/8 : FROM openjdk:17
     ---> 5e28ba2b4cdb
    Step 2/8 : COPY src/ /devs-dclitest/src/
     ---> 0decf775c2d8
    Step 3/8 : COPY lib/ /devs-dclitest/lib/
     ---> 1c9d49d80b7f
    Step 4/8 : WORKDIR /devs-dclitest
     ---> Running in 091fd0917dfd
     ---> 8c3614e1d136
    Step 5/8 : RUN mkdir -p /devs-dclitest/bin
     ---> Running in f5a5ce7416d8
     ---> 81ac429c3dd0
    Step 6/8 : RUN javac -cp "/devs-dclitest/lib/fwkdevs-v0.7" -d /devs-dclitest/bin /devs-dclitest/src/*.java
     ---> Running in 1ed5149e6b28
    Note: /devs-dclitest/src/Car.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    ---> 25fbba4dacc8
    Step 7/8 : WORKDIR /devs-dclitest/bin
     ---> Running in 451e735c007d
     ---> 54a5fb214664
    Step 8/8 : CMD ["java", "-cp", "/devs-dclitest/bin:/devs-dclitest/lib/fwkdevs-v0.7", "Simulator"]
     ---> Running in b287512ceb80
     ---> 530f80b5391d
    Successfully built 530f80b5391d
    Successfully tagged devs-dcli:test

    If successfully, right click on the main class, then Run AsJava Application in Container. alt text

    Note: In case Docker Tooling has some problems, install Docker on Ubuntu (follow guildlines here). Then build and run docker by command line:

    docker build -t devs-dcli:test .    
    docker run -it devs-dcli:test

    Initialize a project using a customized Devcontainer configuration

    On Terminal, type:

    dcli init

    Insert image name of docker created:

    Image Name: devs-dcli:test

    Test running the DevContainer

    Type :

    dcli start

    You will see the VSCode workspace opened. Test running the java program inside the DevContainer, type:

    java -cp /devs-dclitest/bin:/devs-dclitest/lib/fwkdevs-v0.7 Simulator

    alt text

    Stop the container:

    dcli stop 

    Push DevContainer to the LIS Cluster

    1. Export the DevContainer

    Type:

    dcli export

    Once finished, you should see a squashfs file created.

    Note: Ignore the error on permission denied, or type:

    dcli export | chmod -R 777 tmp

    2. Push your Devcontainer on LIS Cluster

    On the first teminal window, connect to the cluster:

    ssh your-user.name@sms

    Then create new folders:

    mkdir devcontainer_images # for the squashfs file
    mkdir devs-dclitest       # for your soucre code

    On the second window, type:

    dcli config
    Please provide the following information to create the .cluster_config file.
    Cluster server name/address [sms]: sms
    LIS cluster username []: your-user.name
    Devcontainer workspace directory path [/workspace]: /workspace
    Project directory (absolute path) to mount inside the devcontainer located on the cluster []: /home/your-user.name/devs-dclitest/
    Directory containing squashfs images (absolute path) located on the cluster []: /home/your-user.name/devcontainer_images/
    
    .cluster_config file created successfully in the .devcontainer directory.

    Now, push the squashfs file to the cluster push your squashfs fil inside the cluster:

    dcli push

    Then, push your source code to the cluster. E.g:

    scp -r -o ProxyJump="your-user.name@139.124.22.4" ./src/Car.java your-user.name@sms:/home/your-user.name/devs-dclitest/src/Car.java

    Run your DevContainer on LIS Cluster

    Type:

    dcli irun

    Once connect successfully, type:

    java -cp /devs-dclitest/bin:/devs-dclitest/lib/fwkdevs-v0.7 Simulator

    Note: To run manually, connect to the cluster first, then type:

    srun --container-image=/home/your-user.name/devcontainer_images//dcli_devs-dclitest.squashfs --container-mounts=/home/your-user.name/devs-dclitest/:/workspace --container-workdir=/workspace --cpus-per-task=12 --pty bash