Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
WSL0809 committed May 27, 2024
1 parent ac81290 commit ce2576f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
**/.DS_Store
.venv
.git
./target
Cargo.lock
.github
.idea
37 changes: 29 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
#拉取 python3.10 的基础镜像
FROM python:3.10
##拉取 python3.10 的基础镜像
#FROM python:3.10
#
#WORKDIR /app
#
#COPY . /app
#
#RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
# pip install --upgrade pip --no-cache && \
# pip install --no-cache -r requirements.txt
#
#EXPOSE 80
#
#CMD ["uvicorn", "main:app", "--host", "127.0.0.1", "--port", "20245", "--workers", "4"]

FROM python:3.10-slim AS builder

WORKDIR /app

COPY . /app
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

COPY requirements.txt .
RUN pip install --upgrade pip && \
pip wheel --no-deps --wheel-dir /wheels -r requirements.txt

FROM python:3.10-slim

WORKDIR /app

RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
pip install --upgrade pip --no-cache && \
pip install --no-cache -r requirements.txt
COPY --from=builder /wheels /wheels
COPY --from=builder /app/requirements.txt .

EXPOSE 80
RUN pip install --no-cache /wheels/*

CMD ["uvicorn", "main:app", "--host", "127.0.0.1", "--port", "20245", "--workers", "4"]
COPY . .
2 changes: 1 addition & 1 deletion api/fault_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class FaultRegistrationRecv(BaseModel):


class FaultRegistrationResp(BaseModel):
status: str
status: Union[str, int]
details: Union[str, None]


Expand Down
5 changes: 4 additions & 1 deletion api/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@ class AddRoomRecv(BaseModel):
room_number: str
notes: Union[str, None]


class DeleteRoomRecv(BaseModel):
room_number: str


class AddRoomResp(BaseModel):
msg: str
success: bool


@router.post("/add_room", response_model=AddRoomResp)
@roles_required("admin")
async def add_room(room_info: AddRoomRecv, current_user: User = Depends(get_current_active_user), db: Session = Depends(get_db)):
async def add_room(room_info: AddRoomRecv, current_user: User = Depends(get_current_active_user),
db: Session = Depends(get_db)):
try:
room = Room(room_number=room_info.room_number, notes=room_info.notes)
db.add(room)
Expand Down

0 comments on commit ce2576f

Please sign in to comment.