optimize docsify

This commit is contained in:
Stille 2022-01-05 23:45:12 +08:00
parent 0d81ce289d
commit 9ff91505e1
4 changed files with 30 additions and 15 deletions

View File

@ -3,9 +3,10 @@ LABEL org.opencontainers.image.authors="stille@ioiox.com"
WORKDIR /
ADD entrypoint.sh /
RUN npm i docsify-cli -g
RUN docsify init ./docs
EXPOSE 3000
CMD docsify serve docs
ENTRYPOINT ["/bin/sh", "-c", "/entrypoint.sh"]

View File

@ -8,20 +8,13 @@ Docker [stilleshan/docsify](https://hub.docker.com/r/stilleshan/docsify)
docsify serve docker, 方便在 macOS 或 Windows 本地使用 docker 来启动 docsify 服务进行编写文档.
## 使用
### 现有项目
需挂载本地`docsify`文档目录到容器内`/docs`,启动容器使用`127.0.0.1:3000`访问.
### docker
```shell
docker run -d --name=docsify -p 3000:3000 -v /your/docs/path:/docs stilleshan/docsify
docker run --name docsify -p 3000:3000 -v /your/docs/path:/docs stilleshan/docsify
# 修改本地文档目录
```
### 新建项目
```shell
docker run -d --name=docsify -p 3000:3000 stilleshan/docsify
# 不挂载启动容器,初始化新文档.
docker cp docsify:/docs .
# 将容器内初始化的文档拷贝出来.
```
后续可参考上述`现有项目`方式挂载来维护编写文档.
访问`127.0.0.1:3000`
> 注意: 如本地文档目录内含有 index.html 并是初次初始化 docsify, 需重命名 index.html 进行备份,再次启动容器.
### docker compose
下载 [docker-compose.yml](https://raw.githubusercontent.com/stilleshan/dockerfiles/main/docsify/docker-compose.yml) 执行以下命令启动:

View File

@ -7,4 +7,3 @@ services:
- 3000:3000
volumes:
- /your/docs/path:/docs
restart: always

22
docsify/entrypoint.sh Executable file
View File

@ -0,0 +1,22 @@
# /bin/sh
if [ ! -d /docs ]; then
docsify init ./docs
docsify serve docs
fi
docsify init ./tmp-docs
if [ ! -f /docs/index.html ]; then
mv /tmp-docs/index.html /docs
fi
if [ ! -f /docs/README.md ]; then
mv /tmp-docs/README.md /docs
fi
if [ ! -f /docs/.nojekyll ]; then
mv /tmp-docs/.nojekyll /docs
fi
docsify serve docs