Skip to content

feat: Docker 构建与 Compose、Redis 集成及子路径部署支持#16

Open
hsmustard wants to merge 1 commit intohelloxz:mainfrom
hsmustard:feat/docker-redis-subpath
Open

feat: Docker 构建与 Compose、Redis 集成及子路径部署支持#16
hsmustard wants to merge 1 commit intohelloxz:mainfrom
hsmustard:feat/docker-redis-subpath

Conversation

@hsmustard
Copy link

@hsmustard hsmustard commented Feb 26, 2026

变更概述

本 PR 对 Zurl 的部署与运行方式做了以下改进:

  1. Docker 构建

    • 基础镜像改为 python:3.12-slim,在镜像内使用 Node.js/pnpm 构建前端,构建完成后移除前端源码与 Node 以缩小镜像体积。
    • 支持通过构建参数 BASE_URL 在构建时指定前端静态资源与 API 的根路径,便于子路径部署。
  2. Docker Compose 与 Redis

    • 新增 Redis 服务,与 Zurl 一同通过 docker-compose 启动。
    • Zurl 通过环境变量 REDIS_HOSTREDIS_PORTREDIS_DBREDIS_PASSWORD 连接 Redis;未设置时从 config.toml[redis] 读取。
    • 运行脚本 run.sh 改为仅启动应用进程,Redis 由 Compose 或外部单独提供。
  3. 子路径部署(BASE_URL)

    • 后端支持通过环境变量 BASE_URL 或配置中的 app.BASE_URL 设置子路径(如 /zurl),静态资源与路由均挂载到该路径下。
    • 前端构建时使用 VITE_BASE_URL(与 BASE_URL 一致),便于在反向代理后以子路径访问。
  4. 配置与数据

    • config.simple.toml 增加 [redis]app.BASE_URL 示例。
    • 新增 Alembic 迁移,将历史数据中 urls.is_active 为 NULL 的记录设为 1,保证启用/禁用与旧数据兼容。
  5. 文档

    • 更新 README.mdREADME_zh.md:安装方式改为推荐使用项目内 docker-compose.yaml(含 Redis),并补充 Redis、BASE_URL 的配置说明及子路径部署说明。

Summary of Changes

This PR improves how Zurl is built and run:

  1. Docker build

    • Base image is now python:3.12-slim. The frontend is built inside the image with Node.js/pnpm; after the build, frontend source and Node are removed to reduce image size.
    • Build arg BASE_URL is supported so the frontend and API base path can be set at build time for subpath deployment.
  2. Docker Compose and Redis

    • A Redis service is added and started together with Zurl via docker-compose.
    • Zurl connects to Redis using env vars REDIS_HOST, REDIS_PORT, REDIS_DB, REDIS_PASSWORD; if unset, config is read from [redis] in config.toml.
    • run.sh now only starts the app process; Redis is expected to be run by Compose or externally.
  3. Subpath deployment (BASE_URL)

    • The backend supports a subpath (e.g. /zurl) via env BASE_URL or app.BASE_URL in config. Static files and routes are mounted under that path.
    • The frontend is built with VITE_BASE_URL matching BASE_URL so the app can be served under a subpath behind a reverse proxy.
  4. Config and data

    • config.simple.toml includes [redis] and app.BASE_URL examples.
    • A new Alembic migration sets urls.is_active = 1 where it was NULL for legacy data, so enable/disable behavior stays compatible.
  5. Docs

    • README.md and README_zh.md are updated: installation now recommends the project’s docker-compose.yaml (with Redis) and document Redis, BASE_URL, and subpath deployment.

@hsmustard hsmustard closed this Feb 26, 2026
@hsmustard hsmustard deleted the feat/docker-redis-subpath branch February 26, 2026 14:40
@hsmustard hsmustard restored the feat/docker-redis-subpath branch February 26, 2026 14:41
@hsmustard hsmustard reopened this Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant