feat: 添加可配置的文件上传大小限制

新增 MAX_FILE_SIZE_MB 环境变量统一控制文件上传大小,默认 50MB
This commit is contained in:
wizardchen
2025-12-30 11:08:05 +08:00
committed by lyingbug
parent 7c302bea1f
commit 6cf7cbcb9c
10 changed files with 93 additions and 17 deletions
+7 -4
View File
@@ -27,11 +27,14 @@ FROM nginx:stable-alpine as production-stage
# 复制构建产物到nginx服务目录
COPY --from=build-stage /app/dist /usr/share/nginx/html
# 复制nginx配置文件
COPY nginx.conf /etc/nginx/conf.d/default.conf
# 复制nginx配置模板文件
COPY nginx.conf /etc/nginx/templates/default.conf.template
# 设置默认环境变量(MB)
ENV MAX_FILE_SIZE_MB=50
# 暴露端口
EXPOSE 80
# 启动nginx
CMD ["nginx", "-g", "daemon off;"]
# 启动时将 MAX_FILE_SIZE_MB 转换为带单位的 MAX_FILE_SIZE,然后替换到 nginx 配置
CMD ["/bin/sh", "-c", "export MAX_FILE_SIZE=${MAX_FILE_SIZE_MB}M && envsubst '${MAX_FILE_SIZE}' < /etc/nginx/templates/default.conf.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"]