移除静态文件支持:删除静态资源目录相关代码和 Dockerfile 配置

This commit is contained in:
2026-01-27 16:22:21 +08:00
parent e12d912a6c
commit 6052af8357
3 changed files with 3 additions and 9 deletions

View File

@@ -32,11 +32,9 @@ FROM alpine:3.21
RUN apk add --no-cache ca-certificates tzdata RUN apk add --no-cache ca-certificates tzdata
WORKDIR /app WORKDIR /app
# 创建必要目录 # 创建必要目录
RUN mkdir -p data static RUN mkdir -p data
# 从构建阶段复制二进制文件 # 从构建阶段复制二进制文件
COPY --from=builder /app/BingPaper . COPY --from=builder /app/BingPaper .
# 复制静态资源(如果有些资源没有被 embed
COPY --from=builder /app/static ./static
# 复制默认配置 # 复制默认配置
COPY config.example.yaml ./data/config.yaml COPY config.example.yaml ./data/config.yaml

View File

@@ -34,9 +34,6 @@ func SetupRouter(webFS embed.FS) *gin.Engine {
// Swagger // Swagger
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
// 静态文件
r.Static("/static", "./static")
api := r.Group("/api/v1") api := r.Group("/api/v1")
{ {
// 公共接口 // 公共接口

View File

@@ -242,9 +242,8 @@ func (f *Fetcher) saveVariant(ctx context.Context, img *model.Image, variant, fo
func (f *Fetcher) saveDailyFiles(srcImg image.Image, originalData []byte) { func (f *Fetcher) saveDailyFiles(srcImg image.Image, originalData []byte) {
util.Logger.Info("Saving daily files") util.Logger.Info("Saving daily files")
localRoot := config.GetConfig().Storage.Local.Root localRoot := config.GetConfig().Storage.Local.Root
if config.GetConfig().Storage.Type != "local" { if localRoot == "" {
// 如果不是本地存储,保存在静态资源目录 localRoot = "data"
localRoot = "static"
} }
if err := os.MkdirAll(localRoot, 0755); err != nil { if err := os.MkdirAll(localRoot, 0755); err != nil {