51 Commits

Author SHA1 Message Date
向宁
7faddfed05 feat: add shared sanitize and s3errors packages 2026-05-25 12:52:39 +08:00
向宁
b9b5838938 chore: add Kratos, Watermill, GORM, Wire dependencies for migration
Add new framework dependencies needed for the Gin-to-Kratos migration:
- go-kratos/kratos/v2 (HTTP/gRPC transport, config, middleware, JWT auth)
- google/wire (compile-time dependency injection)
- ThreeDotsLabs/watermill + watermill-sql/v2 (event-driven CQRS)
- gorm.io/gorm + gorm.io/driver/postgres (PostgreSQL ORM)

The old Gin/Swagger deps remain as direct deps since existing code still
imports them. They will be removed in later migration tasks when code is
rewritten. Blank imports in internal/deps.go ensure go mod tidy keeps
the new deps until actual code imports them directly.
2026-05-25 12:51:26 +08:00
向宁
1cfa43a33c feat: define file service proto API with HTTP+gRPC annotations 2026-05-25 12:45:35 +08:00
向宁
ed47904a85 chore: initialize Kratos project skeleton, add proto config and Makefile
- Add Makefile with api/config/wire/build/run/test/clean targets
- Update buf.yaml with api, internal/conf, and third_party modules
- Update buf.gen.yaml with protobuf, grpc, and grpc-gateway plugins
- Add internal/conf/conf.proto (Kratos config schema: Bootstrap/Server/Data/Auth)
- Generate internal/conf/conf.pb.go via buf
- Add configs/config.yaml with HTTP/gRPC server, Postgres, S3, and auth settings
- Add third_party/google/api proto files (annotations, http)
- Remove old Gin-based layers: internal/api, internal/infrastructure/mediator,
  internal/middleware, internal/common, docs
