已安装
docker
compose
新建目录memos
,新建文件docker-compose.yml
version: "3.0"
services:
memos:
image: ghcr.io/usememos/memos:0.18.0
container_name: memos
restart: always
volumes:
- ./memos/:/var/opt/memos
environment:
- MEMOS_DRIVER=mysql
- MEMOS_DSN=root:password@tcp(db:3306)/memos_prod
command: ["--metric=false"]
depends_on:
- db
db:
image: mysql:8.2.0
container_name: mysql
restart: always
env_file: .db.env
volumes:
- ./mysql_data:/var/lib/mysql
caddy:
image: caddy:2.7.5
container_name: caddy
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- ./caddy/site:/srv
- ./caddy/caddy_data:/data
- ./caddy/caddy_config:/config
depends_on:
- memos
创建.db.env
,修改为自己的数据库密码
MYSQL_RANDOM_ROOT_PASSWORD=yes
MYSQL_DATABASE=memos_prod
MYSQL_USER=yourusername
MYSQL_PASSWORD=yourpassword
创建Caddyfile
,memos
修改为你的域名
memos.com {
reverse_proxy memos:5230
}
执行docker-compose up -d
启动
访问域名打开网站,设置一个管理员账户
修改发文字体为其他
@font-face {
font-family: 'font';
src: url('https://www.font.woff') format('woff');
}
.memo-content-text {
font-family: 'font', sans-serif;
}
详细教程Configuring Cloudflare R2 Storage - Memos
存储路径处可以设置{year}/{month}/{timestamp}_{filename}
以文件夹方式存储保存在R2上的内容
1.tag
使用
支持#hello
#hello/haha
后面加一个空格即可
自托管最重要的就是数据备份了,写了个简单的脚本,利用mysqldump
导出
#!/bin/bash
BACKUPPASS="setBACKUPPASS"
BACKUPDIR="/path/to/backup"
# 使用 mysqldump 备份
echo "开始备份"
docker exec mysql bash -c 'mysqldump -u root --password="password" --no-tablespaces "memos_prod"' > $BACKUPDIR/memos-db-$(date '+%F').sql
echo "备份完成"
#加密文件
echo "开始加密"
7z a -p$BACKUPPASS -mhe=on $BACKUPDIR/memos-db-$(date '+%F').7z $BACKUPDIR/memos-db-$(date '+%F').sql
echo "加密完成"
echo -e '\ndocker pull togettoyou/ghcr.io.usememos.memos:0.17.1\ndocker tag togettoyou/ghcr.io.usememos.memos:0.17.1 ghcr.io/usememos/memos:0.17.1' | bash
详见:[hub-mirror] 请求执行任务 · Issue #1515 · togettoyou/hub-mirror · GitHub