# FastAPI Docker 方式

* Dockfile

```python
FROM python:3.9.9-alpine

RUN pip install fastapi uvicorn aiofiles fastapi-async-sqlalchemy python-multipart

EXPOSE 80

COPY . .

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
```

* 打包

```bash
docker build -t myfastapi .
```

* 部署

```bash
docker run -d --name myfastapi -p 80:80 myfastapi
```

* 保存镜像

```bash
docker save -o myfastapi.tar myfastapi
```

* 其他机器部署

  ```bash
  docker load < myfastapi.tar
  ```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://close.gitbook.io/yun-wei-bi-ji/python/fastapi/fastapi-docker-fang-shi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