- Update .gitignore to exclude server binary and bin/
2026-05-25 12:37:45 +08:00
向宁
654b7d9bb6 chore: initial commit before Kratos migration 2026-05-25 12:29:31 +08:00
向宁
3a18ca0579 feat: add directory structure and file sharing support
- PostgreSQL metadata overlay layer on top of existing S3 storage
- 3 new tables: folders, files, share_links
- Folder CRUD: create, get with children, tree, rename, delete (cascade)
- File operations: upload to folder, move between folders
- Share links: create with optional password/expiry/download limit, public access
- S3 compensation on PG write failure
- Existing 14 endpoints untouched
2026-05-20 20:26:19 +08:00
向宁
2b2618f18c fix: change file-system port from 8080 to 8090
Port 8080 is occupied on the host. Move to 8090 to avoid conflict.
2026-05-17 22:36:47 +08:00
向宁
8b08a70dca fix: add required env vars and network_mode host to deploy
- Add S3 credentials, auth config, and OTel endpoint
- Switch from port mapping to network_mode: host
- Fixes container crash on missing AUTH_API_KEY
2026-05-17 22:32:47 +08:00
向宁
5f3d84a89b fix: remove web dir from Dockerfile, fix healthcheck path
web/ was deleted in previous refactoring. Healthcheck now uses /health
endpoint instead of /web.
2026-05-17 22:28:01 +08:00
向宁
c17d7c2c29 fix: include Swagger docs in Docker build
Remove docs from .dockerignore and track generated swagger files
in git so they're available in the Docker build context.
2026-05-17 22:23:41 +08:00
向宁
b5df6445e5 refactor: commit all pending file_system changes
- Restructure handlers into file_commands/file_queries/file_handlers
- Add gRPC auth client, JWT middleware, rate limiting, request ID
- Add common utilities: logger, sanitizer, s3_errors
- Add unit tests for config, mediator, auth, request_id, sanitize
- Add proto definitions and generated code
- Remove old web UI pages
- Add .dockerignore and .env.example
2026-05-17 22:20:02 +08:00
向宁
5e20a6d7fc fix: upgrade Dockerfile to Go 1.25, use Docker Hub base images
go.mod requires Go 1.25 (gin-contrib/cors v1.7.7 dependency).
Switch from private registry to Docker Hub for base images since
they're public and the registry only has Go 1.24.
2026-05-17 22:14:17 +08:00
向宁
d3015d63f2 feat: add OpenTelemetry tracing, metrics, and logging
- Create internal/common/otel.go with InitOTel() for tracing + metrics + logs
- Add otelgin middleware for automatic Gin HTTP span creation
- Add OTelEndpoint config (default: 192.168.1.154:4316)
- Export all signals via OTLP gRPC to OTel Collector
2026-05-17 22:08:03 +08:00
root
d861be0d6e feat: 新增文件文本内容接口,修复Markdown预览
- 新增 GET /files/content 接口,后端直接读取S3文件文本内容返回
- Repository 新增 GetFileContent 方法
- CQRS: 新增 GetFileContentQuery / GetFileContentHandler
- 前端 Markdown 预览改为调用后端接口获取内容,用 marked.js 渲染
- 解决 presigned URL CORS 和下载头导致 MD 文件无法预览的问题
- config.go: AuthAPIKey 默认值恢复为 xn001624.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-06 18:08:42 +08:00
8c180082d5 fix: healthcheck path /swagger/index.html -> /web 2026-05-06 18:06:32 +08:00
root
f5a906a208 feat: 修复API密钥默认值 & 添加Markdown文件预览支持
- config.go: AuthAPIKey 默认值从空字符串恢复为 xn001624.
- index.html: 引入 marked.js,支持 .md/.markdown 文件渲染预览
- 新增 markdown 预览类型,自动获取内容并渲染为 HTML
- 文件图标识别 md 文件显示为代码文件图标

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-06 15:25:05 +08:00
c2111e5473 refactor: optimize Dockerfile with pre-built golang base image 2026-05-05 17:32:57 +08:00
root
9efd78aaff fix: 修正 RustFS 连接地址,移除硬编码密钥
- 修正 RustFS 端点地址为 192.168.1.154:9000(对应服务器实际部署)
- 移除 config.go 中硬编码的 AccessKey/SecretKey 默认值,改为环境变量传入
- 移除 middleware/auth.go 中硬编码的 API_KEY_VALUE 常量,改为参数注入
- 新增 Config.AuthAPIKey 字段,通过 AUTH_API_KEY 环境变量配置
- 移除 login.html 页面上的密钥格式提示,防止信息泄露
- docker-compose.yml 补全 RustFS 连接所需的环境变量

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-05 17:02:01 +08:00
58cfd917c1 fix: replace cleanWs with deleteDir in Jenkinsfile 2026-05-05 16:35:33 +08:00
236afb5628 feat: add Jenkinsfile for Pipeline CI/CD 2026-05-05 16:13:55 +08:00
root
54f66c56ed feat: 添加 Web UI 登录功能
为 Web UI 添加完整的登录验证系统,遵循 CQRS 架构模式。

主要功能:
- 创建登录页面 UI (web/login.html)
  - 美观的渐变背景设计
  - 密钥输入和验证
  - 错误提示和加载状态

- 实现登录验证 (遵循 CQRS)
  - 新增 LoginQuery 和 LoginHandler (internal/api/handlers/auth_handlers.go)
  - 新增 AuthEndpoint (internal/api/endpoints/auth_endpoints.go)
  - 注册登录接口 /auth/login (无需授权)

- 更新主页面 (web/index.html)
  - 添加登录状态检查
  - 未登录显示提示信息
  - 所有 API 请求自动携带 X-API-Key 头
  - 添加退出登录功能
  - 401 错误自动跳转登录页

- 更新路由配置 (cmd/server/main.go)
  - 添加 /auth/login 公开路由
  - 注册登录处理器和端点

- 新增登录文档 (docs/LOGIN_GUIDE.md)
  - 完整的使用说明
  - 技术实现细节
  - API 接口说明

安全特性:
- 密钥存储在 localStorage
- 自动处理登录过期
- 支持主动退出登录

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-05 20:27:45 +08:00
root
98a3701d54 docs: 更新 README.md 文档
完整重写项目文档,包含以下内容:

