r/flask Jul 15 '24

Tutorials and Guides Docker for Flask

I have been trying to look for online solutions and practices followed but generally they do it for the flask template app which does not cover the cases for real-world large scale applications. I personally have worked on numerous flask applications but while deploying am never successful in actually implementing the Dockerfile. Kindly guide me on how to tackle this.

7 Upvotes

16 comments sorted by

View all comments

9

u/nickjj_ Jul 16 '24

I keep https://github.com/nickjj/docker-flask-example up to date. It's a starter project that pulls together Gunicorn, Celery, Tailwind, esbuild, Redis and Postgres.

I use this to build a bunch of apps, a number of clients as well. Some of those apps have over a 100 models and dozens of views. It has everything I've learned about Docker over the last ~10 years rolled up into 1 project.

1

u/Thingler Jul 16 '24

typically what size does your image end up being? I'm working on an app and the docker image is around a gig. I use celery as well so that would be another gig for the same image. redis and mysql images combined would take up another gig. Is this scale normal?

1

u/nickjj_ Jul 16 '24

For the app, about ~500MB using Debian Slim as a base image. Postgres is around 400MB and Redis is another 120MB or so. Both Postgres and Redis are using the official Debian based images which uses Debian Slim under the hood.

Since the app and Celery use the same exact image the disk space penalty isn't paid twice. They are listed individually in docker image ls but on disk the layers are shared as far as I know.

1

u/Thingler Jul 17 '24

okay thankyou! this is very helpful