Compare commits
17 Commits
36b5a1db2d
...
master
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c0810e4352 | ||
![]() |
53668b12e9 | ||
![]() |
e6f36da184 | ||
![]() |
22ed9ab4d7 | ||
![]() |
37b43ef8f5 | ||
![]() |
5421b81828 | ||
![]() |
1021a2d6be | ||
![]() |
20283e17b9 | ||
![]() |
1abc63a603 | ||
![]() |
539c9c7453 | ||
![]() |
b40bc183d0 | ||
![]() |
e8b4f6d6a7 | ||
![]() |
d78af84c66 | ||
![]() |
5ab7ebbe5a | ||
![]() |
2f8e547e03 | ||
![]() |
69a3032102 | ||
![]() |
001bc4e52b |
@@ -1,5 +1,5 @@
|
|||||||
# 使用Python官方镜像
|
# 使用Python官方镜像
|
||||||
FROM python:3.9-slim
|
FROM python:3.11-slim
|
||||||
|
|
||||||
# 设置工作目录
|
# 设置工作目录
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -8,7 +8,7 @@ WORKDIR /app
|
|||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
|
|
||||||
# 安装依赖
|
# 安装依赖
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||||
|
|
||||||
# 复制项目文件
|
# 复制项目文件
|
||||||
COPY . .
|
COPY . .
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
pydantic<2.0
|
||||||
|
asyncmy>=0.2.10
|
||||||
fastapi>=0.95.2
|
fastapi>=0.95.2
|
||||||
python-dotenv>=1.0.0
|
python-dotenv>=1.0.0
|
||||||
sqlalchemy>=2.0.15
|
sqlalchemy>=2.0.15
|
||||||
@@ -6,4 +8,5 @@ bcrypt>=4.0.1
|
|||||||
pyjwt>=2.6.0
|
pyjwt>=2.6.0
|
||||||
pytest>=7.3.1
|
pytest>=7.3.1
|
||||||
requests>=2.28.2
|
requests>=2.28.2
|
||||||
|
cryptography>=42.0.2
|
||||||
uvicorn[standard]>=0.21.1
|
uvicorn[standard]>=0.21.1
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from pydantic import BaseModel, Field, model_validator
|
from pydantic import BaseModel, Field, root_validator
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
# 用户角色枚举
|
# 用户角色枚举
|
||||||
@@ -27,7 +27,7 @@ class UserUpdate(BaseModel):
|
|||||||
description: Optional[str] = Field(None, max_length=255, description="用户描述")
|
description: Optional[str] = Field(None, max_length=255, description="用户描述")
|
||||||
|
|
||||||
# 可选:确保至少更新一个字段
|
# 可选:确保至少更新一个字段
|
||||||
@model_validator(mode='before')
|
@root_validator
|
||||||
def validate_at_least_one_field(cls, values):
|
def validate_at_least_one_field(cls, values):
|
||||||
if not any(values.values()):
|
if not any(values.values()):
|
||||||
raise ValueError("至少需要更新一个字段")
|
raise ValueError("至少需要更新一个字段")
|
||||||
|
@@ -25,11 +25,9 @@ services:
|
|||||||
- app-network
|
- app-network
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
image: nginx:stable-alpine
|
build: ./nginx
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
volumes:
|
|
||||||
- ./nginx.conf:/etc/nginx/nginx.conf
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- frontend
|
- frontend
|
||||||
- backend
|
- backend
|
||||||
|
@@ -8,7 +8,8 @@ WORKDIR /app
|
|||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
# 安装依赖
|
# 安装依赖
|
||||||
RUN npm install
|
RUN npm config set registry https://registry.npmmirror.com && \
|
||||||
|
npm install
|
||||||
|
|
||||||
# 复制项目文件
|
# 复制项目文件
|
||||||
COPY . .
|
COPY . .
|
||||||
@@ -22,6 +23,9 @@ FROM nginx:stable-alpine as production-stage
|
|||||||
# 复制构建好的文件到Nginx目录
|
# 复制构建好的文件到Nginx目录
|
||||||
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
||||||
|
|
||||||
|
# 复制Nginx配置文件
|
||||||
|
COPY nginx.conf /etc/nginx/nginx.conf
|
||||||
|
|
||||||
# 暴露80端口
|
# 暴露80端口
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
21
frontend/nginx.conf
Normal file
21
frontend/nginx.conf
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# 用户连接数
|
||||||
|
worker_processes 1;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
# 设置根目录
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
# 处理SPA路由
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -82,6 +82,9 @@ const handleConfirm = async () => {
|
|||||||
if (!createData.password) {
|
if (!createData.password) {
|
||||||
throw new Error('密码不能为空')
|
throw new Error('密码不能为空')
|
||||||
}
|
}
|
||||||
|
if (!/^\d{6,}$/.test(createData.password)) {
|
||||||
|
throw new Error('密码必须为6位或以上的数字')
|
||||||
|
}
|
||||||
await userService.createUser({
|
await userService.createUser({
|
||||||
username: createData.username,
|
username: createData.username,
|
||||||
password: createData.password,
|
password: createData.password,
|
||||||
|
11
nginx/Dockerfile
Normal file
11
nginx/Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# 使用Nginx作为基础镜像
|
||||||
|
FROM nginx:stable-alpine
|
||||||
|
|
||||||
|
# 复制Nginx配置文件
|
||||||
|
COPY nginx.conf /etc/nginx/nginx.conf
|
||||||
|
|
||||||
|
# 暴露80端口
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
# 启动Nginx
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
@@ -9,7 +9,7 @@ http {
|
|||||||
listen 80;
|
listen 80;
|
||||||
|
|
||||||
location /api/ {
|
location /api/ {
|
||||||
proxy_pass http://backend:8000/;
|
proxy_pass http://backend:8000;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
Reference in New Issue
Block a user