From f46f81410008e021ebdb46240c1d8b82c1d146ea Mon Sep 17 00:00:00 2001 From: KIEU Thi phuong <thi-phuong.kieu@lis-lab.fr> Date: Mon, 17 Mar 2025 22:18:18 +0100 Subject: [PATCH] Update file README.md --- README.md | 63 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 32df5fd..5170f91 100644 --- a/README.md +++ b/README.md @@ -95,37 +95,38 @@ DCLI is a tool which will help you manage DevContainers (https://gitlab.lis-lab. dcli --version ``` -### Import Java Project - -Open Eclipse, create your own project or import the devs-dclitest project [here](https://gitlab.lis-lab.fr/thi-phuong.kieu/devs-dclitest/-/blob/main/devs-dclitest.zip). - - -### Write Dockerfile script - -Create and file named *Dockerfile* under the project folder, and insert this script: - -```javascript -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 Java project and Write dockerfile + +- **hello-world** + - **src** + - **main.java** + ```java + public class main { + public static void main(String[] arg) { + System.out.println("Hello, World!"); + } + } + ``` + - **dockerfile** + ```javascript + FROM openjdk + COPY src hello-world/src + WORKDIR hello-world + RUN mkdir -p bin + RUN javac -d bin ./main.java + WORKDIR bin + CMD ["java", "main.java"] + ``` + *This scripts should have the exact name as `Dockerfile` or `dockerfile`.* ### Create docker image -Then build and run docker by command line: - ```bash -docker build -t devs-dcli:test . +docker build -t hello:test . ``` ```bash -docker run -it devs-dcli:test +docker run -it hello:test ``` ### Initialize a project using a customized Devcontainer configuration @@ -139,7 +140,7 @@ dcli init Insert image name of docker created: ```bash -Image Name: devs-dcli:test +Image Name: hello:test ``` ### Test running the DevContainer @@ -153,7 +154,7 @@ dcli start You will see the VSCode workspace opened. Test running the java program inside the DevContainer, type: ```bash -java -cp /devs-dclitest/bin:/devs-dclitest/lib/fwkdevs-v0.7 Simulator +java main.java ``` Stop the container: @@ -192,7 +193,7 @@ Then create new folders: ```bash mkdir devcontainer_images # for the squashfs file -mkdir devs-dclitest # for your soucre code +mkdir hello-world # for your soucre code ``` On the second window, type: @@ -206,7 +207,7 @@ 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/ +Project directory (absolute path) to mount inside the devcontainer located on the cluster []: /home/your-user.name/hello-world/ 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. @@ -222,7 +223,7 @@ dcli push Then, push your source code to the cluster. E.g: ```bash -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 +scp -r -o ProxyJump="your-user.name@139.124.22.4" ./src/main.java your-user.name@sms:/home/your-user.name/hello-world/src/main.java ``` ### Run your DevContainer on LIS Cluster @@ -236,11 +237,11 @@ dcli irun Once connect successfully, type: ```bash -java -cp /devs-dclitest/bin:/devs-dclitest/lib/fwkdevs-v0.7 Simulator +java main.java ``` **Note:** To run manually, connect to the cluster first, then type: ```bash -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 +srun --container-image=/home/your-user.name/devcontainer_images//dcli_hello-world.squashfs --container-mounts=/home/your-user.name/hello-world/:/workspace --container-workdir=/workspace --cpus-per-task=12 --pty bash ``` \ No newline at end of file -- GitLab