info_tfgrid/docs/hero_mdbook_fullvm_script.md

78 lines
3.0 KiB
Markdown
Raw Normal View History

2024-02-15 19:55:04 +00:00
<h1>Hero and mdbook on a Full VM: Script</h1>
<h2>Table of Contents</h2>
- [Introduction](#introduction)
- [Setting the Full VM](#setting-the-full-vm)
- [Remote Explorer Access](#remote-explorer-access)
- [Download and Run the Script](#download-and-run-the-script)
- [Serve and View the mdbook](#serve-and-view-the-mdbook)
- [Questions and Feedback](#questions-and-feedback)
***
## Introduction
In this tutorial, we show how to use a script to deploy an mdbook with the [hero](https://github.com/freeflowuniverse/crystallib/tree/development/cli/hero) tool.
For this guide, we show an example using the mdbook from the repository [info_tfgrid](https://git.ourworld.tf/tfgrid/info_tfgrid). This setup can be done locally or on a VM. Note that it should be run as root.
We show the steps for a full VM deployed on the TFGrid with WireGuard. We use `10.20.4.2` as a WireGuard IP address. Adjust according to your own setup.
We will be using SSH to connect to the VM and to create an SSH tunnel between the local machine and the VM. This will allow the mdbook output to be displayed on a local browser.
To manage the mdbook files, we will be using the remote explorer feature of either VSCodium or VSCode.
## Setting the Full VM
We start by deploying a full VM with WireGuard on the TFGrid. We also set an SSH tunnel.
- Deploy a full VM with WireGuard on the TFGrid
- Set an SSH tunnel, on port 3333 for both local and VM
```
ssh -4 -L 3333:127.0.0.1:3333 root@10.20.4.2
```
Instead of working on the SSH tunnel terminal window, we will be using the remote explorer feature of a source-code editor.
## Remote Explorer Access
You can use the remote explorer feature of both [VSCode](https://marketplace.visualstudio.com/items?itemName=ms-vscode.remote-repositories) and [VSCodium](https://open-vsx.org/extension/jeanp413/open-remote-ssh) to manage the mdbook.
- Open the window `Remote Explorer`, click on `Add New` and write the following in the SSH config file:
```
Host 10.20.4.2
HostName 10.20.4.2
User root
```
- Click on `Connect to Host`
- Open the main `/root` directory
- Right-click on the main window of the directory and select `Open in Integrated Terminal`
## Download and Run the Script
- Download the script
```
2024-02-15 20:01:14 +00:00
wget https://git.ourworld.tf/tfgrid/info_tfgrid/raw/branch/main/scripts/hero_mdbook.sh
2024-02-15 19:55:04 +00:00
```
- Run the script (this will take a couple of minutes)
```
source hero_mdbook.sh
```
## Serve and View the mdbook
- Serve the mdbook
```
mdbook serve --port 3333
```
- Open your browser and use the following URL:
```
localhost:3333
```
You can now work on the mdbook and see live the changes your bring to the mdbook files on the remote VM.
## Questions and Feedback
If you have any questions or feedback, please let us know by either writing a post on the [ThreeFold Forum](https://forum.threefold.io/), or by chatting with us on the [TF Grid Tester Community](https://t.me/threefoldtesting) Telegram channel.