本文主要是介绍【打工日常】使用Docker部署团队协作文档工具,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、ShowDoc介绍
ShowDoc是一个适合IT团队共同协作API文档、技术文档的工具。通过showdoc,可以方便地使用markdown语法来书写出API文档、数据字典文档、技术文档、在线excel文档等等。
响应式网页设计:可将项目文档分享到电脑或移动设备查看。同时也可以将项目导出成word文件,以便离线浏览。
公开项目与私密项目:ShowDoc上的项目有公开项目和私密项目两种。公开项目可供任何登录与非登录的用户访问,而私密项目则需要输入密码验证访问。密码由项目创建者设置。
项目转让:项目创建者可以自由地把项目转让给网站的其他用户。
项目成员:你可以很方便地为ShowDoc的项目添加、删除项目成员。项目成员可以对项目进行编辑,但不可转让或删除项目(只有项目创建者才有权限)。
团队管理:利用showdoc的团队功能你可以更好地进行团队协作。
markdown编辑:ShowDoc采用markdown编辑器,无论是编辑还是阅读体验都极佳很棒。
模板插入:在ShowDoc的编辑页面,点击编辑器上方的按钮可方便地插入API接口模板和数据字典模板。
历史版本:ShowDoc为页面提供历史版本功能,你可以方便地把页面恢复到之前的版本。
二、本次实践介绍
-
本次实践简介
本次实践部署环境为个人测试环境
-
本地环境规划
本次实践环境规划:下载镜像fastposter/fastposter:latest,通过docker-cli或者docker compose启动容器
镜像命名 | IP地址 | 容器镜像版本 | 操作系统版本 |
---|---|---|---|
showdoc | localhost | latest | ubuntu 22.04 |
三、检查本地Docker环境
-
检查本地Docker版本
检查Docker版本:docker version root@WellDone:/home/goodjob# docker version
Client: Docker Engine - Community Version: 25.0.0 API version: 1.44 Go version: go1.21.6 Git commit: e758fe5 Built: Thu Jan 18 17:09:49 2024 OS/Arch: linux/amd64 Context: default Server: Docker Engine - Community Engine: Version: 25.0.0 API version: 1.44 (minimum version 1.24) Go version: go1.21.6 Git commit: 615dfdf Built: Thu Jan 18 17:09:49 2024 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.6.27 GitCommit: a1496014c916f9e62104b33d1bb5bd03b0858e59 runc: Version: 1.1.11 GitCommit: v1.1.11-0-g4bccb38 docker-init: Version: 0.19.0 GitCommit: de40ad0
root@WellDone:/home/goodjob#
-
检查Docker服务状态
检查Docker服务状态,确保Docker服务正常运行。
systemctl status docker root@WellDone:/home/goodjob/Downloads# systemctl status docker
● docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2024-01-24 08:54:31 CST; 1 day 4h ago
TriggeredBy: ● docker.socket Docs: https://docs.docker.com Main PID: 1549 (dockerd) Tasks: 65 Memory: 419.5M CPU: 38.874s CGroup: /system.slice/docker.service ├─ 1549 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock ├─ 2010 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 6379 -container-ip 172.17.0.2 -container-port 6379 ├─ 2016 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 6379 -container-ip 172.17.0.2 -container-port 6379 ├─ 2029 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 5432 -container-ip 172.17.0.3 -container-port 5432 ├─ 2036 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 5432 -container-ip 172.17.0.3 -container-port 5432 ├─123083 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8888 -container-ip 172.17.0.4 -container-port 8080 └─123095 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8888 -container-ip 172.17.0.4 -container-port 8080 1月 24 08:54:31 WellDone dockerd[1549]: time="2024-01-24T08:54:31.067895045+08:00" level=info msg="API listen on /run/docker.sock"
1月 24 08:54:31 WellDone systemd[1]: Started Docker Application Container Engine.
1月 24 16:13:48 WellDone dockerd[1549]: time="2024-01-24T16:13:48.185008219+08:00" level=info msg="ignoring event" container=8ad99af82d8a41dd661d>
1月 24 16:13:48 WellDone dockerd[1549]: time="2024-01-24T16:13:48.189484205+08:00" level=warning msg="ShouldRestart failed, container will not be>
1月 24 21:58:08 WellDone dockerd[1549]: time="2024-01-24T21:58:08.024915139+08:00" level=info msg="ignoring event" container=27fd28e2993f31b170b8>
1月 24 21:58:08 WellDone dockerd[1549]: time="2024-01-24T21:58:08.029986730+08:00" level=warning msg="ShouldRestart failed, container will not be>
1月 25 10:46:16 WellDone dockerd[1549]: time="2024-01-25T10:46:16.329180722+08:00" level=info msg="Container failed to exit within 10s of signal >
1月 25 10:46:16 WellDone dockerd[1549]: time="2024-01-25T10:46:16.350757439+08:00" level=info msg="ignoring event" container=b1223add00f36bbb3246>
1月 25 10:49:21 WellDone dockerd[1549]: time="2024-01-25T10:49:21.993755983+08:00" level=info msg="Container failed to exit within 10s of signal >
1月 25 10:49:22 WellDone dockerd[1549]: time="2024-01-25T10:49:22.015822650+08:00" level=info msg="ignoring event" container=edb0e153b45dbe62acd8>
lines 1-28/28 (END)
四、部署showdoc镜像
-
下载showdoc镜像
docker pull fastposter/fastposter root@HEJIAJIN-FX506HE:/docker_software# docker pull fastposter/fastposter
Using default tag: latest
latest: Pulling from fastposter/fastposter
7d63c13d9b9b: Pull complete
6ad2a11ca37b: Pull complete
8076cdef4689: Pull complete
0ba90f5a7dd0: Pull complete
27c191df269f: Pull complete
e332e26a6509: Pull complete
b6aa2cfacc25: Pull complete
Digest: sha256:0d1c173c7bc5ef6b51a815a995f06dd89b4902e4773be98687259134cf6ea267
Status: Downloaded newer image for fastposter/fastposter:latest
docker.io/fastposter/fastposter:latest
-
创建容器
使用docker快速创建showdoc的容器。
完整创建过程:1.使用docker-cli启动一个showdoc的容器。docker run -d --name showdoc --user=root -p 1222:80 --restart always -v /docker_software/showdoc/html:/var/www/html/ star7th/showdoc:latest2.使用docker-compose启动一个showdoc的容器 version: '3.9'
services:showdoc:image: 'star7th/showdoc:latest'volumes:- '/docker_software/showdoc/html:/var/www/html/'restart: alwaysports:- '1222:80'user: rootcontainer_name: showdoc
-
检查容器运行状态
检查容器的运行状态,确保服务的正常运行。
docker ps
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
showdoc star7th/showdoc:latest "/entrypoint bash do…" showdoc 3 minutes ago Up 3 minutes 443/tcp, 9000/tcp, 0.0.0.0:1222->80/tcp, :::1222->80/tcp
查看容器运行日志
docker logs -f showdoc
Not found /var/www/html/index.php, copy...
Same version, skip upgrade.
delay 30s start mock...
2024-03-15 15:41:05,123 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message.
2024-03-15 15:41:05,123 INFO Included extra file "/opt/docker/etc/supervisor.d/nginx.conf" during parsing
2024-03-15 15:41:05,123 INFO Included extra file "/opt/docker/etc/supervisor.d/php-fpm.conf" during parsing
2024-03-15 15:41:05,126 INFO RPC interface 'supervisor' initialized
2024-03-15 15:41:05,126 INFO supervisord started with pid 65
2024-03-15 15:41:06,128 INFO spawned: 'nginxd' with pid 66
2024-03-15 15:41:06,129 INFO spawned: 'php-fpmd' with pid 67
-> Executing /opt/docker/bin/service.d/nginx.d//10-init.sh
2024-03-15 15:41:06,132 INFO success: nginxd entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2024-03-15 15:41:06,132 INFO success: php-fpmd entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
-> Executing /opt/docker/bin/service.d/php-fpm.d//10-init.sh
Setting php-fpm user to application
[15-Mar-2024 15:41:06] NOTICE: fpm is running, pid 67
[15-Mar-2024 15:41:06] NOTICE: ready to handle connections
[php-fpm:access] 127.0.0.1 - 15/Mar/2024:15:41:06 +0000 "GET /index.php" 302 /app/index.php 13.245 2048 75.50%
172.24.0.1 - - [15/Mar/2024:15:41:06 +0000] "GET / HTTP/1.1" 302 5 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0"
[php-fpm:access] 127.0.0.1 - 15/Mar/2024:15:41:06 +0000 "GET /install/index.php" 200 /app/install/index.php 1.296 2048 0.00%
172.24.0.1 - - [15/Mar/2024:15:41:06 +0000] "GET /install/index.php HTTP/1.1" 200 3204 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0"
[php-fpm:access] 127.0.0.1 - 15/Mar/2024:15:41:26 +0000 "GET /install/ajax.php?lang=zh" 200 /app/install/ajax.php 0.698 2048 0.00%
172.24.0.1 - - [15/Mar/2024:15:41:26 +0000] "GET /install/ajax.php?lang=zh HTTP/1.1" 200 197 "http://localhost:1222/install/index.php" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0"> mockServer@1.0.0 start
> npm run pm2 start index.js> mockServer@1.0.0 pm2
> node ./node_modules/pm2/bin/pm2 "start" "index.js"-------------__/\\\\\\\\\\\\\____/\\\\____________/\\\\____/\\\\\\\\\______\/\\\/\\\_\/\\\\\\________/\\\\\\__/\\\///\\\____\/\\\_______\/\\\_\/\\\//\\\____/\\\//\\\_\///______\//\\\___\/\\\\\\\\\\\\\/__\/\\\\///\\\/\\\/_\/\\\___________/\\\/____\/\\\/____\/\\\__\///\\\/___\/\\\________/\\\//______\/\\\_____________\/\\\____\///_____\/\\\_____/\\\//_________\/\\\_____________\/\\\_____________\/\\\___/\\\/____________\/\\\_____________\/\\\_____________\/\\\__/\\\\\\\\\\\\\\\__\///______________\///______________\///__\///__Runtime EditionPM2 is a Production Process Manager for Node.js applicationswith a built-in Load Balancer.Start and Daemonize any application:$ pm2 start app.jsLoad Balance 4 instances of api.js:$ pm2 start api.js -i 4Monitor in production:$ pm2 monitorMake pm2 auto-boot at server restart:$ pm2 startupTo go further checkout:http://pm2.io/-------------[PM2] Spawning PM2 daemon with pm2_home=/root/.pm2
[PM2] PM2 Successfully daemonized
[PM2] Starting /showdoc_data/mock/index.js in fork_mode (1 instance)
[PM2] Done.
┌─────┬──────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user │ watching │
├─────┼──────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0 │ index │ default │ 1.0.0 │ fork │ 135 │ 0s │ 0 │ online │ 0% │ 26.9mb │ root │ disabled │
└─────┴──────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
五、访问showdoc
访问地址:http://localhost:1222
选择语言
2.查看初始化结果(初始化成功。默认管理员账户密码是showdoc/123456。)
3.进入ShowDoc登录页
4.登录ShowDoc首页
5.进入后台管理界面
6.新建项目
7.新建与编辑文档
8.团队管理
这篇关于【打工日常】使用Docker部署团队协作文档工具的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!