Skip to content

部署

实战-docker部署全网最美个人相册machete-2024.12.19(测试成功)

image-20241219065243694

目录

[toc]

版权

本着开源共享、共同学习的精神:

本文是根据 开源站点:《家庭相册-filesite-io》里提供的部署文档进一步编辑输出的 ,具体信息请看 原作者github开源仓库。转载无需和我联系,但请注明文章来源。如果侵权之处,请联系博主进行删除,谢谢~

官网:https://jialuoma.com/

仓库地址:https://github.com/filesite-io/machete

image-20240807124010055

demo演示

https://photo.onedayxyy.cn/

image-20240813153759698

背景

你想拥有一个家庭相册吗?里面可以放你的摄影作品、家人照片、旅拍作品等等……

恰好这个相册部署简单,体验丝滑,数据安全,那么选择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

环境

bash
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

image-20241218065457156

说明:

这里之所以把镜像打包提供,是为了对数据进行备份。还是建议大家从 官网仓库 获取镜像。

1、部署

docker-compose版本:(推荐)

bash
#本地虚机版
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

#自定义配置
cat > /root/machete/runtime/custom_config.json <<EOF
{
    "theme": "beauty",
    "content_directory": "girls/",
    "enableSmallImage": false,
    "showQRImageInFooter": false,
    "adminForLanIps": true,
    "adminWhiteIps": [
        "127.0.0.1",
        "192.168.1.100",
        "183.192.139.190"
    ],
    "slide_show_timeout": 5,
    "showVersion": true
}
EOF

#自定义加密目录
cat > /root/machete/runtime/custom_password.json <<EOF
{
    "password_auth": {
        "enable": true,
        "default": "",
        "allow": {
            "5-加密目录": "123456"
        }
    }
}
EOF

#设置权限
chmod -R 777 runtime/
docker pull filesite/machete
docker-compose up -d
docker ps

#备注:
#photo:存放本地相册数据的;
#runtime目录用来缓存相册封面、缩略图、缓存的,这里做了持久化,即使以后容器删除后,再次新起的容器,相册封面也是在的;(目录封面图缓存和缩略图缓存都在目录runtime/cache里)

配置文件相关选项含义说明:

bash
"enableSmallImage": false, #所有图片使用原图而不是缩略图
"enableSmallImageForWan": "true", #开启查看大图显示缩略图
"showQRImageInFooter": false,	#关闭网页底部的二维码
"adminForLanIps","adminWhiteIps" #增加内网ip和ip白名单设置
"slide_show_timeout": 5, #设置自动播放时每张照片停留时间
"showVersion": true #显示版本号
"password_auth": #开启密码授权访问
  • 此时,到浏览器简单访问下,观察效果,可以看到数据为空(那是因为我们还没传数据呢)

在浏览器访问http://192.168.1.100:1081/

image-20240810181429530

2、同步

FreeFileSync方式同步相册数据到linux(推荐)

最终2便的相册数据:(完全一致)

image-20241218065944956

image-20241218070018349

1.安装FreeFileSync

  • winodws安装FreeFileSync_13.7_Windows_Setup

image-20240811072434170

官网链接:

https://freefilesync.org/

image-20240811072109273

下载winodws客户端:

https://freefilesync.org/download/FreeFileSync_13.7_Windows_Setup.exe

image-20240811072139140

安装:(一直下一步安装即可)

安装后:

image-20240811072218130

image-20240811072234365

2.同步相册数据

开始同步:

同步前,我们先来做下比较,发现远程目录都为空。

image-20240811071239186

这里选择镜像把本地数据同步到linux服务器:

image-20240811071406785

点击同步:

image-20240811071447999

此时已经同步完了。

image-20240811071533650

3、验证

  • 验证

此时,发现同步上来的文件权限、属主、属组都是欧克的,完美。😜

image-20241218070105633

可以再做一次数据比较,发现2边数据是完全欧克的。

image-20240811071700031

  • 此时访问web

http://192.168.1.100:1081/

image-20241218070154881

至此,完美。😜

4、扩展

以上是在本地局域网相册的部署方式,如果是把相册部署在云服务器上,请按如下方式配置:

和本地版部署相比,这里只加了个 "enableSmallImageForWan": "true",选项。

bash
#云服务器版:
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

#自定义配置
cat > /root/machete/runtime/custom_config.json <<EOF
{
    "theme": "beauty",
    "content_directory": "girls/",
    "enableSmallImageForWan": "true",
    "showQRImageInFooter": false,
    "adminForLanIps": true,
    "adminWhiteIps": [
        "127.0.0.1",
        "192.168.1.100",
        "183.192.139.190"
    ],
    "slide_show_timeout": 5,
    "showVersion": true
}
EOF

