# Stateless Deployment#

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.

## Configuration Fix#

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:

• Admin username: student

• Admin email: student@cis.cabrillo.edu

• Admin password: Cabri11o (a.k.a “funny Cabrillo”)

## Test Procedure#

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.

## Release#

Submissions for this milestone should have milestone-4.x in the release name.

Important

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.

## Requirements#

1. You should move configuration and secrets into environment variables:

1. The $DJANGO_SECRET variable must be used 2. You must update your Dockerfile to use the $PORT variable when starting the container

## Turn In#

1. Tag this milestone milestone-4.x.

2. Submit the URL to your application in CloudRun so I can browse it

3. Submit your GitHub repository URL so I can check your files