feat:增加fastapi博客

This commit is contained in:
2026-01-06 19:57:45 +08:00
parent b6669a1731
commit 4f07faaa64
4 changed files with 42 additions and 3 deletions

View File

@@ -35,14 +35,16 @@ export const routers = [
{ text: 'SpringBoot注解', link: '/Web-Backend/SpringBoot/SpringBoot-Annotation' },
{ text: 'SpringBoot3原生镜像', link: '/Web-Backend/SpringBoot/SpringBoot3-GraalVM' },
{ text: 'SpringBoot技巧', link: '/Web-Backend/SpringBoot/SpringBoot-Skills' },
{ text: 'SpringBoot Common', link: '/Web-Backend/SpringBoot/SpringBoot-Common' }
{ text: 'SpringBoot Common', link: '/Web-Backend/SpringBoot/SpringBoot-Common' },
{ text: 'SpringBoot RestClient简介', link: '/Web-Backend/SpringBoot/SpringBoot-RestClient' }
]
},
{
text: '🐍 FastAPI',
items: [
{ text: 'FastAPI基础教程', link: '/Web-Backend/FastAPI/FastAPI-Guide' },
{ text: '基于OAuth2的安全验证', link: '/Web-Backend/FastAPI/OAuth2' }
{ text: '基于OAuth2的安全验证', link: '/Web-Backend/FastAPI/OAuth2' },
{ text: 'FastAPI Docker部署', link: '/Web-Backend/FastAPI/FastAPI-Docker' }
]
},
{

View File

@@ -288,7 +288,7 @@ docker system prune -f
# 六、Dockerfile
  Dockerfile 是用来构建 Docker 镜像的文本文件,包含了一系列构建指令,可以自动化地创建包含应用及其运行环境的镜像。
  基本结构:
```
```dockerfile
# 基础镜像
FROM 镜像名:标签

View 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"]
```

View File

@@ -0,0 +1,4 @@
---
title: SpringBoot RestClient简介
date: 2026-01-06
---