#自定义加密目录
cat > /root/machete/runtime/custom_password.json <<EOF
{
    "password_auth": {
        "enable": true,
        "default": "",
        "allow": {
            "5-加密目录": "123456"
        }
    }
}
EOF

#设置权限
chmod -R 777 runtime/
docker pull filesite/machete
docker-compose up -d
docker ps

#备注:
#photo:存放本地相册数据的;
#runtime目录用来缓存相册封面、缩略图、缓存的,这里做了持久化,即使以后容器删除后,再次新起的容器,相册封面也是在的;(目录封面图缓存和缩略图缓存都在目录runtime/cache里)

含义说明:

bash
"enableSmallImageForWan": "true", #开启查看大图显示缩略图
  • 配置云服务器nginx

vim /etc/nginx/conf.d/photo.onedayxyy.cn.conf

bash
    server {
        listen 80;
        server_name  photo.onedayxyy.cn;

        #配置https重定向
        return 301 https://$host$request_uri;
    }


    server {
        listen       443 ssl;
        listen       [::]:443 ssl;
        server_name photo.onedayxyy.cn;

        #root /root/home3.0;
    
        #location / {
        #    index index.html index.htm;
        #}    


        location / {
            proxy_pass http://云服务器ip: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             /etc/letsencrypt/live/onedayxyy.cn/fullchain.pem;
    	ssl_certificate_key         /etc/letsencrypt/live/onedayxyy.cn/privkey.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 {
        }
    }
  • 配置域名解析

image-20241218100855805

  • cdn配置

image-20241218101020524

image-20241218101058453

本次相册配置:

image-20241218101139966

image-20241218101158933

image-20241218101234684

image-20241218101250155

  • 此时,利用域名测试,打开图片的速度就很快了😂

https://photo.onedayxyy.cn/

image-20241219065243694

image-20241218101520102

the end。

总结

以上,关于自己的家庭相册就完美解决了。

我只需要维护winodws本地照片(增加、修改、删除等等),然后就会自动刷新云端照片的,而不需要维护2份数据。

为了数据安全性,我windows本地相册数据是放在百度云同步空间的哦,也对数据安全性做了保障,完美。😜

关于我

我的博客主旨:

  • 排版美观,语言精炼;
  • 文档即手册,步骤明细,拒绝埋坑,提供源码;
  • 本人实战文档都是亲测成功的,各位小伙伴在实际操作过程中如有什么疑问,可随时联系本人帮您解决问题,让我们一起进步!

🍀 微信二维码

x2675263825 (舍得), qq:2675263825。

image-20230107215114763

🍀 微信公众号

《云原生架构师实战》

image-20230107215126971

🍀 个人主页:

https://onedayxyy.cn

image-20240805214647028

🍀 知识库:

https://wiki.onedayxyy.cn/

🍀 博客:

http://blog.onedayxyy.cn/

image-20240804075845906

🍀 csdn

https://blog.csdn.net/weixin_39246554?spm=1010.2135.3001.5421

image-20230107215149885

🍀 知乎

https://www.zhihu.com/people/foryouone

image-20230107215203185

往期推荐

QQ群

玩转Typora+Docusuaurus+起始页交流群:(欢迎小伙伴一起探讨有趣的IT技术,来完成一些漂亮的项目)

我的开源项目:

项目名称我的文档我的demo作者demo
1、玩转Typorahttps://wiki.onedayxyy.cn/docs/typorahttps://wiki.onedayxyy.cn/docs/typorahttps://typoraio.cn/#
2、玩转Docusaurushttps://wiki.onedayxyy.cn/docs/mogai-docusaurushttps://wiki.onedayxyy.cn/https://www.docusaurus.cn/
3、个人主页home3.0https://wiki.onedayxyy.cn/docs/home3.0https://onedayxyy.cn/https://github.com/hsBUPT/hsBUPT.github.io
4、全网最美博客-ruyu-bloghttps://wiki.onedayxyy.cn/docs/ruyu-blog-install-one-keyhttps://blog.onedayxyy.cn/https://www.kuailemao.xyz/
5、家庭相册filesite-iohttps://wiki.onedayxyy.cn/docs/filesite.io-photot-install-fullhttps://photo.onedayxyy.cn/https://demo.jialuoma.cn/

https://wiki.onedayxyy.cn/docs/OpenSource

image-20240811063938529

  • typora皮肤

https://wiki.onedayxyy.cn/docs/typora

image-20240518165037517

  • 起始页

https://onedayxyy.cn/

image-20240814230557697

  • 知识库

https://wiki.onedayxyy.cn/

  • 博客

https://blog.onedayxyy.cn/

image-20240803162010305

  • 家庭相册

https://photo.onedayxyy.cn/

最后

好了,关于本次就到这里了,感谢大家阅读,最后祝大家生活快乐,每天都过的有意义哦,我们下期见!

最近更新