2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,3 +4,5 @@ Data/funds.db
|
|||||||
__pycache__/
|
__pycache__/
|
||||||
*.pyc
|
*.pyc
|
||||||
*.env
|
*.env
|
||||||
|
Frontend/dist/
|
||||||
|
Backend/static/
|
||||||
|
|||||||
20
Backend/Dockerfile
Normal file
20
Backend/Dockerfile
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
FROM python:3.10-slim
|
||||||
|
EXPOSE 5000
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE=1
|
||||||
|
ENV TIME_ZONE=Asia/Shanghai
|
||||||
|
RUN echo "${TIME_ZONE}" > /etc/timezone \
|
||||||
|
&& ln -sf /usr/share/zoneinfo/${TIME_ZONE} /etc/localtime
|
||||||
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
ENV FLASK_ENV=development
|
||||||
|
ENV FLASK_APP=run.py
|
||||||
|
ENV DEBUG=True
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install --no-cache-dir --upgrade pip
|
||||||
|
RUN python -m pip install --no-cache-dir -r requirements.txt
|
||||||
|
WORKDIR /app
|
||||||
|
# COPY env.sample .env
|
||||||
|
COPY . /app
|
||||||
|
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
|
||||||
|
USER appuser
|
||||||
|
VOLUME [ "/data" ]
|
||||||
|
CMD ["python", "app.py"]
|
||||||
@@ -18,7 +18,7 @@ import time
|
|||||||
import re
|
import re
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__, static_folder='static', static_url_path='')
|
||||||
CORS(app) # 允许跨域请求
|
CORS(app) # 允许跨域请求
|
||||||
|
|
||||||
# 注册市场数据 Blueprint
|
# 注册市场数据 Blueprint
|
||||||
@@ -2440,5 +2440,17 @@ def preload_services():
|
|||||||
# 启动预加载(在应用启动时执行)
|
# 启动预加载(在应用启动时执行)
|
||||||
preload_services()
|
preload_services()
|
||||||
|
|
||||||
|
from flask import send_from_directory
|
||||||
|
|
||||||
|
@app.route('/', defaults={'path': ''})
|
||||||
|
@app.route('/<path:path>')
|
||||||
|
def serve_frontend(path):
|
||||||
|
"""服务前端静态文件,SPA 路由支持"""
|
||||||
|
import os
|
||||||
|
static_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static')
|
||||||
|
if path and os.path.exists(os.path.join(static_dir, path)):
|
||||||
|
return send_from_directory(static_dir, path)
|
||||||
|
return send_from_directory(static_dir, 'index.html')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=True, host='0.0.0.0', port=5000)
|
app.run(debug=True, host='0.0.0.0', port=5000)
|
||||||
@@ -6,7 +6,7 @@ from pathlib import Path
|
|||||||
# 获取当前文件所在目录(Backend/)
|
# 获取当前文件所在目录(Backend/)
|
||||||
BACKEND_DIR = Path(__file__).parent.resolve()
|
BACKEND_DIR = Path(__file__).parent.resolve()
|
||||||
# 项目根目录 = BACKEND_DIR 的父目录
|
# 项目根目录 = BACKEND_DIR 的父目录
|
||||||
PROJECT_ROOT = BACKEND_DIR.parent
|
PROJECT_ROOT = BACKEND_DIR
|
||||||
# 数据库路径:PROJECT_ROOT / Data / funds.db
|
# 数据库路径:PROJECT_ROOT / Data / funds.db
|
||||||
DATABASE_PATH = PROJECT_ROOT / "Data" / "funds.db"
|
DATABASE_PATH = PROJECT_ROOT / "Data" / "funds.db"
|
||||||
|
|
||||||
|
|||||||
17
Backend/docker-compose.yml
Normal file
17
Backend/docker-compose.yml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
services:
|
||||||
|
backend:
|
||||||
|
container_name: gofundbot
|
||||||
|
image: jianboy/gofundbot:latest
|
||||||
|
volumes:
|
||||||
|
- ./Data:/app/Data
|
||||||
|
ports:
|
||||||
|
- 5000:5000
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
db_data:
|
||||||
|
|
||||||
|
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
driver: bridge
|
||||||
Reference in New Issue
Block a user