I started more serious work on the next version of the Numu Tracker API this weekend. Originally I intended on building it as a Django app, but now that I work full time professionally on a Flask API I decided it would help teach me a lot if I built it out that way.
You can follow along at the numutracker_api GitHub repo.
I’d never used Docker before, nor had I ever set up a development environment with an internal PostgreSQL database and a differ by external database for production, nor had I set up Flask myself. I spent pretty much the entirety of my Sunday following various parts of tutorials to get everything going.
Docket wasn’t too tricky to get running and understand. The hardest part was the database set up; I set up two new DO droplets, one to run the docket container for the Flask app, and another to run the production PostgresSQL database, with a private network between them allowing secure database access. I’m not happy with how I am handling environment variables but this is a workable solution (dev.py and prod.py config files) that isn’t too messy. I wanted to avoid having different docker-compose.yml files for dev and production, which might be a bit silly. I’ll probably revisit this in the future but since this is not a project that will see frequent deploys it may not be a priority for me.
Working with Flask seems way easier than working with Django so far, but also Docker takes a lot of complexity out of setting things up when you can just use an existing image and you don’t have to worry about virtualenvs anymore. I also go into Flask with an existing understanding of Django and having worked with Flask a fair amount. Anyway, good times!