Deploying a containerized QR code generator app on Google Cloud Run

Recently I had to create some slides for a lightning talk I will giving at Google Next ’24 and wanted to create QR codes to share some of my GitHub repositories. Unhappy with some of the options I found, I decided to create my own!

Glen Yu
Google Cloud - Community
3 min readMar 22, 2024

--

QR code leads to app’s GitHub repo

I wanted to preface this post with the fact that I did find QRCode Monkey shortly after I embarked on this little fun project. If I’m being honest, it was less about creating my own QR coder and more about this being an opportunity to for me to write and deploy an app that solves a problem.

Python app + Project IDX

While I wouldn’t call myself a software developer, I’m quite comfortable with Python. Luckily, there seems to be a Python libraries for just about everything — and sure enough, there was one for generating QR codes!

The qrcode library’s documentation was clear and user-friendly, allowing me to generate QR codes locally on my laptop within minutes. I could have stopped here, but I wanted to offer another free QR code generation site for people to find and use.

Project IDX

I got a head start on development thanks to preview access to Google’s Project IDX, an experimental web-based IDE for building applications. Project IDX’s built-in AI generated helpful starter code for the Flask frontend, streamlining the process.

Project IDX interface

That evening, I built a functional prototype. The next day, I began deploying it to Cloud Run, Google’s serverless container platform.

Deployment on Google Cloud

I have alway advocated for Google’s Always Free Tier — a very generous monthly allowance of resources you can use for no cost (assuming you stay within its limits, of course). I always try to use free-tier resources whenever I create projects or demos as it ensures anyone replicating or deploying their own version avoids unexpected costs. With that said, let’s go over some of the free-tier services I used in this project.

Cloud Build

Cloud Build is what I use as my CI/CD tool, and it goes beyond just building. It can also be used for deployment. My Cloud Build pipeline incorporates external container images for pre-deployment checks. The checks include linting, efficiency, and vulnerability scans before the image is pushed to Artifact Registry.

Cloud Run

For deploying containerized web apps, Cloud Run is my go-to platform. Its versatility shines with extensive configuration options and a variety of sizing choices. The ability to scale to zero is what I like most as it helps keep costs to a minimum (I run multiple Cloud Run services across different projects).

One of the most underrated features of Cloud Run is the ability to map custom domains to Cloud Run services. You just make sure you follow the instructions and create the proper DNS entries (for a domain that you own, of course) and Google Cloud will handle the rest, including provisioning SSL certs.

Cloud Storage

Even though the generated QR codes are small, I opted to use Cloud Storage rather than temporary storage in the container, which will help minimize memory usage over time. To ensure proper cleanup, I implemented a one-day retention policy on the storage bucket.

Architecture of my QR coder app

What’s next?

Currently, my Free QR Code App can only generate a simple QR code for URLs. I want to expand on its capabilities and include customization options such as the image styles, and the ability to add a custom logo in the centre. I learned that there are also Wi-Fi QR codes that make connecting to Wi-Fi a breeze. I will likely have to refactor the code to when I add these features.

--

--

Glen Yu
Google Cloud - Community

Cloud Engineering @ PwC Canada. I'm a Google Cloud GDE, HashiCorp Ambassador and HashiCorp Core Contributor (Nomad). Also an ML/AI enthusiast!