Let's build a demo application, using a whole bunch o' Google Cloud components. Let's make it just like emojipedia, but let's call it...
- Django 2.2 as the web framework
- Google Cloud Run as the hosting platform
- Google Cloud SQL as the managed database, via django-environ
- Google Cloud Storage as the media storage platform, via django-storages
- Google Cloud Build for build and deployment automation
- Google KMS for secret storage, via berglas
This repo serves as a proof of concept of showing how you can piece all the above technolgies together into a working project.
- Try the application locally optional
- Setup Google Cloud Platform environment
- Create a Cloud SQL Instance
- Create a Cloud Storage Bucket
- Create some Berglas Secrets
- First Deployment
- Ongoing Deployments
- Setup a Cloud Build trigger
Emojipedia curates information about emoji and how they are represented on different platforms. E.g. the Sparkles emoji (
In Unicodex, these relations are represented by a codepoint (Sparkles) having multiple designs (images). Each image represents a version from a vendor (e.g. Google Android 9.0, Twitter Twemoji 1.0, ...). These relations are represented by four models:
Vendor, respectively. Designs have a FileField which stores the image.
In the django admin, an admin action has been setup so that you can select a Codepoint, and run the "Generate designs" actions. This will -- for all configured vendors and vendor versions -- scrape Emojipedia for the information. Alternatively, you can enter this information manually from the django admin.
Service design - 1:1:1
Unicodex runs as a Cloud Run service. Using the Python package
django-storages, it's been configured to take a
GS_BUCKET_NAME as a storage place for its media. Using the Python package
django-environ it takes a complex
DATABASE_URL, which will point to a Cloud SQL postgres database. These are all designed to live in the same Google Cloud Project.
In this way, Unicodex runs 1:1:1 -- one Cloud Run Service, one Cloud SQL Database, one Google Storage bucket. It also assumes that there is only one service/database/bucket.
This implementation is live at https://unicodex.gl.asnt.app/
Other service designs
With a few find/replace of some critical values, this setup can be converted to have multiple versions of the service each having their own database in a shared instance. More information for this can be found in the .util directory.
- implement custom database name (as well as instance)
- allow multiple
CURRENT_HOSTvalues (useful when handling custom domains)
Please see the contributing guidelines
This library is licensed under Apache 2.0. Full license text is available in LICENSE