一、项目介绍
1.项目简述
JmalCloud是一款私有云存储网盘项目,能够简单安全管理您的云端文件。
2.项目功能
支持OSS,阿里云OS、腾讯云OSS和MinIO;支持图片,音频,视频等文件的在线预览;支持Word、Excel、PPT、流程图和思维导图的编辑和预览;支持x86、arm64(Centos/Debian/Ubuntu/macOS);提供强大的在线文本编辑器;支持超大文件上传,断点续传;支持WebDAV。
3.项目开源地址
https://github.com/jamebal/jmal-cloud-view?tab=readme-ov-file#jmalcloud-%E4%B8%AA%E4%BA%BA%E7%BD%91%E7%9B%98--english
二、项目搭建环境
1. 项目测试环境
A.项目搭建在腾讯云centos7.6,外网地址为43.138.153.157
Linux VM-8-12-centos 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
B.docker版本为26.01,docker-compose版本为v2.26.1
注意:本次实践部署环境为个人腾讯云的测试环境,若是生产环境请谨慎部署;对应开启了容器的端口,在linux下和防火墙下需开放对应端口。
2. 本次项目实施过程
使用docker下载镜像,创建好项目需要挂载的路径,通过docker-cli或者docker compose启动容器,启动容器后查看容器启动状态,查看容器的运行日志是否正常,以上全部正常执行后体验项目功能。
3.注意:docker下载镜像有可能遇到比较慢的情况,参考以下解决措施:
A.docker配置换源,进入/etc/docker的路径,如果没有就创建这个目录
cd /etc/docker/
mkdir -p /etc/docker
B.编辑配置文件
vim daemon.json ##可以清空里面的内容:%d 然后复制下面的源进去wq保存
{
"registry-mirrors":[
"https://286u3d9d.mirror.aliyuncs.com"
]
}
C.registry-mirrors:指定了一个镜像仓库的 URL https://286u3d9d.mirror.aliyuncs.com。 这个配置项用于设置 Docker镜像的镜像仓库地址,使得在拉取和推送 Docker 镜像时能够通过该镜像仓库进行加速。这边提供的是广东广州服务器的镜源,建议个人自己去阿里云建一个个人账号,根据实际所在区获取镜源。
D.重新加载源,重启docker服务
sudo systemctl daemon-reload
sudo systemctl restart docker
三、项目搭建前巡检
1. 检查docker是否正常运行
systemctl status docker
or
service docker status
注:我个人测试环境是使用systemctl进行管理,若有使用service管理请使用第二条的命令进行查看。
[root@VM-8-12-centos ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2024-04-22 23:13:57 CST; 4 days ago
Docs: https://docs.docker.com
Main PID: 17092 (dockerd)
Tasks: 158
Memory: 142.3M
CGroup: /system.slice/docker.service
若显示docker的Active是active (running),即表明docker是正常运行的。
2.一般我会使用docker-compose去管理,所以预先需要创建好yaml文件,vim docker-compose.yml,格式如下例子:
version: '3.9'
services:
nginx:
image: nginx
logging:
options:
max-size: 1g
restart: always
volumes:
- '/var/run/docker.sock:/tmp/docker.sock:ro'
ports:
- '80:80'
四、项目实施过程
1.根据开源项目,找到对应的镜像进行pull,若遇到很慢的情况,先检查是否网络问题以及是否已经换源。
docker pull jmal/jmalcloud
[root@VM-8-12-centos ~]# docker pull jmal/jmalcloud
Using default tag: latest
latest: Pulling from jmal/jmalcloud
d1669123f281: Pull complete
2ec73b48ae40: Pull complete
64ed7897b25d: Pull complete
eefea741bc5a: Pull complete
28cc9a8a9caf: Pull complete
c6243262b905: Pull complete
5c2d9fd83087: Pull complete
e3ebcbb7b55e: Pull complete
4f4fb700ef54: Pull complete
Digest: sha256:39a32a34a4e4ecd6e289d08d649f530441d5fe3c6cdb60bdc0f1fbc9d1f2bd26
Status: Downloaded newer image for jmal/jmalcloud:latest
docker.io/jmal/jmalcloud:latest
2.若已经下载完成显示新的一行,可以输入命令查看是否上一条命令执行成功
echo$?
若返回0,则成功;返回其他则根据实际情况重新下载或者查找原因。
3.docker下载完后,可以查看对应的镜像是否下载成功
docker images |grep gopeed
4.下载成功后,编辑docker-compose.yml文件
version: "3"
services:
jmalcloud:
container_name: jmalcloud_server
image: jmal/jmalcloud:latest
environment:
MONGODB_URI: mongodb://mongo:27017/jmalcloud
TZ: Asia/Shanghai
volumes:
- /container/jmalcloud/files:/jmalcloud/files/
restart: unless-stopped
mongo:
container_name: jmalcloud_mongodb
image: mongo:4.4
environment:
TZ: Asia/Shanghai
volumes:
- /container/jmalcloud/mongodb/data/db:/data/db
restart: unless-stopped
command: --wiredTigerCacheSizeGB 0.5
nginx:
container_name: jmalcloud_nginx
image: jmal/jmalcloud-nginx:latest
ports:
- 7070:80
- 7071:8089
environment:
TZ: Asia/Shanghai
links:
- jmalcloud
- office
- drawio-webapp
restart: unless-stopped
office:
container_name: jmalcloud_office
image: onlyoffice/documentserver:7.0.0.132
environment:
TZ: Asia/Shanghai
restart: unless-stopped
drawio-webapp:
container_name: jmalcloud_drawio
image: jgraph/drawio:20.2.3
environment:
TZ: Asia/Shanghai
restart: unless-stopped
编辑后输入wq进行保存
5.启动docker-compose
docker compose up -d
6.启动容器后,查看容器的状态是否正常
docker compose ps
[root@VM-8-12-centos jmalcloud]# docker compose ps
WARN[0000] /opt/jmalcloud/docker-compose.yml: `version` is obsolete
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
jmalcloud_drawio jgraph/drawio:20.2.3 "/docker-entrypoint.…" drawio-webapp 7 minutes ago Up 7 minutes 8080/tcp, 8443/tcp
jmalcloud_mongodb mongo:4.4 "docker-entrypoint.s…" mongo 7 minutes ago Up 7 minutes 27017/tcp
jmalcloud_nginx jmal/jmalcloud-nginx:latest "/docker-entrypoint.…" nginx 7 minutes ago Up 7 minutes 0.0.0.0:7070->80/tcp, :::7070->80/tcp, 0.0.0.0:7071->8089/tcp, :::7071->8089/tcp
jmalcloud_office onlyoffice/documentserver:7.0.0.132 "/app/ds/run-documen…" office 7 minutes ago Up 7 minutes 80/tcp, 443/tcp
jmalcloud_server jmal/jmalcloud:latest "/bin/sh -c 'java -j…" jmalcloud 7 minutes ago Up 5 minutes 8088/tcp
7.启动容器后,查看容器的日志是否正常
docker logs -f jmalcloud_server
[root@VM-8-12-centos jmalcloud]# docker logs -f jmalcloud_server
__ .___ ___. ___ __ ______ __ ______ __ __ _______
| | | \/ | / \ | | / || | / __ \ | | | | | \
| | | \ / | / ^ \ | | | ,----'| | | | | | | | | | | .--. |
.--. | | | |\/| | / /_\ \ | | | | | | | | | | | | | | | | | |
| `--' | | | | | / _____ \ | `----.| `----.| `----.| `--' | | `--' | | '--' |
\______/ |__| |__| /__/ \__\ |_______| \______||_______| \______/ \______/ |_______/
:: jmalcloud :: (v2.7.1)
:: Spring Boot :: (v3.2.4)
:: JDK Version :: (v17.0.7)
__ .___ ___. ___ __ ______ __ ______ __ __ _______
| | | \/ | / \ | | / || | / __ \ | | | | | \
| | | \ / | / ^ \ | | | ,----'| | | | | | | | | | | .--. |
.--. | | | |\/| | / /_\ \ | | | | | | | | | | | | | | | | | |
| `--' | | | | | / _____ \ | `----.| `----.| `----.| `--' | | `--' | | '--' |
\______/ |__| |__| /__/ \__\ |_______| \______||_______| \______/ \______/ |_______/
:: jmalcloud :: (v2.7.1)
:: Spring Boot :: (v3.2.4)
:: JDK Version :: (v17.0.7)
8.启动容器后,需要重置密码
# A. 重置密码
docker exec -it jmalcloud_mongodb mongo jmalcloud --eval "db.getCollection('user').update({ 'creator': true }, {\$set: { 'password': '1000:c5b705ea13a1221f5e59110947ed806f8a978e955fbd2ed6:22508de12228c34a235454a0caf3bcaa5552858543258e56' }}, { 'multi': false, 'upsert': false })"
# B. 重启容器
docker restart jmalcloud_server
# 重置后的密码为: jmalcloud
五、项目体验
注:云服务器记得放开防火墙7070,nginx对外放开访问即可,若想访问demo可以先访问我下面的测试环境!
个人测试demo访问地址:https://43.138.153.157:7070/,账号密码为user/jmalcloud