-
Notifications
You must be signed in to change notification settings - Fork 258
/
preview.sh
executable file
·39 lines (34 loc) · 1.27 KB
/
preview.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
set -euo pipefail
## this script is to run a docker container to
## 1. render the markdown files for vuepress
## 2. serve the rendered HTML pages in a vuepress site
##
## It takes one argument as the listner port number the
## port number which defaults to 8080
PRODUCT="${1:-ce}" # ce or ee
HOST_PORT="${2:-8080}"
## FIXME: the preview container will print docs link to stdout
## but it is not the host port with `localhost`
## i.e.
## use command `./preview.sh ee 8081`
## but the container printed inner local address:
## ```
## vitepress v1.0.0-alpha.75
##
## ➜ Local: http://localhost:8080/
## ➜ Network: http://172.17.0.2:8080/
## ```
CONTAINER_NAME="emqx-doc-preview-${PRODUCT}"
THIS_DIR="$(cd "$(dirname "$(readlink "$0" || echo "$0")")"; pwd -P)"
docker rm "$CONTAINER_NAME" > /dev/null 2>&1 || true
python3 "$THIS_DIR/gen.py" ce > directory.json
docker run -p ${HOST_PORT}:8080 -it --name "$CONTAINER_NAME" \
-v "$THIS_DIR"/directory.json:/app/docs/.vitepress/config/directory.json \
-v "$THIS_DIR"/en_US:/app/docs/en/emqx/latest \
-v "$THIS_DIR"/zh_CN:/app/docs/zh/emqx/latest \
-v "$THIS_DIR"/hocon:/app/docs/.vitepress/public/api \
-e DOCS_TYPE=emqx \
-e VERSION=latest \
-e HOCON=true \
ghcr.io/emqx/docs-emqx-com-next:latest