Project setup on pi3 with db and server

Hi guys, I have a dockerized python server that needs a mysql db.
My python server dockerfile build from craigham/pandas:latest because it has already compiled some crucial libraries for the project.
To build my image for pi3 I run docker buildx build --platform linux/arm/v7 -t nick/my-project .
So I couldn’t just balena push instead I build locally my image and run balena deploy.
Reading balena docks and the forum I have understood that I need a multicontainer setup, one container for mysql db and one for my python server. So I need to deploy a docker-compose file.
In order to have my db data persisted every time I release a new version of my python server I have to (Q1)

  1. store the db data under /data inside the mysql container
  2. OR create a volume for my data that mounts a balena os host directory with mysql /data directory?
    can’t really understand it from the docs.
    My next problem is, lets say I have an sql dump for my db, how can I load it on my db container?
    I suppose I have to somehow move it in my balena os host, then create a volume that mounts on /data of mysql container and the dockerfile of my db will execute the command to load the data?

To conclude, high level I need a docker-compose file that sets up the two services and each one has its own dockerfile.
To run my buildx command from the docker-compose I have to create my image, put it in a repo and mention it in the docker-compose?
Thank you in advance guys, please keep the answers stupid simple newbie here! :stuck_out_tongue:

Hi there,

When you push to balenaCloud with the balenaCLI, you will automatically build for the right device type/architecture for the app you are deploying to, so that makes it easier than cross-building locally.

You will need to deploy a multicontainer app, that is correct.

If you want data to be persisted between app updates, you’ll need to create a volume and persist all your data there. Any data written outside that volume will be blown away when updating to a newer release (as it is part of the container’s filesystem). You can read more about those volumes in our services masterclass, available here:

If you want to load a backup, you are probably best served by loading that as part of the image build process (i.e., in the Dockerfile itself). Additionally you could set up some scaffolding in the image to load a dump at boot, but depending on how often you are building/redeploying that container it may not be worth the added complexity.

Please let us know if you have any further questions! If you are just getting started, I definitely recommend investing in running through some of the masterclasses, as they are quite helpful for building an understanding of how all the pieces fit together.

1 Like