Member-only story
How To Build a FastApi Server to Control a Raspberry Pi
Everything you need to know from installation to deployment using docker-compose

Recently, a friend of mine asked me if I can help him build a graphical user interface that allows him to easily control a couple of valves using a Raspberry Pi. Apart from that, he also wanted to log a couple of things in a database.
My answer was:
“Sounds great! Let’s build a small web server that serves a webpage as the GUI and, together with a MongoDB database, runs in a Docker-compose environment on your Raspberry Pi.”
Here, I want to show you what I have done to get all the bold points working on the Raspberry Pi (Rpi). I assume you already know what Docker and Docker Compose are. If not, take your time and read up on Docker and Docker Compose.
Are you done with that? Let’s get started.
Setting Up Docker and Docker Compose
First of all, why Docker and Docker Compose?
For me, as soon as I build an application that relies on dependencies being installed on the target machine, I use Docker. This avoids potential headaches and eventually avoids “But it runs on my machine” issues.