diff --git a/README.md b/README.md index bfd606fd07bd29b616320d8905e432ba37a5b66b..ba40d4a3ca14343dac5109f9064c6f47d1d8f895 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Tutorial source: ### Import Java Project -You can create your own project, or import DEv-CF model project [here](). +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). ### Install Eclipse Docker Tooling @@ -60,4 +60,187 @@ If unsuccessfully, install manually follow these steps: 4. Check the Docker Tooling option and install. -### Write Dockerfile script \ No newline at end of file +### 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 docker image + +Right click to *Dockerfile* → *Run As* → *Docker Image Build*. + + + +Write *Image Name*, e.g. *devs-dcli:test*. + +Wait for the image built succesfully. +E.g. Build process of image devs-dcli:test +```bash +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 As* → *Java Application in Container*. + + +**Note:** In case Docker Tooling has some problems, install Docker on Ubuntu (follow guildlines [here](https://docs.docker.com/engine/install/ubuntu/)). Then build and run docker by command line: + +```bash +docker build -t devs-dcli:test . +``` + +```bash +docker run -it devs-dcli:test +``` + +### Initialize a project using a customized Devcontainer configuration + +On Terminal, type: + +```bash +dcli init +``` + +Insert image name of docker created: + +```bash +Image Name: devs-dcli:test +``` + +### Test running the DevContainer + +Type : + +```bash +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 +``` + + + +Stop the container: + +```bash +dcli stop +``` + +### Push DevContainer to the LIS Cluster + +#### 1. Export the DevContainer + +Type: + +```bash +dcli export +``` + +Once finished, you should see a squashfs file created. + +**Note:** Ignore the error on permission denied, or type: + +```bash +dcli export | chmod -R 777 tmp +``` + +#### 2. Push your Devcontainer on LIS Cluster + +On the first teminal window, connect to the cluster: + +```bash +ssh your-user.name@sms +``` + +Then create new folders: + +```bash +mkdir devcontainer_images # for the squashfs file +mkdir devs-dclitest # for your soucre code +``` + +On the second window, type: + +```bash +dcli config +``` + +```bash +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: + +```bash +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 +``` + +#### 3. Run your DevContainer on LIS Cluster + +Type: + +```bash +dcli irun +``` + +Once connect successfully, type: + +```bash +java -cp /devs-dclitest/bin:/devs-dclitest/lib/fwkdevs-v0.7 Simulator +``` + +**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 +``` \ No newline at end of file diff --git a/screenshot images/image-1.png b/screenshot images/image-1.png new file mode 100644 index 0000000000000000000000000000000000000000..56cb4cb145d7972ea2f59d9761b7a60c191d1469 Binary files /dev/null and b/screenshot images/image-1.png differ diff --git a/screenshot images/image-2.png b/screenshot images/image-2.png new file mode 100644 index 0000000000000000000000000000000000000000..89416eff695c101ac7889c0034047d8fe9e93e8e Binary files /dev/null and b/screenshot images/image-2.png differ diff --git a/screenshot images/image.png b/screenshot images/image.png new file mode 100644 index 0000000000000000000000000000000000000000..171e8aea913b80744b4d5cbfb445259f0d6f4cea Binary files /dev/null and b/screenshot images/image.png differ