|
| 1 | +# GCP: Cloud Run |
| 2 | + |
| 3 | +In this step-by-step guide, we'll guide you how to deploy your VulcanSQL project to Google Cloud Platform(GCP) |
| 4 | +using [Cloud Run](https://cloud.google.com/run). It's a service that we can build and deploy containerized apps |
| 5 | +written in any language(including Go, Python, Java, Node.js, .Net, and Ruby) on a fully managed platform. |
| 6 | + |
| 7 | +:::info |
| 8 | +For more detailed information of the deployment process, you can [read more here](https://cloud.google.com/run/docs/quickstarts/build-and-deploy/deploy-nodejs-service). |
| 9 | +::: |
| 10 | + |
| 11 | +## Step 1: Install and setup the Google Cloud CLI |
| 12 | + |
| 13 | +Before you begin to use Cloud Run on GCP, you need to do several things: |
| 14 | +1. In the Google Cloud console, on the [project selector page](https://console.cloud.google.com/projectselector2/home/dashboard), select or create a Google Cloud project. |
| 15 | +2. [Make sure the billing is enabled for your Google Cloud project.](https://cloud.google.com/billing/docs/how-to/verify-billing-enabled#console) |
| 16 | +3. [Install](https://cloud.google.com/sdk/docs/install) the Google Cloud CLI. |
| 17 | +4. Initialize the gcloud CLI with the folowwing command: |
| 18 | + ```shell |
| 19 | + gcloud init |
| 20 | + ``` |
| 21 | +5. You can set the default project for your Cloud Run service with the following command: |
| 22 | + ```shell |
| 23 | + gcloud config set project [PROJECT_ID] |
| 24 | + ``` |
| 25 | + |
| 26 | +For more detailed instructions on how to setup the environment, you can [read more here](https://cloud.google.com/run/docs/quickstarts/build-and-deploy/deploy-nodejs-service#before-you-begin). |
| 27 | + |
| 28 | +## Step 2: Package your VulcanSQL project |
| 29 | + |
| 30 | +In this guide, we'll deploy the Docker version of your VulcanSQL project. So please execute the following command in the terminal: |
| 31 | + |
| 32 | +```bash |
| 33 | +vulcan package --output docker |
| 34 | +``` |
| 35 | + |
| 36 | +After executing the command, you'll see a message shown like below and a new directory `dist` in the project directory. |
| 37 | + |
| 38 | +```bash |
| 39 | +2023-08-07 08:47:26.246 INFO [CORE] Package successfully, you can go to "dist" folder and run "docker build ." to build the image. |
| 40 | +✔ Package successfully. |
| 41 | +``` |
| 42 | + |
| 43 | +The directory structure of `dist` is as following: |
| 44 | + |
| 45 | +``` |
| 46 | +dist |
| 47 | +├── Dockerfile |
| 48 | +├── config.json |
| 49 | +├── index.js |
| 50 | +├── package.json |
| 51 | +└── result.json |
| 52 | +``` |
| 53 | + |
| 54 | +## Step 3: Deploy to Cloud Run from source |
| 55 | + |
| 56 | +Now you can deploy you VulcanSQL app to GCP with the following command: |
| 57 | + |
| 58 | +```shell |
| 59 | +gloud run deploy [YOUR_CLOUDRUN_SERVICE_NAME] --port=3000 --allow-unauthenticated |
| 60 | +``` |
| 61 | + |
| 62 | +:::caution |
| 63 | +Important: This quickstart assumes that you have owner or editor roles in the project you are using for the quickstart. |
| 64 | +Otherwise, refer to [Cloud Run deployment permissions](https://cloud.google.com/run/docs/reference/iam/roles#additional-configuration), |
| 65 | +[Cloud Build permissions](https://cloud.google.com/build/docs/iam-roles-permissions#predefined_roles), and |
| 66 | +[Artifact Registry permissions](https://cloud.google.com/artifact-registry/docs/access-control#permissions) for the permissions required. |
| 67 | +::: |
| 68 | + |
| 69 | +After successfully deploy the app, you'll see a similar message in the terminal: |
| 70 | + |
| 71 | +``` |
| 72 | +Service [vulcansql-project] revision [vulcansql-project-00001-mud] has been deployed and is serving 100 percent of traffic. |
| 73 | +Service URL: https://vulcansql-project-ggcxvljfba-df.a.run.app |
| 74 | +``` |
| 75 | + |
| 76 | +Congratulations! Now your VulcanSQL app is on the cloud and is ready to be shared to the world! |
0 commit comments