Visual Studio Code, Google Cloud Run and Multipass

I recently wrote a story about how using Canonical’s multipass can provide a WSL-like isolated development environment on MacOS and Linux. I am a rather big fan of simple deployment and CI/CD, hence wanted to see if I could integrate Google Cloud Run deployment through Visual Studio Code on Multipass. Good news is that it is actually quite painless.

If you haven’t read my primer on getting set up with Multipass yet, head over to here and check it out. Also, this guide assumes you have already created a working Google Cloud Run deployment, if not, have a look at this guide by Google. Once you have all of these components set up, let’s look at how we can configure a simple CI/CD pipeline using Visual Studio Code and Cloud Run.

First things first, launch a Visual Studio Code Remote SSH connection to your Multipass virtual machine. Then we need to install an extension to the remote instance, called Google Cloud Code. Cloud Code makes interacting with Google Cloud Run through Visual Studio Code extremely simple. Install the extension, and authenticate yourself with your Google Cloud project accordingly. The great thing about installing this remotely (within the VM) is that the configuration and credentials are unique to that Multipass instance. No more re-authenticating necessary!

Once this is setup, we need to install Docker in the Multipass instance, so that Cloud Code can build your project and deploy it to Google Cloud Platform. There are a few commands that we need to run here:

Once Docker has been installed, we need to do one last step that if not performed, will cause permissions errors when connecting to Docker’s build socket.

We can now restart the Docker daemon:

Now the machine has been configured to use Cloud Run with the correct credentials, and has a Docker build engine set up, we can proceed to deploy our application through the Cloud Code extension.

Simply click the Cloud Code tab at the bar at the bottom of Visual Studio Code:

This will guide you through the project to deploy to. Click Begin Deployment to deploy.

--

--

Developer and AI enthisiast from Sydney. Founder of Alixir. Check me out @ https://jlgn.io

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Dr. Joe Logan

Developer and AI enthisiast from Sydney. Founder of Alixir. Check me out @ https://jlgn.io