Now that you have a containerized application it’s time to deploy it to the internet. Google’s CloudRun is a service that takes a container image that listens for HTTP on a single port and makes it available (and scalable) to the internet. In this week’s labs I demonstrate how to use environment variables and deploy your application to CloudRun. To complete this milestone you will need to ensure your container is configurable using environment variables and deploy it to CloudRun.
In the CloudRun lab I ran in to some trouble! Put this line in your
settings.py to fix it:
CSRF_TRUSTED_ORIGINS = [ "https://*.run.app" ]
Keep the Embedded Database#
The database should still be embedded in the container. This will enable you to easily run your container with the infrastructure we have so far. This is the last milestone where the embedded database is to be used. One thing you’ll notice about the embedded database is that if you create a user in CloudRun the user will be forgotten if your application doesn’t see any activity for a while. This is what is meant by stateless. Just like last time, you should initialize the database with the following defaults:
Cabri11o(a.k.a “funny Cabrillo”)
I won’t do any automated testing. When you turn in this milestone I’ll go to your application’s URL and log in. I’ll also verify that you’ve met the requirements by looking at your source code.
Submissions for this milestone should have
milestone-4.x in the release name.
In the Deploy to CloudRun lab you should have created a CloudBuild pipeline that builds your container in Google’s infrastructure. Verify that you configured CloudBuild to trigger only on a
milestone-4.x tag. If you kept the default
main branch build your container may change before I have a time to check it.
You should move configuration and secrets into environment variables:
$DJANGO_SECRETvariable must be used
You must update your
Dockerfileto use the
$PORTvariable when starting the container
Tag this milestone
Submit the URL to your application in CloudRun so I can browse it
Submit your GitHub repository URL so I can check your files