# Hugo + Docsy compose.yaml # 用法: # 初始化新站点: docker compose run --rm init # 开发预览: docker compose up server # 构建静态文件: docker compose run --rm build services: # ── 1. 初始化站点(仅首次执行)────────────────────────────────────── init: build: ./hugo working_dir: /src volumes: - ./site:/src environment: GOPROXY: https://goproxy.io,https://goproxy.cn,direct GONOSUMDB: "*" GOFLAGS: "-mod=mod" entrypoint: /bin/sh command: - -c - | set -e if [ -f hugo.toml ]; then echo "hugo.toml already exists, skip init." exit 0 fi hugo new site . --force hugo mod init github.com/me/my-docsy-site printf 'module github.com/me/my-docsy-site\n\ngo 1.21\n\nrequire github.com/google/docsy v0.12.0\n\nreplace (\n\tgithub.com/google/docsy => /opt/docsy\n\tgithub.com/twbs/bootstrap => /opt/bootstrap\n\tgithub.com/FortAwesome/Font-Awesome => /opt/fontawesome\n)\n' > go.mod hugo mod tidy printf '{"dependencies":{"autoprefixer":"^10.4.14","postcss":"^8.4.24","postcss-cli":"^10.1.0"}}' > package.json npm install --ignore-scripts --registry https://registry.npmmirror.com printf '\n[module]\n proxy = "https://goproxy.io,https://goproxy.cn,direct"\n [module.hugoVersion]\n extended = true\n min = "0.146.0"\n [[module.imports]]\n path = "github.com/google/docsy"\n disable = false\n' >> hugo.toml echo "Site initialized. Run: docker compose up server" # ── 2. 开发服务器(热重载)────────────────────────────────────────── server: build: ./hugo working_dir: /src volumes: - ./site:/src - hugo_cache:/tmp/hugo_cache - pdf_store:/src/static/pdfs - excel_html_store:/src/static/excels - word_html_store:/src/static/words ports: - "1313:1313" environment: HUGO_CACHEDIR: /tmp/hugo_cache GOPROXY: "off" GONOSUMDB: "*" GOFLAGS: "-mod=mod" command: server --bind 0.0.0.0 --port 1313 --baseURL / --disableFastRender --poll 700ms restart: unless-stopped networks: - docsy_bridge # ── 3. 生产构建(输出到 site/public)─────────────────────────────── build: build: ./hugo working_dir: /src volumes: - ./site:/src - hugo_cache:/tmp/hugo_cache - site_public:/src/public - word_html_store:/src/static/words environment: HUGO_CACHEDIR: /tmp/hugo_cache HUGO_ENV: production GOPROXY: "off" GONOSUMDB: "*" GOFLAGS: "-mod=mod" command: --minify --gc --baseURL / # ── 4. Nginx 静态文件托管(生产预览)─────────────────────────────── nginx: image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/nginx:alpine volumes: - site_public:/usr/share/nginx/html:ro - pdf_store:/data/pdfs:ro - excel_html_store:/data/excels:ro - word_html_store:/data/words:ro - excel_store:/data/raw_excels:ro - word_store:/data/raw_words:ro - uploads_store:/data/uploads:ro - ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro ports: - "8080:80" depends_on: build: condition: service_completed_successfully restart: unless-stopped networks: - docsy_bridge # ── 5. Filebrowser 文件上传管理 ───────────────────────────────────── filebrowser: image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/filebrowser/filebrowser:latest volumes: - uploads_store:/srv - pdf_store:/srv/pdfs - excel_store:/srv/excels - excel_html_store:/srv/excels_html:ro - word_html_store:/srv/words_html:ro - word_store:/srv/words - ./site/content:/srv/content - filebrowser_data:/database - ./filebrowser/settings.json:/.filebrowser.json restart: unless-stopped networks: - docsy_bridge # ── 5b. Filebrowser 预览代理(8081)──────────────────────────────── filebrowser_proxy: image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/nginx:alpine volumes: - ./filebrowser-proxy:/etc/nginx/conf.d:ro - /home/fxapp/log.png:/opt/fb-assets/log.png:ro depends_on: - filebrowser ports: - "8081:80" restart: unless-stopped networks: - docsy_bridge # ── 6. Excel → HTML 自动转换器 ─────────────────────────────────────── # ── 7. Word(docx) → HTML 自动转换器 ───────────────────────────────── # ── 8. OnlyOffice 文档预览/编辑服务 ─────────────────────────────── onlyoffice: image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/onlyoffice/documentserver:latest environment: JWT_ENABLED: "false" TZ: Asia/Shanghai ports: - "8090:80" volumes: - onlyoffice_data:/var/www/onlyoffice/Data - onlyoffice_log:/var/log/onlyoffice - onlyoffice_lib:/var/lib/onlyoffice - onlyoffice_db:/var/lib/postgresql - ./onlyoffice/local.json:/etc/onlyoffice/documentserver/local.json:ro - ./onlyoffice/ds-docservice.conf:/etc/nginx/includes/ds-docservice.conf:ro restart: unless-stopped networks: - docsy_bridge volumes: hugo_cache: site_public: pdf_store: filebrowser_data: excel_store: excel_html_store: word_store: uploads_store: word_html_store: onlyoffice_data: onlyoffice_log: onlyoffice_lib: onlyoffice_db: networks: docsy_bridge: driver: bridge name: hugo_docsy_bridge