juechafun/Untitled 22.md

138 lines
2.4 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.

---
#领域/未知
#复盘/0 #临时/备忘 #状态/待处理
20260310-备忘-主题名-文件内容
## 一句话描述
[__发布obsidian______]
---
docker-compose.yaml
```yaml
volumes:
  obsidian-vault:
    external: true
services:
  # 2. Quartz 构建服务(修复目录操作)
  quartz-builder:
    image: ghcr.io/jackyzha0/quartz:latest
    container_name: quartz-builder
    restart: no
    volumes:
      - obsidian-vault:/vault
    command: |
      /bin/sh -c "
        # 只清理 public 内容,不删目录
        # 执行构建
        apt update && apt install git -y && apt clean && rm -rf /var/lib/apt/lists/*;
        cd /tmp;
        git clone https://gitea.juecha.fun/chen/juechafun.git;
        cd /usr/src/app/;
        rm -rf content;
        mv /tmp/juechafun content;
        rm -rf content/01-*;
        rm -rf content/05-*;
        rm -rf content/202602*;
        rm -rf content/Untitled*;
        rm -rf content/Untitled*;
        rm -rf content/健康运动*;
        rm -rf content/模板*;
        npx quartz build;
        mv public/* /vault
        echo 'Quartz 构建完成';
      "
  # 3. Nginx Web 服务
  web-server:
    image: nginx:alpine
    container_name: quartz-web
    restart: unless-stopped
    ports:
      - 30082:80
    volumes:
      - obsidian-vault:/usr/share/nginx/html:ro
      - ./default.conf:/etc/nginx/conf.d/default.conf:ro
    depends_on:
      quartz-builder:
        condition: service_completed_successfully
networks: {}
```
default.conf
```conf
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html; # 你的网站根目录(和容器挂载路径一致)
index index.html index.htm;
# 核心:自动补全 .html 后缀的配置
location / {
# 规则解读:
# 1. 先尝试访问原请求路径(如 /03-资源/xxx
# 2. 若不存在,尝试补全 .html 后缀(如 /03-资源/xxx.html
# 3. 若仍不存在,尝试作为目录访问(如 /03-资源/xxx/
# 4. 以上都不存在,返回 404
try_files $uri $uri.html $uri/ =404;
# 可选:支持中文/特殊字符路径的 URL 编码解析
charset utf-8; # 确保 Nginx 识别 UTF-8 编码的中文路径
}
}
```