Skip to content
Snippets Groups Projects
Commit 7295b73d authored by KIEU Thi phuong's avatar KIEU Thi phuong
Browse files

finish

parent 87b3e137
Branches
No related tags found
No related merge requests found
......@@ -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
......@@ -61,3 +61,186 @@ If unsuccessfully, install manually follow these steps:
4. Check the Docker Tooling option and install.
### 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*.
![alt text](image.png)
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*.
![alt text](image-1.png)
**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
```
![alt text](image-2.png)
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
screenshot images/image-1.png

176 KiB

screenshot images/image-2.png

37 KiB

screenshot images/image.png

124 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment