info_tfgrid/docs/hero_mdbook_docker.md

113 lines
3.8 KiB
Markdown
Raw Permalink Normal View History

2024-04-27 13:49:13 +00:00
<h1>Deploy mdBook with Hero on Docker</h1>
<h2>Table of Contents</h2>
- [Introduction](#introduction)
- [Prerequisites](#prerequisites)
- [Steps](#steps)
2024-10-23 03:58:10 +00:00
- [Update the Book](#update-the-book)
2024-04-27 13:49:13 +00:00
---
## Introduction
We give the basic steps to use Hero on Docker to run and create mdBooks.
2024-04-30 00:29:19 +00:00
You can then use a code editor, e.g. VSCodium, to change the files locally and use Hero docker to build and serve the book.
2024-04-27 13:49:13 +00:00
## Prerequisites
2024-10-23 03:48:52 +00:00
- [Docker Engine](https://docs.docker.com/engine/install/ubuntu/) should be installed and running on Linux
2024-10-23 03:33:27 +00:00
- [Docker Desktop](https://www.docker.com/products/docker-desktop/) should be installed and running on MacOS and Windows
2024-04-27 13:49:13 +00:00
- You need a git repository to work with (here we use **info_tfgrid**)
2024-04-30 00:29:19 +00:00
- Clone the hero mdbook repo on your local machine (i.e. the host) and note the path
2024-04-27 13:49:13 +00:00
2024-10-23 03:33:27 +00:00
For basic info on Git, read [this documentation](https://manual.grid.tf/documentation/system_administrators/computer_it_basics/git_github_basics.html).
2024-04-27 13:49:13 +00:00
## Steps
2024-04-30 00:29:19 +00:00
We show the steps to use Hero with Docker.
Once you've set Hero Docker, you can adjust the files at the host path in a code editor and use the docker container to build and serve the book with Hero.
2024-04-27 13:49:13 +00:00
Note that you will need to adjust the local path of the git repo and the docker path of the git repo.
2024-10-23 03:48:52 +00:00
- On a terminal window, create the code repository on the local machine
2024-04-27 13:49:13 +00:00
```
2024-10-23 03:48:52 +00:00
mkdir -p ~/code/git.ourworld.tf/tfgrid
2024-10-23 03:51:12 +00:00
cd ~/code/git.ourworld.tf/tfgrid
git clone https://git.ourworld.tf/tfgrid/info_tfgrid
2024-10-23 03:48:52 +00:00
```
- Start Hero docker
```
2024-10-23 20:35:18 +00:00
sudo docker run --net=host --name herodocker -d -v ~/code:/root/code ghcr.io/scottyeager/hero:latest
2024-04-27 13:49:13 +00:00
```
2024-04-30 00:23:06 +00:00
- Execute the Hero docker container
2024-04-27 13:49:13 +00:00
```
sudo docker exec -it herodocker bash
```
2024-10-23 03:48:52 +00:00
- Change directory
```
2024-10-23 03:51:12 +00:00
cd ~/code/git.ourworld.tf/tfgrid/info_tfgrid
2024-10-23 03:48:52 +00:00
```
2024-04-29 13:30:06 +00:00
- Git configuration
- Set git lobally with a safe directory
```
git config --global --add safe.directory /root/code/git.ourworld.tf/tfgrid/info_tfgrid
```
2024-10-23 03:51:12 +00:00
- You can now use Hero normally, e.g. with **tech**
2024-04-29 13:28:14 +00:00
- With a URL:
```
2024-10-23 03:51:12 +00:00
hero mdbook -u https://git.ourworld.tf/tfgrid/info_tfgrid/src/branch/main/heroscript/tech
2024-04-29 13:28:14 +00:00
```
- With a path:
```
2024-10-23 03:51:12 +00:00
hero mdbook -p /root/code/git.ourworld.tf/tfgrid/info_tfgrid/heroscript/tech
2024-04-29 13:28:14 +00:00
```
- In this case, you can modify the mdbook on the local machine's git repo that you set in the prerequisites section and the changes will be shown on the docker path
2024-04-27 13:49:13 +00:00
- To view the mdbook on your local browser, run the lines:
```
2024-10-23 03:51:12 +00:00
cd ~/hero/var/mdbuild/tech/
2024-10-23 04:03:07 +00:00
mdbook serve -n 0.0.0.0 --port 3005
2024-04-27 13:49:13 +00:00
```
- You should be able to view the rendered book at
```
2024-10-23 04:05:55 +00:00
http://localhost:3005/
2024-04-27 13:49:13 +00:00
```
2024-04-30 00:23:06 +00:00
- To stop the container, exit the Docker container with `exit` and run the following:
2024-04-27 13:49:13 +00:00
```
sudo docker stop herodocker
```
- To start Hero after having stopped the container, run the following:
```
sudo docker start herodocker
```
- You can now run the previous line **docker exec** and continue your work.
2024-04-30 00:04:47 +00:00
- If you need to update the docker Hero image, run the following line:
```
docker pull ghcr.io/scottyeager/hero:latest
2024-10-23 03:58:10 +00:00
```
2024-10-23 04:03:07 +00:00
- To remove the container
```
sudo docker rm herodocker
```
2024-10-23 03:58:10 +00:00
## Update the Book
You can use [VSCodium](https://manual.grid.tf/documentation/system_administrators/computer_it_basics/git_github_basics.html#vs-codium) to update files of the Mdbook.
- Open VSCodium
- Open the directory where the repo is located, e.g.
```
cd ~/code/git.ourworld.tf/tfgrid/info_tfgrid
```
- Make changes and save the files
- Redeploy Hero Mdbook
- With a path:
```
hero mdbook -p /root/code/git.ourworld.tf/tfgrid/info_tfgrid/heroscript/tech
```
- With a URL (make sure to pull the changes with `git pull`):
```
hero mdbook -u https://git.ourworld.tf/tfgrid/info_tfgrid/src/branch/main/heroscript/tech
2024-10-23 03:33:27 +00:00
```