Files
Quic/README.md
T

141 lines
3.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# gallery.fukun.net
基于 [Photoview](https://github.com/photoview/photoview) 定制的个人相册,部署在腾讯云 `62.234.90.54`。
---
## 访问
| 地址 | 说明 |
|------|------|
| `https://gallery.fukun.net` | 管理后台(需登录) |
| `https://cdn.fukun.net/gallery/photos/...` | CDN 公开原图 |
---
## 定制项(与上游 Photoview 的差异)
- **品牌** — 左上角 FK 书法 logo,页面标题 `Gallery.FuKun.Net`
- **外观** — 纯黑背景 (`#000`),菜单图标改为极简线条
- **字体** — iA Writer Quattro S + Noto Sans SC(与主站 fukun.net 一致)
- **CDN** — 公开原图走 `cdn.fukun.net`,带 token 的鉴权图片自动切 CDN
- **无 Docker** — Go 二进制 + systemd,SQLite 单文件数据库
- **人脸识别** — 已关闭(`PHOTOVIEW_DISABLE_FACE_RECOGNITION=1`)
---
## 目录结构
```
/home/gallery/
├── photoview-src/ # 源码 + 编译产物
│ ├── api/
│ │ ├── .env # 运行时环境变量
│ │ └── photoview # Go 二进制(38MB)
│ └── ui/
│ └── dist/ # 前端构建产物
├── photos/ # 相片库根目录
└── data/
├── photoview.db # SQLite 数据库
└── media-cache/ # 缩略图缓存
```
---
## 本地开发
> 后端依赖 Linux C 库(dlib/libheif/ImageMagick),无法在 Windows 本地运行。
> 只能改前端代码,API 指向生产环境。
```bash
git clone ssh://git@fukun.net/data/git-repos/gallery.git
cd ui
cat > .env << EOF
REACT_APP_API_ENDPOINT=https://gallery.fukun.net/api/
REACT_APP_BUILD_VERSION=dev
REACT_APP_BUILD_DATE=$(date -u +%Y-%m-%d)
REACT_APP_BUILD_COMMIT_SHA=local
EOF
npm ci
npm run dev # localhost:1234,API 连生产服务器
```
---
## 部署到服务器
```bash
# 构建前端
scp -r ui/src ui/public ubuntu@62.234.90.54:/tmp/pv-ui/
ssh ubuntu@62.234.90.54 '
sudo cp -r /tmp/pv-ui/* /home/gallery/photoview-src/ui/
sudo chown -R gallery:gallery /home/gallery/photoview-src/ui
sudo -u gallery bash -c "cd /home/gallery/photoview-src/ui && npm ci && npm run build"
'
# 构建后端 + 重启
ssh ubuntu@62.234.90.54 '
cd /home/gallery/photoview-src/api
export PKG_CONFIG_PATH=/usr/local/im7/lib/pkgconfig CGO_ENABLED=1
sudo -u gallery go build -o photoview .
sudo systemctl restart photoview
'
```
---
## 运行时配置
**systemd** — `/etc/systemd/system/photoview.service`
| 环境变量 | 值 |
|----------|-----|
| `PHOTOVIEW_DATABASE_DRIVER` | `sqlite` |
| `PHOTOVIEW_SQLITE_PATH` | `/home/gallery/data/photoview.db` |
| `PHOTOVIEW_LISTEN_IP` | `127.0.0.1` |
| `PHOTOVIEW_LISTEN_PORT` | `8000` |
| `PHOTOVIEW_SERVE_UI` | `1` |
| `PHOTOVIEW_UI_PATH` | `/home/gallery/photoview-src/ui/dist` |
| `PHOTOVIEW_MEDIA_CACHE` | `/home/gallery/data/media-cache` |
| `PHOTOVIEW_DISABLE_FACE_RECOGNITION` | `1` |
| `LD_LIBRARY_PATH` | `/usr/local/im7/lib` |
**Nginx** — `/etc/nginx/sites-enabled/gallery.fukun.net`
- `gallery.fukun.net` + `cdn.fukun.net` → HTTPS → `127.0.0.1:8000`
- `/photos/` → `alias /home/gallery/photos/`(CDN 回源口)
- `/assets/` → 缓存 30 天
**SSL 证书** — 腾讯云证书,`/etc/nginx/ssl/gallery.fukun.net_*`
---
## 维护
```bash
# 查看状态
sudo systemctl status photoview
sudo journalctl -u photoview -f
# 重启
sudo systemctl restart photoview
# 备份数据库
sudo cp /home/gallery/data/photoview.db /opt/backup/photoview_$(date +%Y%m%d).db
# 上传照片
scp *.jpg ubuntu@62.234.90.54:/home/gallery/photos/
```
---
## 仓库
```
ssh://git@fukun.net/data/git-repos/gallery.git
```
服务器上 `/data/git-repos/gallery.git`(bare),推送到 `master`。