feat:增加fastapi博客
This commit is contained in:
33
docs/Web-Backend/FastAPI/FastAPI-Docker.md
Normal file
33
docs/Web-Backend/FastAPI/FastAPI-Docker.md
Normal file
@@ -0,0 +1,33 @@
|
||||
---
|
||||
title: FastAPI Docker离线部署
|
||||
date: 2026-01-06
|
||||
---
|
||||
|
||||
# 一、安装依赖
|
||||
  通过pip将requirements.txt中的依赖包下载到本地:
|
||||
```sh
|
||||
pip download -r requirements.txt -d ./packages --only-binary=:all: --platform manylinux2014_x86_64 -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
```
|
||||
|
||||
::: tip
|
||||
`--only-binary=:all:`表示只下载预编译的二进制包
|
||||
`--platform manylinux2014_x86_64`指定目标平台为 Linux
|
||||
`-i`指定pip镜像源源
|
||||
还可以加上`--python-version 310`指定python版本
|
||||
:::
|
||||
|
||||
  执行命令后,会在./packages中下载相应的二进制包。
|
||||
|
||||
# 二、Dockfile
|
||||
```dockerfile
|
||||
FROM python:3.10-slim
|
||||
WORKDIR /app
|
||||
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
RUN echo 'Asia/Shanghai' > /etc/timezone
|
||||
COPY ./packages /app/packages
|
||||
COPY requirements.txt /app/
|
||||
RUN pip install --no-cache-dir --no-index --find-links=/app/packages -r requirements.txt
|
||||
COPY . /app/
|
||||
EXPOSE 8095
|
||||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8095"]
|
||||
```
|
||||
4
docs/Web-Backend/SpringBoot/SpringBoot-RestClient.md
Normal file
4
docs/Web-Backend/SpringBoot/SpringBoot-RestClient.md
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
title: SpringBoot RestClient简介
|
||||
date: 2026-01-06
|
||||
---
|
||||
Reference in New Issue
Block a user