Comments (18)
@tiangolo hello!
Now it is possible to build arm based containers on any computer. Can you support it in your scripts? If you dont have enough free time I can try to make PR.
https://medium.com/@artur.klauser/building-multi-architecture-docker-images-with-buildx-27d80f7e2408
https://collabnix.com/building-arm-based-docker-images-on-docker-desktop-made-possible-using-buildx/
from uvicorn-gunicorn-fastapi-docker.
I've made an upstream PR to make the uvicorn-gunicorn containers multiarch. Those images are on docker hub as well (since I was testing push functionality).
Assuming that gets merged I can make another PR here to do the same.
from uvicorn-gunicorn-fastapi-docker.
Since the amd64 version of this container was way too slow on my m1 mac I forked this repo and changed the deploy action to build the arm64 version aswell: https://github.com/flyingjoe/uvicorn-gunicorn-fastapi-docker/tree/ARM_Images
(same for the underlying uvicorn-gunicorn image of course)
Maybe this helps someone:
https://hub.docker.com/r/flyingjoe/uvicorn-gunicorn-fastapi
Note: I had no time yet to adapt the tests to multi platform, that's why there is no pull request yet. I wouldn't recommend using this image for production.
from uvicorn-gunicorn-fastapi-docker.
Yes, I would like to, that's one of the reasons why I always base these images on official ones (official Python) and use parts from official images, because these base images are multi-architecture.
The issue is that not Docker Hub automated builds nor Travis CI can compile to ARMs.
If you clone this repository, you should be able to compile the images in the Raspberry Pi itself. Although this is not ideal.
"Solution", new docs
For this specific use case, I added documentation to create your application's Dockerfile
with minimal requirements, in a way compatible with Raspberry Pi.
Using only Uvicorn (without Gunicorn), to reduce resource usage.
Here's the new documentation: https://fastapi.tiangolo.com/deployment/#raspberry-pi-and-other-architectures
Future plans
One of the side-projects in my backlog is finding a way to build in ARM (Raspberry Pi) and publish in the same Docker Hub images without affecting the other architectures. And then find a way to automatize it. But I haven't been able to test it, although I actually have a small Raspberry Pi cluster/farm (8 Pis I think). But for now, I think the solution above should work.
from uvicorn-gunicorn-fastapi-docker.
+1 for multiarch!
from uvicorn-gunicorn-fastapi-docker.
Ideally the base image could be multi-architecture (https://blog.docker.com/2017/09/docker-official-images-now-multi-platform/) to maximize compatibility.
from uvicorn-gunicorn-fastapi-docker.
Thank you for your extensive answer and quick reaction, I'm even more impressed with this project. I am looking forward to your automated builds, for now I will stick to your "Solution".
I had a small problem but managed to get it working on PC using a slight modification of your newest addition to the documentation. In my case I needed to add a WORKDIR
to keep my application in scope.
My new Dockerfile:
FROM python:3.7
EXPOSE 80
# manual installation
RUN pip install fastapi uvicorn
# copy whole installation (minus dockerignore)
COPY ./app /app
# install additional dependencies (might have duplicates?)
# (was pipenv previously but had problems with alpine)
COPY ./requirements.txt requirements.txt
RUN pip install -r requirements.txt
# set workdir to have subscripts in scope
WORKDIR ./app
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
I unsuccessfully tried "improving" the Dockerfile by using FROM python:3.7-alpine
. This is not possible as httpstools
and uvloops
are unable to build wheels. It might be sensible to empathize that as using alpine seems to be the default nowadays.
I was unable to get it running on my Raspberry Pi Zero W using the above Dockerfile. I have not found a solution in the last 2 hours, did I overlook something?
pi@modischpi-zero:~/CutSolver $ bash docker build -t cutsolver:latest .
Sending build context to Docker daemon 45.57kB
Step 1/8 : FROM python:3.7
---> fb676539ecfe
Step 2/8 : EXPOSE 80
---> Using cache
---> b2607ba96d8b
Step 3/8 : RUN pip install fastapi uvicorn
---> Running in 26bb1cd0822a
The command '/bin/sh -c pip install fastapi uvicorn' returned a non-zero code: 139
A few measurements I made while experimenting (on PC):
uvicorn-gunicorn:python3.7-alpine3.8
size: 114 554 660
init mem: 65MiB
Idle: 0.4%
Run: 7.5%
python:3.7 ("manual" build)
size: 974 971 759
init mem: 17MiB
Idle: 0.1%
Run: 7.3%
from uvicorn-gunicorn-fastapi-docker.
I was experimenting a bit and it seems like a manual build is possible on Raspberry Pi 3B, but not on Zero W. Building the image on the 3B took around 15min, but at least it's working.
The main difference was that the 3B is using ARMv7 while the Zero W has ARMv6.
from uvicorn-gunicorn-fastapi-docker.
I'm sorry for the delay. Thanks for the report. That's an interesting finding. I don't own a Zero myself, so I wouldn't know. But it seems like the issue could be right there in the ARM version difference.
from uvicorn-gunicorn-fastapi-docker.
Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues.
from uvicorn-gunicorn-fastapi-docker.
Interested as well!
from uvicorn-gunicorn-fastapi-docker.
+1 for multiarch!
from uvicorn-gunicorn-fastapi-docker.
@tiangolo can this be reopened please?
from uvicorn-gunicorn-fastapi-docker.
Hi @tedivm is it viable to use the arm64 docker image from your docker hub repository on production on AWS graviton? Or is it better to way for the merge?
from uvicorn-gunicorn-fastapi-docker.
I only put them up for testing (since docker buildx handles both building and pushing together, a registry is needed). I'm not automatically updating them or maintaining them, and after the PR is merged I plan on erasing the repo.
If you need to use these on graviton before they're merged in I'd suggest building them yourself directly, hosting on ECR, and then building off of your own images.
from uvicorn-gunicorn-fastapi-docker.
Hi @tedivm thanks but where could I find the most updated dockerfile to build these arm64 docker images?
I tried to rebuild arm64 uvicorn-gunicorn
images based on https://github.com/tiangolo/uvicorn-gunicorn-docker/tree/master/docker-images and buildx
, but this gave me inconsistent results unfortunately.
from uvicorn-gunicorn-fastapi-docker.
If you want to use images from this PR you should clone my version of the upstream repository, check out this branch, update the repository username to the one for your container repository, and then run the build and push script from that repo.
Then do the same for this repository, pointing the dockerfiles at your newly created images.
from uvicorn-gunicorn-fastapi-docker.
@flyingjoe thanks for your arm64 image on docker hub, it works well on AWS EC2 graviton.
However, I have a strange behaviour when docker is running: rapidly the docker container takes more than 2 GB of disk space. I don't understand how and why it takes so much. Do you have an idea?
Thanks!
from uvicorn-gunicorn-fastapi-docker.
Related Issues (20)
- Application does not start up when combining this image and a database connection in Linux CentOS. HOT 4
- Upgrade from python3.8 to python3.11 fails HOT 1
- ModuleNotFoundError: No module named 'app' HOT 2
- APScheduler logs not showing in docker HOT 1
- websocket can not use
- Deploying HuggingFace model/pipeline using uvicorn-gunicorn-fastapi-docker on Google Cloud Run HOT 2
- Is --proxy-headers applied in the uvicorn CMD in the image? HOT 1
- getting timeout 504 in 1 minute
- Support for Apple sillicon
- New docker-image may be broken HOT 1
- apt-get update not working on specific version
- container build fails with pydantic-settings HOT 1
- Uvicorn -gunicorn-fastapi-docker
- Runtime Error: Can't start new thread HOT 2
- linux/arm64/v8 not supported HOT 2
- Unexpected Redirection of `/docs` Endpoint with Custom `APP_MODULE` Setup
- Current gunicorn version does not support Python 3.11 HOT 1
- Base Dockerfile HOT 3
- pydantic_settings package not supported
- Update fastapi to support Pydantic2 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uvicorn-gunicorn-fastapi-docker.