{
"$type": "site.standard.document",
"canonicalUrl": "https://unnecessary.tech/posts/quick_run_site",
"path": "/posts/quick_run_site",
"publishedAt": "2019-04-25T00:00:00.000Z",
"site": "at://did:plc:jx54v4rmscfwzit7fmgz24ba/site.standard.publication/3mnrsqmzz3w2e",
"tags": [
"cloud"
],
"textContent": "In my previous post I discussed Google Cloud\nRun as a docker-based PaaS. An opportunity\narose to put together a quick website to help people play the Martian on the\nLoose scavenger hunt game which is\ncurrently running to promote The Expanse\ntelevision series. The game is managed entirely on twitter by the actor Cas\nAnvar who plays one of the main characters in\nthe series, and was instrumental in rallying fans to save the show when SyFy\ncanceled it, ultimately leading Amazon to produce the show's upcoming 4th\nseason. \n\nThe downside of running a game on twitter is that the rules\npost becomes\nincreasingly harder to find as the game continues. There are also a couple of\nregular posts of clues, required to solve the puzzle for each scavenger hunts,\nand it seems fairly common for there to be confusion over finding the clues\nfor the most recent hunt. In order to fix this, I decided to put together a\nweb site which holds both the instructions\nand the links to the clues for the current scavenger hunt. I also retyped the\ninstructions to make it more accessible. \n\nThe site is a simple static website, which I could have hosted just about\nanywhere. Netlify, Zeit,\nor Surge are all great choices for serving a static site,\nbut I decided to give Cloud Run a try. I've\nput up the full source code on\ngithub. The Dockerfile\nuses the nginx:mainline image and copies in the static files along with a\nconfiguration template and a shell script with adjusts the Nginx listening\nport at runtime. The script is necessary because Cloud Run passes in a PORT\nenvironment variable to indicate which port the server should listen on. \n\nI use a cloudbuild.yaml to ensure the Google Cloud\nBuild system builds the container,\nstores it in the container registry, and then deploys it to Cloud Run\nautomatically. I can therefore just use the command\n\nto build and deploy the website into production. In order for this to work,\nthe following roles must be added to the Cloud Build service account\n(which is the project number followed by @cloudbuild.gserviceaccount.com):\n\n- Cloud Build Service Account\n- Service Account User\n- Cloud Run Admin\n\nThis can be done from the IAM & admin page in the Google Cloud Console.\n\nSo far it looks like it's working well, although there are many ways to deploy\na static site, and Cloud Run is not really the optimal solution. Despite the\nfact that the resulting container is rather large at 114 MB, it still started\nup from a cold state in less than a second (749 ms from request sent to\nresponse received), and then has typically returned a web page in 3-15 ms. The\nbuild time for the container on Google Cloud Build was 40 seconds. Overall it\nseems like a relatively painless way to deploy a web site.",
"title": "Martian on the Loose: A Quick Cloud Run Site"
}