diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c010115 --- /dev/null +++ b/.dockerignore @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..40d8114 --- /dev/null +++ b/Dockerfile @@ -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)"] diff --git a/api/webui/index.html b/api/webui/index.html index 2d67728..9573baf 100644 --- a/api/webui/index.html +++ b/api/webui/index.html @@ -1,16 +1,16 @@ - - - - - - - webui - + + + + + + + webui + - - - -
- - + + + +
+ + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..32bde20 --- /dev/null +++ b/docker-compose.yml @@ -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