diff --git a/src/docsify/devcontainer-feature.json b/src/docsify/devcontainer-feature.json
index 9a080cb..613ab91 100644
--- a/src/docsify/devcontainer-feature.json
+++ b/src/docsify/devcontainer-feature.json
@@ -1,7 +1,7 @@
{
"name": "docsify",
"id": "docsify",
- "version": "0.1.1",
+ "version": "0.1.2",
"description": "Automatically serves ./docs workspace directory via 'docsify serve' in the background.",
"options": {
"port": {
diff --git a/src/docsify/fallback/README.md b/src/docsify/fallback/README.md
new file mode 100644
index 0000000..8a12c91
--- /dev/null
+++ b/src/docsify/fallback/README.md
@@ -0,0 +1,3 @@
+# Fake Site
+
+> An awesome fake site test.
diff --git a/src/docsify/fallback/index.html b/src/docsify/fallback/index.html
new file mode 100644
index 0000000..4a493aa
--- /dev/null
+++ b/src/docsify/fallback/index.html
@@ -0,0 +1,22 @@
+
+
+
+
+ Fake Site
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/docsify/install.sh b/src/docsify/install.sh
index 08acb05..f5ca89a 100755
--- a/src/docsify/install.sh
+++ b/src/docsify/install.sh
@@ -2,6 +2,7 @@
set -e
DOCSIFY_SERVE_PATH="/usr/local/bin/docsify-serve"
+DOCSIFY_FALLBACK_PATH="/usr/local/share/docsify-serve/fallback"
DOCS_PATH=${DOCS_PATH:-docs}
@@ -9,46 +10,11 @@ echo "Activating feature 'docsify-cli'..."
npm install -g docsify-cli
-# The fallback/default index.html file to use when the documents directory does
-# not exist.
-DEFAULT_INDEX_HTML=$(cat <
-
-
-
- Fake Site
-
-
-
-
-
-
-
-
-
-
-
-
-EOF
-)
-
-# The fallback/default README.md file to use when the documents directory does
-# not exist.
-DEFAULT_README_MD=$(cat < An awesome fake site test.
-EOF
-)
-
-tee "${DOCSIFY_SERVE_PATH}" > /dev/null \
-<< EOF
-#!/usr/bin/env sh
+cat <"${DOCSIFY_SERVE_PATH}"
+#!/usr/bin/env bash
# we need to explicitly "activate" (the current) node here, as otherwise
# devcontainers using our feature and also setting their remoteEnv PATH will
@@ -58,17 +24,23 @@ nvm use node
mkdir -p "${DOCS_PATH}"
if [ ! -f "${DOCS_PATH}/index.html" ]; then
- echo "${DEFAULT_INDEX_HTML}" > "${DOCS_PATH}/index.html"
- echo "${DEFAULT_README_MD}" > "${DOCS_PATH}/README.md"
+ cp ${DOCSIFY_FALLBACK_PATH}/* "${DOCS_PATH}"
fi
-nohup bash -c "\
+# since this script is going to be executed as this feature's
+# "postStartCommand" there is an important catch here: it is run via
+# "docker exec -it ...". Please notice the absence of "-d" as this is a
+# synchronous operation. Just using "nohup" as shown in several cases is
+# a bad idea: when postStartCommand finishes, it tears down the nohup.
+# Thus, use setsid(1) (https://man7.org/linux/man-pages/man1/setsid.1.html)
+# to run the docsify serve node process in a new session.
+setsid --fork bash -c "\
docsify serve \
-p=${PORT} \
-P=${LIVERELOAD_PORT} \
--no-open \
${DOCS_PATH} \
- &" >/tmp/nohup-docsify.log 2>&1
+ >/tmp/nohup-docsify.log 2>&1"
EOF
chmod 0755 "${DOCSIFY_SERVE_PATH}"