chore: sync local changes (2026-03-12)

This commit is contained in:
2026-03-12 18:58:36 +08:00
parent 2bd4f06188
commit d8c1e1ee6c
49 changed files with 409 additions and 182 deletions

View File

@@ -0,0 +1,18 @@
__pycache__
*.pyc
*.pyo
*.pyd
.Python
*.so
*.egg
*.egg-info
dist
build
.venv
venv
.env
.env.local
.git
.gitignore
README.md
*.md

View File

@@ -0,0 +1,23 @@
FROM python:3.11-slim
WORKDIR /app
# 复制依赖文件
COPY requirements.txt .
# 安装依赖
RUN pip install --no-cache-dir -r requirements.txt
# 复制应用代码
COPY . .
# 暴露端口
EXPOSE 4343
# 设置环境变量
ENV DRIFT_BOTTLE_DATA_DIR=/data
ENV FLASK_APP=app.py
ENV PORT=4343
# 运行应用
CMD ["python", "app.py"]

View File

@@ -42,6 +42,7 @@ PROJECT_ROOT = BACKEND_ROOT.parent # Root project directory
FRONTEND_ROOT = PROJECT_ROOT / "mengyadriftbottle-frontend" # Frontend directory
TEMPLATES_DIR = FRONTEND_ROOT / "templates" # Templates in frontend
STATIC_DIR = FRONTEND_ROOT / "static" # Static files in frontend
BACKGROUND_DIR = BACKEND_ROOT / "background" # Background images directory
FRONTEND_DIST = Path(
os.environ.get("DRIFT_BOTTLE_FRONTEND_DIST") or PROJECT_ROOT / "frontend-dist"
)
@@ -547,7 +548,20 @@ def admin_settings():
# ---------------------------------------------------------------------- #
# ==============================后端公开API============================== #
# ==============================静态文件服务============================== #
# ---------------------------------------------------------------------- #
@app.route("/background/<path:filename>")
def serve_background_image(filename: str):
"""Serve background images from the background directory."""
if not BACKGROUND_DIR.exists():
abort(404)
return send_from_directory(str(BACKGROUND_DIR), filename)
# ---------------------------------------------------------------------- #
# ==============================前端应用服务============================== #
# ---------------------------------------------------------------------- #
@@ -558,6 +572,10 @@ def serve_frontend_app(path: str):
if path.startswith("api/"):
abort(404)
# 如果路径是 background/,由上面的路由处理
if path.startswith("background/"):
abort(404)
if not FRONTEND_DIST.exists():
return ("Frontend build not found. Please run npm run build first.", 404)
@@ -569,4 +587,6 @@ def serve_frontend_app(path: str):
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5002, debug=True)
port = int(os.environ.get("PORT", 5002))
debug = os.environ.get("FLASK_DEBUG", "False").lower() == "true"
app.run(host="0.0.0.0", port=port, debug=debug)

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 920 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 MiB

View File

@@ -0,0 +1,22 @@
version: '3.8'
services:
backend:
build: .
container_name: mengyadriftbottle-backend
ports:
- "3737:4343"
volumes:
- /shumengya/docker/mengyadriftbottle-backend/data:/data
- ./background:/app/background:ro
environment:
- DRIFT_BOTTLE_DATA_DIR=/data
- DRIFT_BOTTLE_SECRET=${DRIFT_BOTTLE_SECRET:-}
- DRIFT_BOTTLE_ADMIN_TOKEN=${DRIFT_BOTTLE_ADMIN_TOKEN:-shumengya520}
restart: unless-stopped
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:4343/api/health')"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s