Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@TianMingNanWei
Copy link

📋 概述

本次 PR 重构了 Docker 配置,将前端服务独立出来,并为 Dockerfile 中为 Go 后端添加 SQLite 数据库支持。

🔧 主要变更

后端 Dockerfile

  • Go 版本升级至 1.24
  • 启用 CGO 并添加 SQLite 构建依赖(gcc, musl-dev, sqlite-dev)
  • 运行时添加 sqlite-libs 支持

新增前端服务

  • Dockerfile.nginx: 多阶段构建,使用 Node.js 构建 Next.js 前端,Nginx 提供静态文件服务
  • nginx-frontend.conf: 前端 Nginx 配置
    • SPA 路由支持
    • API 请求代理到后端(/api/ 及其他路由)
    • 静态资源缓存优化
    • Gzip 压缩

Docker Compose

  • 将通用 nginx 服务替换为专用 frontend 服务
  • 简化端口映射(仅保留 80 端口)
  • 移除 SSL 相关配置

🎯 优势

  • 前后端服务分离,架构更清晰
  • 后端支持 SQLite 数据库
  • 前端静态资源缓存优化,性能提升
  • 配置简化,更易部署

提交: 063c6c2f0906623c443faf7cd81807ab4e5261b8

…d service, update Dockerfile for Go backend to support SQLite, and add Dockerfile and configuration for frontend Nginx service.
Copy link
Owner

@difyz9 difyz9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢 @TianMingNanWei 的贡献!这个 PR 实现了两个重要功能:

  1. SQLite 支持 - 为轻量级部署提供选择
  2. 前后端分离 - 提升架构灵活性

变更统计: +117 −14 行


✅ 优点

1. SQLite 支持实现完善

  • ✅ 添加了必要的构建依赖(gcc musl-dev sqlite-dev
  • ✅ 正确启用 CGO 编译(CGO_ENABLED=1
  • ✅ 添加运行时库(sqlite-libs
  • ✅ 与现有代码兼容(已验证 pkg/store/database.go 支持 SQLite)

2. 架构设计合理

  • ✅ 前后端容器解耦,便于独立扩展
  • ✅ 多阶段构建优化镜像体积
  • ✅ Nginx 配置包含 gzip 压缩和缓存策略

3. Docker Compose 配置改进

  • ✅ 前端服务独立化
  • ✅ 服务依赖关系明确

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.

2 participants