Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/distributed demo #94

Merged
merged 58 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
46128b9
Cleans up the security code and links
prasadtalasila Jun 25, 2023
ca16cde
Updates the deploy code
prasadtalasila Jun 26, 2023
f52c43a
Improves the installation procedures
prasadtalasila Jun 28, 2023
36d69dc
Updates vagrant installation setup and cleans up scripts
prasadtalasila Jun 29, 2023
f444898
Completes the documentation
prasadtalasila Jun 30, 2023
bed4b26
Updates the mkdocs config for generating pdf files
prasadtalasila Aug 27, 2023
12ddba6
Updates the mkdocs config and adds new docs.sh script
prasadtalasila Aug 27, 2023
6752822
Updates links in README.md
prasadtalasila Aug 27, 2023
a0d18bc
Updates documentation files
prasadtalasila Aug 27, 2023
0fa5c39
Merge branch 'feature/distributed-demo' into release-v0.2
astitva1905 Sep 3, 2023
1a7bbfd
Merge pull request #2 from astitva1905/release-v0.2
astitva1905 Sep 3, 2023
5332e6b
Update install.sh
astitva1905 Sep 5, 2023
19cbca7
Update install.sh
astitva1905 Sep 5, 2023
9460cd7
Update env.sh
astitva1905 Sep 5, 2023
42a5618
Update LIB-MS.md
astitva1905 Sep 5, 2023
36b0a5d
Update README.md
astitva1905 Sep 7, 2023
4de0c6d
Update install.sh
astitva1905 Sep 7, 2023
43a704c
Update single-script-install.sh
astitva1905 Sep 7, 2023
e9f003a
Update single-script-install.sh
astitva1905 Sep 7, 2023
7e34955
Delete packages directory
astitva1905 Sep 7, 2023
9e01af4
Update env.sh
astitva1905 Sep 7, 2023
1c0c011
Update provision.sh
astitva1905 Sep 7, 2023
dfbd8fb
Update README.md
astitva1905 Sep 7, 2023
cfc740a
Update README.md
astitva1905 Sep 7, 2023
6eea1bd
Update prod.js
astitva1905 Sep 7, 2023
f070a27
Update README.md
astitva1905 Sep 7, 2023
50f4277
Update env.js
astitva1905 Sep 7, 2023
29ddc4a
Update host.md
astitva1905 Sep 7, 2023
86e64cd
Update LIB-MS.md
astitva1905 Sep 7, 2023
f90532e
Update trial.md
astitva1905 Sep 7, 2023
2af01c6
Update single-machine.md
astitva1905 Sep 7, 2023
5f78aa4
Update two-machines.md
astitva1905 Sep 7, 2023
65b3b1d
Delete docs/developer/system/DTaaS-overview.pdf
astitva1905 Sep 7, 2023
c038064
Update thanks.md
astitva1905 Sep 7, 2023
b2620d9
Add files via upload
astitva1905 Sep 7, 2023
53372fc
Rename ssl.conf to ssl/ssl.conf
astitva1905 Sep 7, 2023
1c46f39
Add files via upload
astitva1905 Sep 7, 2023
923bece
Update single-script-install.sh
astitva1905 Sep 7, 2023
e266cf1
Update README.md
astitva1905 Sep 7, 2023
eba921d
Add files via upload
astitva1905 Sep 7, 2023
e4b52a0
Rename docs/DTaaS.drawio to docs/developer/system/DTaaS.drawio
astitva1905 Sep 7, 2023
8d70b43
Add files via upload
astitva1905 Sep 7, 2023
101a7d9
Rename docs/package-diagram.puml to docs/developer/client/uml/package…
astitva1905 Sep 7, 2023
1f4d2f5
Add files via upload
astitva1905 Sep 7, 2023
9012a85
Rename docs/developer/lib-class.puml to docs/developer/servers/lib/li…
astitva1905 Sep 7, 2023
10914e0
Rename docs/developer/lib-sequence.puml to docs/developer/servers/lib…
astitva1905 Sep 7, 2023
5e6d679
Update README.md
astitva1905 Sep 8, 2023
32a4896
Update README.md
astitva1905 Sep 8, 2023
18b81bf
Update README.md
astitva1905 Sep 8, 2023
cd3f4bf
Update README.md
astitva1905 Sep 8, 2023
e2b749e
Update Vagrantfile
astitva1905 Sep 8, 2023
e4252b7
Update CLIENT.md
astitva1905 Sep 8, 2023
9025f21
Update host.md
astitva1905 Sep 8, 2023
9202f7b
Update LIB-MS.md
astitva1905 Sep 8, 2023
4a4a9c3
Update README.md
astitva1905 Sep 8, 2023
0fff162
Update single-machine.md
astitva1905 Sep 8, 2023
2f1bc4f
Update two-machines.md
astitva1905 Sep 8, 2023
9a3e6c6
Changed permission
astitva1905 Sep 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:
uses: Tiryoh/actions-mkdocs@v0
with:
mkdocs_version: 'latest'
requirements: 'docs/requirements.txt'
configfile: 'mkdocs.yml'
requirements: 'docs/requirements-github.txt'
configfile: 'mkdocs-github.yml'


- name: show contents of compiled docs
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,21 @@ The rest of the information on this page is aimed at current and potential contr
To install the development environment, run

```bash
bash script/install.bash
bash script/env.sh
```

There is a script to download all the docker containers used in the project. You can download them using

```bash
bash script/docker.sh
```

**CAVEAT**: The docker images are large and are likely to consume about 5GB of bandwidth and 15GB of space. You will have to download the docker images on a really good network.

Before you make commits, please install the git hooks provided in the repository.

```shell
script/configure-git-hooks.sh
```bash
bash script/configure-git-hooks.sh
```

This will ensure that your commits are formatted correctly and that the unittests pass before you push your changes. Be aware that the tests take a long time to run. If you want to skip the tests or formatting, you can use the `--no-verify` flag on `git commit` or `git push`.
Expand Down
8 changes: 8 additions & 0 deletions STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@
[![Client CI](https://github.com/into-cps-association/dtaas/actions/workflows/client.yml/badge.svg)](https://github.com/into-cps-association/dtaas/actions/workflows/client.yml/badge.svg)

[![Server CI](https://github.com/into-cps-association/dtaas/actions/workflows/server.yml/badge.svg)](https://github.com/into-cps-association/dtaas/actions/workflows/server.yml/badge.svg)

[![Contributors](https://img.shields.io/github/contributors/INTO-CPS-Association/DTaaS)](https://github.com/INTO-CPS-Association/DTaaS/graphs/contributors)

[![Latest Commit](https://img.shields.io/github/last-commit/INTO-CPS-Association/DTaaS)](https://github.com/INTO-CPS-Association/DTaaS/commits/feature/distributed-demo)

[![INTO-CPS Association](https://img.shields.io/badge/INTO_CPS_Association-white)](https://into-cps.org/)


4 changes: 2 additions & 2 deletions client/config/prod.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
window.env = {
REACT_APP_ENVIRONMENT: 'dev',
REACT_APP_ENVIRONMENT: 'prod',
REACT_APP_URL: 'https://foo.com/',
REACT_APP_URL_BASENAME: 'dtaas',
REACT_APP_URL_DTLINK: '/lab',
Expand All @@ -15,4 +15,4 @@ window.env = {
REACT_APP_REDIRECT_URI: 'https://foo.com/Library',
REACT_APP_LOGOUT_REDIRECT_URI: 'https://foo.com/',
REACT_APP_GITLAB_SCOPES: 'openid profile read_user read_repository api',
};
};
93 changes: 93 additions & 0 deletions deploy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# DTaaS on Linux Operating System

This directory contains code for running DTaaS application on a Ubuntu Server 20.04 Operating System. The setup requires a machine which can spare 16GB RAM, 8 vCPUs and 50GB Hard Disk space.

A dummy **foo.com** URL has been used for illustration. Please change this to your unique website URL. It is assumed that you are going to serve the application in only HTTPS mode.

Please follow these steps to make this work in your local environment. Download the codebase as zip file into your computer and unzip the same into a directory named **DTaaS**. The rest of the instructions assume that your working directory is **DTaaS**.

## Configuration

You need to configure the gateway, library microservice and react client website.

The first step is to decide on the number of users and their usenames. The traefik gateway configuration has a template for two users. You can modify the usernames in the template to the usernames chosen by you.

### The traefik gateway server

You can run the Run the Traefik gateway server in both and HTTPS and HTTPS mode to experience the DTaaS application. The installation guide assumes that you can run the application in HTTPS mode.

The Traefik gateway configuration is at [fileConfig](../config/gateway/fileConfig.yml). Change `localhost` to `foo.com` and user1/user2 to the usernames chosen by you.

**NOTE**: Do not use `http://` or `https://` in [fileConfig](../config/gateway/fileConfig.yml).

#### Authentication

The dummy username is `foo` and the password is `bar`.
Please change this before starting the gateway.

```bash
rm deploy/config/gateway/auth
touch deploy/config/gateway/auth
htpasswd deploy/config/gateway/auth <first_username>
password: <your password>
```

The user credentials added in [auth](../config/gateway/auth) should match the usernames in [fileConfig](../config/gateway/fileConfig.yml).

## Configure lib microservice
The library microservice requires configuration. A template of this configuration file is given in _config/lib_ file. Please modify this file as per your needs.

The first step in this configuration is to prepare the a filesystem for users. An example file system in `files/` directory. You can rename the top-level user1/user2 to the usernames chosen by you.

Add an environment file named .env in lib for the library microservice. An example `.env` file is given below. The simplest possibility is to use `local` mode with the following example. The filepath is the absolute filepath to `files/` directory. You can copy this configuration into _config/lib_ file to get started.
```env
PORT='4001'
MODE='local'
LOCAL_PATH ='filepath'
LOG_LEVEL='debug'
APOLLO_PATH='/lib'
GRAPHQL_PLAYGROUND='true'
```

## Configure react website

Change the React website configuration in _deploy/config/client/env.js_.

```js
astitva1905 marked this conversation as resolved.
Show resolved Hide resolved
window.env = {
REACT_APP_ENVIRONMENT: 'prod',
REACT_APP_URL: 'https://foo.com/',
REACT_APP_URL_BASENAME: 'dtaas',
REACT_APP_URL_DTLINK: '/lab',
REACT_APP_URL_LIBLINK: '',
REACT_APP_WORKBENCHLINK_TERMINAL: '/terminals/main',
REACT_APP_WORKBENCHLINK_VNCDESKTOP: '/tools/vnc/?password=vncpassword',
REACT_APP_WORKBENCHLINK_VSCODE: '/tools/vscode/',
REACT_APP_WORKBENCHLINK_JUPYTERLAB: '/lab',
REACT_APP_WORKBENCHLINK_JUPYTERNOTEBOOK: '',

REACT_APP_CLIENT_ID: '934b98f03f1b6f743832b2840bf7cccaed93c3bfe579093dd0942a433691ccc0',
REACT_APP_AUTH_AUTHORITY: 'https://gitlab.foo.com/',
REACT_APP_REDIRECT_URI: 'https://foo.com/Library',
REACT_APP_LOGOUT_REDIRECT_URI: 'https://foo.com/',
REACT_APP_GITLAB_SCOPES: 'openid profile read_user read_repository api',
};
```

## Update the installation script

Open `deploy/install.sh` and update user1/user2 to usernames chosen by you.

## Perform the Installation

Go to the DTaaS directory and execute

```sh
source deploy/install.sh
```

You can run this script multiple times until the installation is successful.

## Access the application

Now you should be able to access the DTaaS application at: _https://foo.com_
18 changes: 18 additions & 0 deletions deploy/config/client/env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
window.env = {
REACT_APP_ENVIRONMENT: 'dev',
REACT_APP_URL: 'https://foo.com/',
REACT_APP_URL_BASENAME: 'dtaas',
REACT_APP_URL_DTLINK: '/lab',
REACT_APP_URL_LIBLINK: '',
REACT_APP_WORKBENCHLINK_TERMINAL: '/terminals/main',
REACT_APP_WORKBENCHLINK_VNCDESKTOP: '/tools/vnc/?password=vncpassword',
REACT_APP_WORKBENCHLINK_VSCODE: '/tools/vscode/',
REACT_APP_WORKBENCHLINK_JUPYTERLAB: '/lab',
REACT_APP_WORKBENCHLINK_JUPYTERNOTEBOOK: '',

REACT_APP_CLIENT_ID: '934b98f03f1b6f743832b2840bf7cccaed93c3bfe579093dd0942a433691ccc0',
REACT_APP_AUTH_AUTHORITY: 'https://gitlab.foo.com/',
REACT_APP_REDIRECT_URI: 'https://foo.com/Library',
REACT_APP_LOGOUT_REDIRECT_URI: 'https://foo.com/',
REACT_APP_GITLAB_SCOPES: 'openid profile read_user read_repository api',
};
1 change: 1 addition & 0 deletions deploy/config/gateway/auth
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo:$apr1$fGdMVLcl$dMzJW.JF8Rn6Vzrf5uxaU/
9 changes: 9 additions & 0 deletions deploy/config/lib
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PORT='4001'
MODE='local' or 'gitlab'
LOCAL_PATH ='filepath'
GITLAB_GROUP ='dtaas'
GITLAB_URL='https://gitlab.foo.com/api/graphql'
TOKEN='123-sample-token'
LOG_LEVEL='debug'
APOLLO_PATH='/lib' or ''
GRAPHQL_PLAYGROUND='false' or 'true'
22 changes: 22 additions & 0 deletions deploy/create-cronjob.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
# Add a cronjob for the DTaaS services to the current users crontab
# the actual crontab script is cron.sh
# all existing crontab jobs are retained