主要更新:
- 添加项目介绍和功能特性说明
- 新增 API 授权章节,说明密钥验证机制
- 提供完整的 API 接口列表和使用示例
- 添加项目结构说明和配置指南
- 包含开发、部署和测试指南
- 更新版本日志

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-05 20:23:49 +08:00
root
8a01af8953 chore: 添加 .gitignore 文件 2026-01-05 20:22:25 +08:00
root
11fc10ba8a feat: 添加API授权中间件
为所有API接口添加授权验证,要求请求头中包含有效的API密钥才能访问。

主要变更:
- 新增授权中间件 (internal/middleware/auth.go)
  - 验证 X-API-Key 请求头
  - 密钥值为 xn001624.
  - 无效密钥返回 401 Unauthorized

- 更新路由配置 (cmd/server/main.go)
  - 使用路由组统一应用授权中间件
  - 保护所有文件和存储桶操作接口
  - Swagger 和 Web UI 保持公开访问

- 新增授权使用文档 (docs/AUTH_GUIDE.md)
  - 多语言使用示例 (cURL, JavaScript, Python)
  - 完整的错误说明和授权范围

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-05 20:22:04 +08:00
root
5b66e7d3e7 修改 s3 地址 2026-01-05 19:51:19 +08:00
root
20e9e36d29 docs:更新swagger 文档 2025-12-27 10:44:50 +08:00
root
00a0e583a8 添加存储桶删除功能
- 新增 DeleteBucketHandler 处理存储桶删除请求
- 添加 DELETE /buckets API 端点
- 在前端界面添加删除存储桶按钮功能
- 添加存储桶删除请求验证器

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-19 16:40:09 +08:00
root
71a5ea5f41 添加文件删除功能 2025-12-19 16:32:20 +08:00
root
c565eb25af Fix deployment stage: add docker-cli installation
- Install docker-cli before docker-compose in deployment stage
- Fix 'docker: not found' error in deploy_service job
- Ensure both docker and docker-compose are available

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-19 10:58:55 +08:00
root
0904060f0c Fix deployment stage: use alpine image and install docker-compose
- Change from non-existent docker/compose image to alpine
- Install docker-compose package in before_script
- Fix deployment stage image pull error

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-19 10:42:49 +08:00
root
04b689fc95 Fix Dockerfile: add file package installation
- Add file package to runtime environment
- Fix build error where file command was not found

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-19 10:39:10 +08:00
root
3e1f4083b9 Fix deployment configuration and add docker-compose.yml
- Fix YAML syntax error in GitLab CI/CD pipeline
- Update Docker image path to push/pull from docker directory
- Add docker-compose.yml for proper deployment
- Simplify CI/CD configuration removing complex deployment scripts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-19 10:36:03 +08:00
root
3d464c747d Fix YAML syntax error in GitLab CI/CD pipeline
- Replaced Bash for loop syntax that's not supported in GitLab CI
- Converted: "for i in {1..15}; do...done" to individual echo-sleep commands
- Maintains the same functionality with 15-second wait countdown
- Each step now properly formatted as separate YAML array entries
- Preserves the enhanced logging experience while fixing syntax compatibility

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-19 10:28:50 +08:00
root
e12ce5c632 Enhance logging for better troubleshooting and debugging
🔧 CI/CD Pipeline Improvements:
- Added comprehensive logging with emojis for better readability
- Detailed environment information display
- Step-by-step progress tracking with timestamps
- Enhanced Docker build progress with --progress=plain
- Container deployment validation and health checks
- Network connectivity testing and port monitoring
- Storage usage reporting and cleanup operations

🏗️ Dockerfile Enhancements:
- Added verbose logging for every build stage
- Go environment verification and dependency tracking
- Detailed compilation progress with file sizes
- Runtime environment preparation checks
- Built-in health check configuration
- Enhanced startup logging with service URLs
- Error-friendly fallback messages

📊 Debugging Features:
- Build log preservation (build.log file)
- Container state inspection and JSON formatting
- Port listening status verification
- Service availability testing with retries
- Comprehensive error reporting with context
- Container ID tracking for reference

