Deploy to Google Cloud Platform using Cloud Run: a step-by-step guide.
Google Cloud Platform (GCP) is a suite of cloud computing services from Google, providing a comprehensive infrastructure to deploy and manage applications of all kinds. In this article, you will learn how to deploy your Pathway application to GCP using Cloud Run, a compute platform that lets you run containers on scalable infrastructue.
The entire process is as easy as deploying any dockerized application. You will see, step by step, how to deploy a Pathway web service hosted on a GitHub repository.
Prerequisites
- Google account
- GitHub account
- A GitHub project with Pathway application and Dockerfile
For an easy start, you can fork our demo repository.
Note: Regardless of whether you use a Gmail or Google Workspace account, you can test Cloud Run for free. Google may require billing information, but you will not be charged after the trial period.
Create Google Cloud project
The first step is to create a Google Cloud project at GCP Console
- Choose friendly name of your project and click
Create
Create Cloud Run service
Now that you have your project ready, go to Cloud Run. Make sure your newly created project is selected in top left corner.
- Click on the "Create Service" button
- Select "Continuously deploy from a repository" and click on "Set up with Cloud Build":
- Point to the repository with your Pathway application and click the "Next" button.
Note: Google may prompt you to enable additional APIs. In such case simply click Enable and wait for a short time. If you are not authenticated already, choose Github as the repository provider and authenticate.
When prompted, paste your repository identifier: https://github.com/pathway-labs/realtime-indexer-qa-chat
- Choose "Dockerfile" as a build type and save the changes:
Note: if you are using custom repository, you can adjust Dockerfile path.
- Select "Allow unauthenticated invocations" as an authentication type:
- Under container resources section, increase memory to at least 1 GiB and click "Create":
Test your deployment
Once your app has been deployed, you will see a green mark next to the project name. You can now copy the URL of your service and test it with CURL.
If your deployment is ready, you can test it with the following command:
curl -X POST -d '{"input": "hello, world"}' <YOUR-URL>
You can learn more about this example on GitHub.
Deploy changes
You have successfully deployed a sample Pathway application using Cloud Run. You can now adjust the Pathway pipeline by modifying app.py. Once you are ready, commit and push your changes. Cloud Build will automatically detect your changes and start deploying the new version. You can monitor this process under the revisions tab.
Delete your web service
If you were only testing your web service and wish to delete it, go to Cloud Run, select your service, and click the "Delete" button.
Conclusions
In this guide, you learned how to deploy a Pathway application to GCP using Cloud Run, from setting up your Google Cloud project to testing and managing your deployment. By leveraging the continuous deployment capabilities of Google Cloud Build, you can deploy changes to your applications in seconds. Don't hesitate to explore other methods for deploying Pathway in our dedicated article.