if [ -n "$1" ]; then
PROJECT_PATH="$1"
else
PROJECT_PATH="$(pwd)"
fi

export PROJECT_PATH

printf "Existing crontab for the user\n"
crontab -l
crontab -l | sort -u > temp.cron
echo "* * * * * ${PROJECT_PATH}/deploy/cron.sh ${PROJECT_PATH}" >> temp.cron
sort -u temp.cron > jobs.cron
crontab jobs.cron
rm jobs.cron temp.cron
printf "Updated crontab for the user\n"
crontab -l
25 changes: 25 additions & 0 deletions deploy/cron.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
# Run the client website and lib microservice in background mode

PROJECT_PATH="$1"

nc -z localhost 4000
PORT_STATUS=$?
if (( PORT_STATUS == 1 ))
then
echo "starting react website"
cd "${PROJECT_PATH}/client" || exit
nohup serve -s build -l 4000 & disown
fi



nc -z localhost 4001
PORT_STATUS=$?
if (( PORT_STATUS == 1 ))
then
cd "${PROJECT_PATH}/servers/lib" || exit
nohup yarn start & disown
fi

docker start traefik-gateway
94 changes: 94 additions & 0 deletions deploy/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/bash
set -eu

printf "NOTE\n "
printf "....\n "
printf "This script installs DTaaS application for two users.\n "
printf "Remember to configure the application before proceeding further....\n "
printf "All the configuration instructions are in deploy/README.md file.\n "
printf ".........\n \n \n "

printf "Press Ctl+C if you need to complete the configuration....\n "
printf "Waiting for 60 seconds....\n "
sleep 60

printf "\n \n Install the system dependencies...\n "
printf "....\n "
bash script/env.sh || exit

printf "\n \n Download the required docker images...\n "
printf ".........\n "
source script/docker.sh || exit


printf "\n \n Continue with the DTaaS installation...\n "
printf ".........\n "
TOP_DIR=$(pwd)

printf "\n \n Build, configure and run the react website\n "
printf ".....\n "
cd "${TOP_DIR}/client" || exit
yarn install
yarn build

#one of the environments; specify only one; "dev" used the REACT_APP_ENV is not set
yarn configapp prod
cp "${TOP_DIR}/deploy/config/client/env.js" build/env.js
nohup serve -s build -l 4000 & disown

#-------------
printf "\n\nStart the lib microservice\n "
printf "...........\n "
cd "${TOP_DIR}/servers/lib" || exit
yarn install
yarn build
cp "${TOP_DIR}/deploy/config/lib" .env
nohup yarn start & disown

#-------------
printf "\n \n Start the user workspaces\n "
printf "...........\n "
docker run -d \
-p 8090:8080 \
--name "ml-workspace-user1" \
-v "${TOP_DIR}/files/user1:/workspace" \
-v "${TOP_DIR}/files/common:/workspace/common:ro" \
--env AUTHENTICATE_VIA_JUPYTER="" \
--env WORKSPACE_BASE_URL="user1" \
--shm-size 512m \
--restart always \
mltooling/ml-workspace:0.13.2 || true

docker run -d \
-p 8091:8080 \
--name "ml-workspace-user2" \
-v "${TOP_DIR}/files/user2:/workspace" \
-v "${TOP_DIR}/files/common:/workspace/common:ro" \
--env AUTHENTICATE_VIA_JUPYTER="" \
--env WORKSPACE_BASE_URL="user2" \
--shm-size 512m \
--restart always \
mltooling/ml-workspace:0.13.2 || true

#-------------
printf "\n \n Start the traefik gateway server\n "
printf "...........\n "
cd "${TOP_DIR}/servers/config/gateway" || exit
cp "${TOP_DIR}/deploy/config/gateway/auth" auth
cp "${TOP_DIR}/deploy/config/gateway/fileConfig.yml" "dynamic/fileConfig.yml"

sudo docker run -d \
--name "traefik-gateway" \
--network=host -v "$PWD/traefik.yml:/etc/traefik/traefik.yml" \
-v "$PWD/auth:/etc/traefik/auth" \
-v "$PWD/dynamic:/etc/traefik/dynamic" \
-v /var/run/docker.sock:/var/run/docker.sock \
traefik:v2.5 || true

#----------
printf "\n \n Create crontabs to run the application in daemon mode.\n "
printf "...........\n "
cd "$TOP_DIR" || exit
bash deploy/create-cronjob.sh

printf "\n \n The installation is complete.\n \n \n "
Loading