From ef7598ebdc1c95a9992f79c9c926797bd8bf51b0 Mon Sep 17 00:00:00 2001 From: Amal Prakash <44752430+amalp12@users.noreply.github.com> Date: Sun, 30 Apr 2023 14:29:55 +0300 Subject: [PATCH] Docker (#2) * test program 02 corrected * docker based setup added * Dockerfile path issue fixed * remove unnecessary root --------- Co-authored-by: Cliford <62019276+clifordjoshy@users.noreply.github.com> --- docs/docker-setup.md | 101 +++++++++++++++++++++++++++ docs/install.md | 12 +++- docs/testprograms/test-program-02.md | 6 +- 3 files changed, 113 insertions(+), 6 deletions(-) create mode 100644 docs/docker-setup.md diff --git a/docs/docker-setup.md b/docs/docker-setup.md new file mode 100644 index 0000000..98cad12 --- /dev/null +++ b/docs/docker-setup.md @@ -0,0 +1,101 @@ +--- +title: Docker based setup +--- + +## Install and setup Docker on host machine + +Follow the instructions available [here](https://docs.docker.com/get-docker/){ target="_blank" } to install docker on your machine. + +You could also go through the [:material-docker: Docker quick start quide](https://docs.docker.com/get-started/){ target="_blank" } to know more about Docker . + +!!! warning + The following has **not** been tested on _Windows_. + + If you encounter any issues/ has suggestions raise an issue [here](https://github.com/silcnitc/expl-docs/issues/new) + +## Setting up + +We'll assume the following directory structure + +``` plaintext +. +├── Dockerfile +└── workdir/ # <- user files will be stored here and mapped to container +``` + +We'll store the user written code in `workdir` and map the same into the container. + +We can create the structure using the below commands + +=== "Windows (Powershell)" + + ``` powershell + cd + New-Item Dockerfile + New-Item -path workdir -ItemType directory + ``` + +=== "Unix / Linux" + + ``` sh + cd + touch Dockerfile + mkdir workdir + ``` + +The contents of `Dockerfile` are given below + +``` Dockerfile +FROM ubuntu:20.04 + +RUN apt-get update \ + && apt-get install -y bison flex libreadline-dev libc6-dev libfl-dev wget vim make gcc curl git build-essential + +RUN useradd -m expl +USER expl + +RUN cd /home/expl \ + && git clone https://github.com/silcnitc/xsm_expl.git \ + && cd ./xsm_expl \ + && make + +WORKDIR /home/expl/xsm_expl +``` + +The given `Dockerfile` will setup an expl environment as specified in [Installation Page](./install.md) + +### Building the container image + +We'll now build the container image using the `Dockerfile` + +```sh +docker build -t expl:ubuntu20.04 . +``` + +### Start the container instance + +We'll start an instance of Container and map the local folder `workdir` into `/home/expl/workdir` directory of container. + +=== "Windows (PowerShell)" + ``` powershell + docker run -v ${PWD}/workdir:/home/expl/xsm_expl/workdir -d --name expl -i expl:ubuntu20.04 + ``` + +=== "Unix / Linux" + ``` sh + docker run -v $PWD/workdir:/home/expl/xsm_expl/workdir -d --name expl -i expl:ubuntu20.04 + ``` + +We now have a container instance running in background with the name `expl` and required volume mounts + +### Connecting to the container + +We can connect to the container instance using the following commands + +```sh +docker start expl # if the container instance is not already running + +docker exec -it expl /bin/bash # to get a bash shell inside the container +``` + +After connecting to the container you can use `xfs-interface`, and `xsm` binaries as mentioned in [Installation Page](./install.md) diff --git a/docs/install.md b/docs/install.md index fd08730..9fe820b 100644 --- a/docs/install.md +++ b/docs/install.md @@ -3,6 +3,7 @@ title: 'Installation' --- # Installation +If these instructions do not work, you can try the [:material-docker: Docker based setup](./docker-setup.md). ## Install LEX @@ -42,13 +43,18 @@ Let us install XSM ### Step 1 -Download XSM Simulator +Clone the XSM Simulator from the official repository to your computer -[Version 1 :octicons-download-16:](files/xsm_expl.tar.gz){ .md-button .md-button--primary } +```bash +git clone https://github.com/silcnitc/xsm_expl.git +``` ### Step 2 -Extract this file and navigate into the folder `xsm_expl` through the terminal. +Navigate into the folder `xsm_expl` through the terminal. +```bash +cd xsm_expl +``` Do the following steps: diff --git a/docs/testprograms/test-program-02.md b/docs/testprograms/test-program-02.md index af002a1..02dd4c5 100644 --- a/docs/testprograms/test-program-02.md +++ b/docs/testprograms/test-program-02.md @@ -37,9 +37,9 @@ int ExtendedEuclid(int a,int b) while(r1 != 0) do qi = r0/r1; - ri = r0 - (qi\*r1); - si = s0 - (qi\*s1); - ti = t0 - (qi\*t1); + ri = r0 - (qi*r1); + si = s0 - (qi*s1); + ti = t0 - (qi*t1); r0 = r1; r1 = ri; s0 = s1;