Compiling and running C files on balena docker

Hello guys,
I am trying to develop led-matrix on balena and am stuck on this little problem which is probably very simple for some experienced people here. I need to compile C scripts on startup, and I don’t know how to make a docker template which can do that. Python is just not fast enough to run the LED matrices at a good frame-rate.
Once that’s done, I need to the run the same scripts using a webserver or a python script. It’ll be really helpful if someone can guide me through it, or point me to a resource/tutorial which help me.
Thank you.

Can you explain why you need the runtime compilation? I’ve come across this myself needing to compile Python libs, but ended up changing the base image I was using.

If you need to compile based on some input, you can pre-compile based on inputs and then include based on the input.

You may simply need a different design.