🎯 Key Benefits:
- Easy problem identification during CI/CD
- Clear visibility into build and deployment process
- Service health monitoring and validation
- Streamlined troubleshooting workflow
- Professional logging presentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-19 10:26:34 +08:00
root
8bfae1588b Simplify deployment using Docker run instead of docker-compose
- Removed docker-compose dependency, using direct Docker run commands
- Kept all deployment features: auto-restart, health check, logging
- Direct Docker container deployment from private registry image
- Added comprehensive environment variables for RustFS backend
- Maintained port mapping (8080:8080) and volume mounting
- Added detailed status reporting and health check validation
- Works with local Dockerfile only, no docker-compose.yml needed

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-19 10:23:51 +08:00
root
2f88022782 Add complete deployment configuration with Docker-in-Docker
- Added docker-in-docker service for container deployment
- Created dynamic docker-compose.yml with full configuration
- Added container auto-restart policy (unless-stopped)
- Configured health check for service monitoring
- Added environment variables for RustFS backend
- Set up port mapping (8080:8080) and network configuration
- Added logging configuration with rotation
- Included deployment validation and status reporting
- Service will auto-pull from private registry and deploy

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-19 10:22:19 +08:00
root
929266c55d Fix: Add image push and comment out deploy stage
- Added docker tag and push commands to push image to private registry
- Pushed image will be: 192.168.1.154:31010/file-system-server:latest
- Commented out deploy_service stage that requires shell runner
- Now CI/CD will successfully build and push image to your registry

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-19 10:18:57 +08:00
root
79162a4205 Fix: Configure Go proxy for faster dependency downloads
- Added GOPROXY=https://goproxy.cn,direct for Chinese mirror
- Added GOSUMDB=sum.golang.google.cn for checksum database
- Fixes timeout issues when downloading Go modules during CI/CD build
- Resolves build failure due to network connectivity to proxy.golang.org

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-19 10:09:18 +08:00
root
0fb7557c27 Fix: Use docker/ prefix for all private registry images
- Updated all image paths to include docker/ prefix
- .gitlab-ci.yml: 192.168.1.154:31010/docker/alpine:latest
- Dockerfile: Both build and run stages use docker/alpine:latest
- Matches private registry structure where images are in docker/ directory

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-19 09:47:04 +08:00
root
f894bc212e Revert to using private registry for all images
- Changed .gitlab-ci.yml back to use 192.168.1.154:31010/alpine:latest and docker/compose:latest
- Updated Dockerfile to use private registry alpine image
- Fixed Docker installation order in CI/CD
- All images now consistently use private registry

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-19 09:45:01 +08:00
root
b75a396378 Fix CI/CD: Use Docker Hub images as temporary solution
- Reverted to using Docker Hub images (alpine:latest, docker/compose:latest)
- This allows CI/CD to work while private registry is being configured
- TODO: Configure private registry and switch back to private images

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-19 09:38:00 +08:00
root
0beb859c54 Update Dockerfile to use private registry for alpine base image
- Changed FROM alpine:latest to FROM 192.168.1.154:31010/alpine:latest
- Added push-images.bat script to help push base images to private registry
- Ensures all CI/CD pipeline uses consistent registry sources

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-19 09:36:04 +08:00
root
16798c0fac Remove dind service dependency to rely on host docker socket 2025-12-18 15:53:34 +08:00
root
16dc7313d7 Switch CI/CD jobs to use Alpine image and install Docker tools manually 2025-12-18 15:51:36 +08:00
root
13fabbd5fc Fix CI/CD: Use available images from private registry 2025-12-18 15:47:17 +08:00
root
2e297cf82f Configure CI/CD to use private Nexus registry 2025-12-18 15:20:41 +08:00
root
3a7daf66a7 合并远程仓库的更改 2025-12-18 09:54:27 +08:00
root
d7a3083057 init 2025-12-18 09:51:13 +08:00
root
e3a5bc2a6e init 2025-12-18 09:44:32 +08:00
root
8232827835 Initial commit 2025-12-18 09:34:49 +08:00