]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
:memo: Add instructions for Docker on Raspberry Pi
authorSebastián Ramírez <tiangolo@gmail.com>
Mon, 4 Mar 2019 15:37:46 +0000 (19:37 +0400)
committerSebastián Ramírez <tiangolo@gmail.com>
Mon, 4 Mar 2019 15:37:46 +0000 (19:37 +0400)
docs/deployment.md
docs/release-notes.md

index 69c3a05b36a163a2b9267fb834319befc81e157d..810db2580930c3bc284c9348fba1a4f93664a93b 100644 (file)
@@ -26,7 +26,7 @@ But you can still change and update all the configurations with environment vari
     To see all the configurations and options, go to the Docker image page: <a href="https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker" target="_blank">tiangolo/uvicorn-gunicorn-fastapi</a>.
 
 
-### Build your Image
+### Create a `Dockerfile`
 
 * Go to your project directory.
 * Create a `Dockerfile` with:
@@ -37,6 +37,37 @@ FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7
 COPY ./app /app
 ```
 
+#### Bigger Applications
+
+If you followed the section about creating <a href="" target="_blank">Bigger Applications with Multiple Files
+</a>, your `Dockerfile` might instead look like:
+
+```Dockerfile
+FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7
+
+COPY ./app /app/app
+```
+
+#### Raspberry Pi and other architectures
+
+If you are running Docker in a Raspberry Pi (that has an ARM processor) or any other architecture, you can create a `Dockerfile` from scratch, based on a Python base image (that is multi-architecture) and use Uvicorn alone.
+
+In this case, your `Dockerfile` could look like:
+
+```Dockerfile
+FROM python:3.7
+
+RUN pip install fastapi uvicorn
+
+EXPOSE 80
+
+COPY ./app /app
+
+CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]
+```
+
+### Create the **FastAPI** Code
+
 * Create an `app` directory and enter in it.
 * Create a `main.py` file with:
 
@@ -65,6 +96,8 @@ def read_item(item_id: int, q: str = None):
 └── Dockerfile
 ```
 
+### Build the Docker image
+
 * Go to the project directory (in where your `Dockerfile` is, containing your `app` directory).
 * Build your FastAPI image:
 
@@ -72,6 +105,8 @@ def read_item(item_id: int, q: str = None):
 docker build -t myimage .
 ```
 
+### Start the Docker container
+
 * Run a container based on your image:
 
 ```bash
@@ -81,18 +116,6 @@ docker run -d --name mycontainer -p 80:80 myimage
 Now you have an optimized FastAPI server in a Docker container. Auto-tuned for your current server (and number of CPU cores).
 
 
-#### Bigger Applications
-
-If you followed the section about creating <a href="" target="_blank">Bigger Applications with Multiple Files
-</a>, your `Dockerfile` might instead look like:
-
-```Dockerfile
-FROM tiangolo/uvicorn-gunicorn-fastapi:python3.7
-
-COPY ./app /app/app
-```
-
-
 ### Check it
 
 You should be able to check it in your Docker container's URL, for example: <a href="http://192.168.99.100/items/5?q=somequery" target="_blank">http://192.168.99.100/items/5?q=somequery</a> or <a href="http://127.0.0.1/items/5?q=somequery" target="_blank">http://127.0.0.1/items/5?q=somequery</a> (or equivalent, using your Docker host).
index b8c5ab9ca725d5ec2b74f47ff19c982b560c0599..1cc2d7acb7f707a1f99a80eb715a5e241342b97e 100644 (file)
@@ -1,5 +1,7 @@
 ## Next
 
+* Add <a href="https://fastapi.tiangolo.com/deployment/#raspberry-pi-and-other-architectures" target="_blank">deployment documentation for Docker in Raspberry Pi</a> and other architectures.
+
 * Trigger Docker images build on Travis CI automatically. PR <a href="https://github.com/tiangolo/fastapi/pull/65" target="_blank">#65</a>.
 
 ## 0.7.0