# Deploy Python App
# Optimization Matrix
- [ ] Image Size?
- [ ] Initial and subsequent build times?
# Popular base images for python
# Which one to choose?
# Whast is the difference between various images?
- alpine is only 90 MB,
python-slim-stretch
is 2X that ofalpine
python
base image is almost 1GB, 10X more than alpine- Debian image has lot of built-in python native C Expensions, like cryptography lubraries.
- Debian Images have more Linux Wheels
Remove docker layer
If you want to delete docker Layer, remove them in the same step. Else they have no effect on image size System level deps -> Python level deps -> App level deps
# Google Cloud Run
- Provision stateful services (like Bucket access, and DB access) to stateless app container.
- Link stateful and stateless services
gcloud run deploy agate-dotcom \
--platform managed \
--add-cloudsql-instance vivid:us-central1:agate \
...
How to link static assets? setup django collectstatic
pip install django-storages[google]
DEFAULT_FILE_STORAGE = ()
How do I run django commands? Containers do NOT provide me a shell to run migrate
commands
- Add steps between build and deploy in
cloudbuild.yaml
# Challenges
- Semantic Web 3.0, graphQL-LD
- Match making algorithm
# Resources
- https://slides.com/dmfigol/optimizing-docker-builds-for-python-applications
- Black Magic of Python Wheels