Skip to content

Commit

Permalink
Docker (#2)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
amalp12 and clifordjoshy committed Apr 30, 2023
1 parent 80f85bc commit ef7598e
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 6 deletions.
101 changes: 101 additions & 0 deletions docs/docker-setup.md
Original file line number Diff line number Diff line change
@@ -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 <your directory>
New-Item Dockerfile
New-Item -path workdir -ItemType directory
```

=== "Unix / Linux"

``` sh
cd <your directory>
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)
12 changes: 9 additions & 3 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:

Expand Down
6 changes: 3 additions & 3 deletions docs/testprograms/test-program-02.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ef7598e

Please sign in to comment.