1"use strict";(self.webpackChunkdoc=self.webpackChunkdoc||[]).push([[5708],{3905:(e,o,t)=>{t.d(o,{Zo:()=>d,kt:()=>m});var n=t(7294);function r(e,o,t){return o in e?Object.defineProperty(e,o,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[o]=t,e}function l(e,o){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);o&&(n=n.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),t.push.apply(t,n)}return t}function a(e){for(var o=1;o<arguments.length;o++){var t=null!=arguments[o]?arguments[o]:{};o%2?l(Object(t),!0).forEach((function(o){r(e,o,t[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):l(Object(t)).forEach((function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}))}return e}function i(e,o){if(null==e)return{};var t,n,r=function(e,o){if(null==e)return{};var t,n,r={},l=Object.keys(e);for(n=0;n<l.length;n++)t=l[n],o.indexOf(t)>=0||(r[t]=e[t]);return r}(e,o);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)t=l[n],o.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var p=n.createContext({}),u=function(e){var o=n.useContext(p),t=o;return e&&(t="function"==typeof e?e(o):a(a({},o),e)),t},d=function(e){var o=u(e.components);return n.createElement(p.Provider,{value:o},e.children)},c={inlineCode:"code",wrapper:function(e){var o=e.children;return n.createElement(n.Fragment,{},o)}},s=n.forwardRef((function(e,o){var t=e.components,r=e.mdxType,l=e.originalType,p=e.parentName,d=i(e,["components","mdxType","originalType","parentName"]),s=u(t),m=r,g=s["".concat(p,".").concat(m)]||s[m]||c[m]||l;return t?n.createElement(g,a(a({ref:o},d),{},{components:t})):n.createElement(g,a({ref:o},d))}));function m(e,o){var t=arguments,r=o&&o.mdxType;if("string"==typeof e||r){var l=t.length,a=new Array(l);a[0]=s;var i={};for(var p in o)hasOwnProperty.call(o,p)&&(i[p]=o[p]);i.originalType=e,i.mdxType="string"==typeof e?e:r,a[1]=i;for(var u=2;u<l;u++)a[u]=t[u];return n.createElement.apply(null,a)}return n.createElement.apply(null,t)}s.displayName="MDXCreateElement"},6751:(e,o,t)=>{t.r(o),t.d(o,{assets:()=>p,contentTitle:()=>a,default:()=>c,frontMatter:()=>l,metadata:()=>i,toc:()=>u});var n=t(7462),r=(t(7294),t(3905));const l={},a="GCP: Cloud Run",i={unversionedId:"deployment/gcp-cloud-run",id:"deployment/gcp-cloud-run",title:"GCP: Cloud Run",description:"In this step-by-step guide, we'll guide you how to deploy your VulcanSQL project to Google Cloud Platform(GCP)",source:"@site/docs/deployment/gcp-cloud-run.mdx",sourceDirName:"deployment",slug:"/deployment/gcp-cloud-run",permalink:"/docs/deployment/gcp-cloud-run",draft:!1,editUrl:"https://github.com/Canner/vulcan-sql/tree/main/packages/doc/docs/deployment/gcp-cloud-run.mdx",tags:[],version:"current",frontMatter:{},sidebar:"tutorialSidebar",previous:{title:"Fly.io",permalink:"/docs/deployment/flydotio"},next:{title:"GCP: App Engine",permalink:"/docs/deployment/gcp-app-engine"}},p={},u=[{value:"Step 1: Install and setup the Google Cloud CLI",id:"step-1-install-and-setup-the-google-cloud-cli",level:2},{value:"Step 2: Package your VulcanSQL API Server",id:"step-2-package-your-vulcansql-api-server",level:2},{value:"Step 3: Deploy to Cloud Run from source",id:"step-3-deploy-to-cloud-run-from-source",level:2},{value:"Step 4: (Optional) Deploy your VulcanSQL API Catalog Server",id:"step-4-optional-deploy-your-vulcansql-api-catalog-server",level:2}],d={toc:u};function c(e){let{components:o,...t}=e;return(0,r.kt)("wrapper",(0,n.Z)({},d,t,{components:o,mdxType:"MDXLayout"}),(0,r.kt)("h1",{id:"gcp-cloud-run"},"GCP: Cloud Run"),(0,r.kt)("p",null,"In this step-by-step guide, we'll guide you how to deploy your VulcanSQL project to Google Cloud Platform(GCP)\nusing ",(0,r.kt)("a",{parentName:"p",href:"https://cloud.google.com/run"},"Cloud Run"),". It's a service that we can build and deploy containerized apps\nwritten in any language(including Go, Python, Java, Node.js, .Net, and Ruby) on a fully managed platform."),(0,r.kt)("admonition",{type:"info"},(0,r.kt)("p",{parentName:"admonition"},"For more detailed information of the deployment process, you can ",(0,r.kt)("a",{parentName:"p",href:"https://cloud.google.com/run/docs/quickstarts/build-and-deploy/deploy-nodejs-service"},"read more here"),".")),(0,r.kt)("h2",{id:"step-1-install-and-setup-the-google-cloud-cli"},"Step 1: Install and setup the Google Cloud CLI"),(0,r.kt)("p",null,"Before you begin to use Cloud Run on GCP, you need to do several things:"),(0,r.kt)("ol",null,(0,r.kt)("li",{parentName:"ol"},"In the Google Cloud console, on the ",(0,r.kt)("a",{parentName:"li",href:"https://console.cloud.google.com/projectselector2/home/dashboard"},"project selector page"),", select or create a Google Cloud project."),(0,r.kt)("li",{parentName:"ol"},(0,r.kt)("a",{parentName:"li",href:"https://cloud.google.com/billing/docs/how-to/verify-billing-enabled#console"},"Make sure the billing is enabled for your Google Cloud project.")),(0,r.kt)("li",{parentName:"ol"},(0,r.kt)("a",{parentName:"li",href:"https://cloud.google.com/sdk/docs/install"},"Install")," the Google Cloud CLI."),(0,r.kt)("li",{parentName:"ol"},"Initialize the gcloud CLI with the following command:",(0,r.kt)("pre",{parentName:"li"},(0,r.kt)("code",{parentName:"pre",className:"language-shell"},"gcloud init\n"))),(0,r.kt)("li",{parentName:"ol"},"You can set the default project for your Cloud Run service with the following command:",(0,r.kt)("pre",{parentName:"li"},(0,r.kt)("code",{parentName:"pre",className:"language-shell"},"gcloud config set project [PROJECT_ID]\n")))),(0,r.kt)("p",null,"For more detailed instructions on how to setup the environment, you can ",(0,r.kt)("a",{parentName:"p",href:"https://cloud.google.com/run/docs/quickstarts/build-and-deploy/deploy-nodejs-service#before-you-begin"},"read more here"),"."),(0,r.kt)("h2",{id:"step-2-package-your-vulcansql-api-server"},"Step 2: Package your VulcanSQL API Server"),(0,r.kt)("p",null,"In this guide, we'll deploy the Docker version of your VulcanSQL API Server. So please execute the following command in the terminal:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-bash"},"vulcan package --output docker\n")),(0,r.kt)("p",null,"After executing the command, you'll see a message shown like below and a new directory ",(0,r.kt)("inlineCode",{parentName:"p"},"dist")," in the project directory."),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-bash"},'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. \n\u2714 Package successfully.\n')),(0,r.kt)("p",null,"The directory structure of ",(0,r.kt)("inlineCode",{parentName:"p"},"dist")," is as following:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre"},"dist\n\u251c\u2500\u2500 Dockerfile\n\u251c\u2500\u2500 config.json\n\u251c\u2500\u2500 index.js\n\u251c\u2500\u2500 package.json\n\u2514\u2500\u2500 result.json\n")),(0,r.kt)("admonition",{type:"caution"},(0,r.kt)("p",{parentName:"admonition"},"External resources and configurations, such as ",(0,r.kt)("inlineCode",{parentName:"p"},"profiles.yaml"),", are not copied to the ",(0,r.kt)("inlineCode",{parentName:"p"},"dist")," folder.\nYou'll need to copy them manually. We strongly recommend using a separate profile instead of the one used for development."),(0,r.kt)("p",{parentName:"admonition"},"After copying ",(0,r.kt)("inlineCode",{parentName:"p"},"profiles.yaml")," into the ",(0,r.kt)("inlineCode",{parentName:"p"},"dist")," folder, you should also add one line in ",(0,r.kt)("inlineCode",{parentName:"p"},"Dockerfile")," as following:"),(0,r.kt)("pre",{parentName:"admonition"},(0,r.kt)("code",{parentName:"pre",className:"language-shell"},'.\n.\n.\nFROM node:16-bullseye-slim\nWORKDIR /usr/app\nCOPY --from=build /usr/app /usr/app\nCOPY config.json .\nCOPY index.js .\nCOPY result.json .\n# add the line below\nCOPY profiles.yaml .\nENV NODE_ENV production\n\nCMD [ "node", "index.js" ]\n')),(0,r.kt)("p",{parentName:"admonition"},(0,r.kt)("strong",{parentName:"p"},"Notes: if you have ",(0,r.kt)("a",{parentName:"strong",href:"../references/data-source-profile#define-profile-in-independent-yaml-files"},"multiple profiles"),",\nyou should copy them into the dist folder and add them all in the Dockerfile."))),(0,r.kt)("h2",{id:"step-3-deploy-to-cloud-run-from-source"},"Step 3: Deploy to Cloud Run from source"),(0,r.kt)("p",null,"Now you can deploy you VulcanSQL a
1pp to GCP with the following command:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-shell"},"gloud run deploy [YOUR_CLOUDRUN_SERVICE_NAME] --port=3000 --allow-unauthenticated\n")),(0,r.kt)("admonition",{type:"caution"},(0,r.kt)("p",{parentName:"admonition"},"Important: This quickstart assumes that you have owner or editor roles in the project you are using for the quickstart.\nOtherwise, refer to ",(0,r.kt)("a",{parentName:"p",href:"https://cloud.google.com/run/docs/reference/iam/roles#additional-configuration"},"Cloud Run deployment permissions"),",\n",(0,r.kt)("a",{parentName:"p",href:"https://cloud.google.com/build/docs/iam-roles-permissions#predefined_roles"},"Cloud Build permissions"),", and\n",(0,r.kt)("a",{parentName:"p",href:"https://cloud.google.com/artifact-registry/docs/access-control#permissions"},"Artifact Registry permissions")," for the permissions required.")),(0,r.kt)("p",null,"After successfully deploy the app, you'll see a similar message in the terminal:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre"},"Service [vulcansql-project] revision [vulcansql-project-00001-mud] has been deployed and is serving 100 percent of traffic.\nService URL: https://vulcansql-project-ggcxvljfba-df.a.run.app\n")),(0,r.kt)("p",null,"Congratulations! Now your VulcanSQL app is on the cloud and is ready to be shared to the world!"),(0,r.kt)("admonition",{type:"info"},(0,r.kt)("p",{parentName:"admonition"},"If you need to clean up the resources on Cloud Run, you can ",(0,r.kt)("a",{parentName:"p",href:"https://cloud.google.com/run/docs/quickstarts/build-and-deploy/deploy-nodejs-service#clean-up"},"read the documentation here"),".")),(0,r.kt)("h2",{id:"step-4-optional-deploy-your-vulcansql-api-catalog-server"},"Step 4: (Optional) Deploy your VulcanSQL API Catalog Server"),(0,r.kt)("p",null,"If you need to deploy API Catalog Server, you should execute the following command in the terminal:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-shell"},"vulcan package -t catalog-server -o docker\n")),(0,r.kt)("admonition",{type:"caution"},(0,r.kt)("p",{parentName:"admonition"},"The folder generated by the command is also called ",(0,r.kt)("inlineCode",{parentName:"p"},"dist"),", so if you had executed the command of packaging\nAPI server, you should rename the ",(0,r.kt)("inlineCode",{parentName:"p"},"dist")," folder generated previously to prevent from being overwritten.")),(0,r.kt)("p",null,"Then, you should modify ",(0,r.kt)("inlineCode",{parentName:"p"},"API_BASE_URL")," to the URL of your VulcanSQL API Server you just deployed in Dockerfile:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-dockerfile"},"ENV API_BASE_URL [URL of VulcanSQL API Server]\n")),(0,r.kt)("p",null,"Finally, you execute the same Google Cloud CLI commands used in the step 3 in the terminal, and change any configurations if you need:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre"},"gloud run deploy [YOUR_CLOUDRUN_SERVICE_NAME] --port=4200 --allow-unauthenticated\n")))}c.isMDXComponent=!0}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.