2、部署
实战:docker部署全网最美个人相册machete-2024.09.07(测试成功)
目录
[toc]
前言
版权
本着开源共享、共同学习的精神:
本文是根据 开源站点:《家庭相册-filesite-io》里提供的部署文档进一步编辑输出的 ,具体信息请看 原作者github开源仓库。转载无需和我联系,但请注明文章来源。如果侵权之处,请联系博主进行删除,谢谢~
仓库地址:https://github.com/filesite-io/machete
demo演示
背景
你想拥有一个家庭相册 吗?里面可以放你的摄影作品、家人照片、旅拍作品等等……
恰好这个相册部署简单,体验丝滑,数据安全,那么选择filesite.io就对了😜
一个完美的家人相册的理想状态:
想实现如下一个需求:
我的winodws桌面有一个叫做photo的目录,然后这个目录下有不同子目录,而每个子目录分别存放了不同类型的照片。
有没有一款相册软件,可以把这个photo目录(保持子目录不变)给渲染成一个相册或图库,供大家可以公网访问呢。
本地windows相册数据-->linux;(rsync服务,增量同步,很方便)
这样的好处就是,我只需要维护winodws本地照片,然后就会自动刷新云端照片的,而不需要维护2份数据。
前提
具有1台linux服务器,具有docker、docker-compose环境。
具体部署文档参考如下:
如何搭建docker和docker-compose,见如下链接:
《实战:centos在线安装docker-2022.8.4(成功测试)》 https://wiki.onedayxyy.cn/docs/centos-docker-online-install
《实战:docker-compose安装-2024.4.14(测试成功)》 https://wiki.onedayxyy.cn/docs/docker-compose-install
环境
win10
vmwareworkstation里一台centos7.6 1810虚机,192.168.1.100,能通公网(nat模式)
源码
通过百度网盘分享的文件:filesite-machete-2024.8.13.tar.gz
链接:https://pan.baidu.com/s/1_EQYJZTNgEMujAOWnHcNOg?pwd=hzki
提取码:hzki
filesite-machete-2024.8.13.tar.gz
说明:
这里之所以把镜像打包提供,是为了对数据进 行备份。还是建议大家从 官网仓库 获取镜像。
1、部署
docker-compose版本:(推荐)
mkdir -p /root/machete/photo
mkdir -p /root/machete/runtime/
cd /root/machete
cat > /root/machete/docker-compose.yaml <<EOF
version: "3"
services:
mtphotos:
image: filesite/machete
container_name: machete
restart: always
ports:
- 1081:80
- 445:445
volumes:
- /root/machete/photo:/var/www/machete/www/girls
- /root/machete/runtime:/var/www/machete/runtime
EOF
chmod -R 777 runtime/
docker pull filesite/machete
docker-compose up -d
docker ps
#配置外网大图显示缩略图
docker-compose down
cat > /root/machete/runtime/custom_config.json <<EOF
{"theme":"beauty","content_directory":"girls/","enableSmallImageForWan":"true","showQQImageInFooter":"false"}
EOF
docker-compose up -d
docker ps
#备注:
#photo:存放本地相册数据的;
#runtime目录用来缓存相册封面、缩略图、缓存的,这里做了持久化,即使以后容器删除后,再次新起的容器,相册封面也是在的;(目录封面图缓存和缩略图缓存都在目录runtime/cache里)
- 此时,到浏览器简单访问下,观察效果,可以看到数据为空(那是因为我们还没传数据呢)
在浏览器访问http://192.168.1.100:1081/
2、同步
FreeFileSync方式同步相册数据到linux(推荐)
最终2便的相册数据:(完全一致)
1.安装FreeFileSync
- winodws安装
FreeFileSync_13.7_Windows_Setup
官网链接:
下载winodws客户端:
https://freefilesync.org/download/FreeFileSync_13.7_Windows_Setup.exe
安 装:(一直下一步安装即可)
安装后:
2.同步相册数据
开始同步:
同步前,我们先来做下比较,发现远程目录都为空。
这里选择镜像
把本地数据同步到linux服务器:
点击同步:
此时已经同步完了。
3、验证
- 验证
此时,发现同步上来的文件权限、属主、属组都是欧克的,完美。😜
可以再做一次数据比较,发 现2边数据是完全欧克的。
- 此时访问web
至此,完美。😜
4、扩展
(将家庭相册部署在公网)
以上部署方式可以直接部署在公网的云服务器上,是完全没问题的。
或者将局域网内的小主机frp(内网穿透)出去提供服务。(相册部署都是一样的方法,只是我采用的是frp方式,因此这里仅记录一下)
关于如何部署frp,请看如下文章:
《实战:docker式部署frp内网穿透-2024.7.13(测试成功)》:https://wiki.onedayxyy.cn/docs/docker-install-frp
- 自己nuc小主机frp配置
vim frpc.ini
[filesite-photo]
type = tcp
local_ip = 127.0.0.1
local_port = 1081
remote_port = 1081
重启frpc客户端:
docker restart frpc
- 自己公网ecs上Nginx配置
vim /etc/nginx/nginx.conf
user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
gzip on; # 启用 gzip 压缩
gzip_vary on; # 根据请求中的 `Accept-Encoding` 响应头决定是否启用 gzip
gzip_proxied any; # 在所有代理请求中启用压缩
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; # 指定哪些类型的响应需要压缩
gzip_comp_level 5; # 压缩等级(范围是 1-9,高级别意味着更好的压缩但会消耗更多 CPU 资源)
gzip_min_length 256; # 只对超过给定长度的响应启用压缩
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
charset utf-8;
# Settings for a TLS enabled server.
}
cat /etc/nginx/conf.d/photo.conf
server {
listen 80;
server_name photo.onedayxyy.cn;
#配置https重定向
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name photo.onedayxyy.cn;
#root /root/home3.0;
#location / {
# index index.html index.htm;
#}
location / {
proxy_pass http://47.100.215.163:1081/; # 实际的后台路径
client_max_body_size 100M;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
ssl_certificate "cert/fullchain1.pem";
ssl_certificate_key "cert/privkey1.pem";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
#ssl_ciphers HIGH:!aNULL:!MD5;
#自定义设置使用的TLS协议的类型以及加密套件(以下为配置示例,请您自行评估是否需要配置)
#TLS协议版本越高,HTTPS通信的安全性越高,但是相较于低版本TLS协议,高版本TLS协议对浏览器的兼容性较差。
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
重启nginx:systemctl -s reload
- 验证
总结
以上,关于自己的家庭相册就完美解决了。
我只需要维护winodws本地照片(增加、修改、删除等等),然后就会自动刷新云端照片的,而不需要维护2份数据。
为了数据安全性,我windows本地相册数据是放在百度云同步空间
的哦,也对数据安全性做了保障,完美。😜
FAQ
作者docker方式部署
2024年9月10日更新(这里仅做记录)
windows下,用docker volume 挂载, 分别对应图片目录和runtime目录, 启动容器后,测试:
- 动态添加图片
- 动态添加README_copyright.txt
- 动态添加README_title.txt
- 在runtime/目录下动态添加custom_password.json
- 修改custom_config.json
每次操作后点网页右上角刷新图标, 清空缓存后刷新网页, 所有功能都正常
关于我
我的博客主旨:
- 排版美观,语言精炼;
- 文档即手册,步骤明细,拒绝埋坑,提供源码;
- 本人实战文档都是亲测成功的,各位小伙伴在实际操作过程中如有什么疑问,可随时联系本人帮您解决问题,让我们一起进步!
🍀 微信二维码
x2675263825 (舍得), qq:2675263825。
🍀 微信公众号
《云原生架构师实战》
🍀 个人主页:
🍀 知识库:
🍀 博客:
🍀 csdn
https://blog.csdn.net/weixin_39246554?spm=1010.2135.3001.5421
🍀 知乎
https://www.zhihu.com/people/foryouone
往期推荐
QQ群
玩转Typora+Docusuaurus+起始页
交流群:(欢迎小伙伴一起探讨有趣的IT技术,来完成一些漂亮的项目)
我的开源项目:
https://wiki.onedayxyy.cn/docs/OpenSource
- typora皮肤
https://wiki.onedayxyy.cn/docs/typora
- 起始页
- 知识库
- 博客
- 家庭相册
最后
好了,关于本次就到这里了,感谢大家阅读,最后祝大家生活快乐,每天都过的有意义哦,我们下期见!