feat: add Docker deployment support
Add Dockerfile (python:3.11-slim), docker-compose.yml with volume mounts for webui/data/logs, and .dockerignore for minimal image size. Made-with: Cursor
This commit is contained in:
32
.dockerignore
Normal file
32
.dockerignore
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Frontend source (not needed for Docker, only pre-built assets)
|
||||||
|
WebUI/
|
||||||
|
tests/
|
||||||
|
*.md
|
||||||
|
.git/
|
||||||
|
.gitignore
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# Python bytecode
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
|
||||||
|
# Virtual environment
|
||||||
|
venv/
|
||||||
|
.env/
|
||||||
|
.env.*
|
||||||
|
|
||||||
|
# Runtime data (mounted via volumes)
|
||||||
|
api/data/
|
||||||
|
api/logs/
|
||||||
|
|
||||||
|
# Node
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Temporary files
|
||||||
|
*.tmp
|
||||||
|
*.bak
|
||||||
23
Dockerfile
Normal file
23
Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
FROM python:3.11-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# 使用清华源加速 pip
|
||||||
|
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
|
||||||
|
|
||||||
|
# 安装依赖
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
# 拷贝后端代码
|
||||||
|
COPY api/ ./api/
|
||||||
|
|
||||||
|
# 拷贝编译后的前端产物
|
||||||
|
COPY api/webui/ ./api/webui/
|
||||||
|
|
||||||
|
# 创建数据和日志目录
|
||||||
|
RUN mkdir -p api/data api/logs
|
||||||
|
|
||||||
|
EXPOSE 23994
|
||||||
|
|
||||||
|
CMD ["python", "-c", "import sys; sys.path.insert(0, '/app/api'); import uvicorn; uvicorn.run('app.main:app', host='0.0.0.0', port=23994)"]
|
||||||
@@ -5,10 +5,10 @@
|
|||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>webui</title>
|
<title>webui</title>
|
||||||
<script type="module" crossorigin src="/assets/index-1IMBzsQJ.js"></script>
|
<script type="module" crossorigin src="/assets/index-CZ83FtWq.js"></script>
|
||||||
<link rel="modulepreload" crossorigin href="/assets/vendor-CwFI-VDq.js">
|
<link rel="modulepreload" crossorigin href="/assets/vendor-CwFI-VDq.js">
|
||||||
<link rel="modulepreload" crossorigin href="/assets/element-plus-CAICPA8-.js">
|
<link rel="modulepreload" crossorigin href="/assets/element-plus-CAICPA8-.js">
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-D3zzYHQC.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-DQPizegK.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|||||||
14
docker-compose.yml
Normal file
14
docker-compose.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
services:
|
||||||
|
elysia-todo:
|
||||||
|
build: .
|
||||||
|
container_name: elysia-todo
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "23994:23994"
|
||||||
|
volumes:
|
||||||
|
# 挂载前端编译产物,本地修改后可立即生效
|
||||||
|
- ./api/webui:/app/api/webui:ro
|
||||||
|
# 挂载数据库文件,持久化数据
|
||||||
|
- ./api/data:/app/api/data
|
||||||
|
# 挂载日志目录,方便查看日志
|
||||||
|
- ./api/logs:/app/api/logs
|
||||||
Reference in New Issue
Block a user