정의한 .vscode/launch.json 파일이 없는 경우 Cloud Run 에뮬레이터에서 실행/디버그 대화상자를 사용하면 실행을 구성한 다음 .vscode/launch.json에 설정을 저장할 수 있습니다. .vscode/launch.json 파일을 구성한 경우에는 파일을 직접 수정할 수 있습니다.
서비스를 로컬로 실행하려면 구성을 지정하세요.
명령어 팔레트를 연 다음(Ctrl/Cmd+Shift+P 키를 누르거나 보기 > 명령어 팔레트 클릭) Cloud Run 에뮬레이터에서 실행 명령어를 실행합니다.
Cloud Run 에뮬레이터의 실행/디버그 대화상자에서 구성의 사양을 설정합니다.
로컬에 설치된 빌드 도구만 Cloud Run 에뮬레이터에 사용할 수 있습니다.
Docker 또는 Buildpacks를 빌더로 선택한 후 소스를 지정하세요.
(선택사항) 실행 중인 컨테이너에 전달할 환경 변수를 지정하려면 고급 빌드 설정을 펼친 다음 키-값 쌍을 클릭하여 지정합니다.
이름
설명
예
PORT
리슨할 HTTP 서버의 포트입니다.
8080
K_SERVICE
실행되는 Cloud Run 서비스의 이름입니다.
hello-world
K_REVISION
실행되는 Cloud Run 버전의 이름입니다.
hello-world.1
K_CONFIGURATION
버전을 만든 Cloud Run 구성의 이름입니다.
hello-world
(선택사항) Cloud SQL 연결을 지정하려면 고급 서비스 설정을 펼치고 연결을 클릭한 후 한 줄에 Cloud SQL 연결 하나를 지정합니다.
(선택사항) 로컬 네트워크의 다른 기기에서 서비스에 액세스할 수 있도록 설정 옵션을 선택합니다.
(선택사항) 변경 시 자동으로 서비스를 다시 빌드하고 실행하는 대신 수동으로 다시 빌드하고 실행만 하려면 변경 시 자동으로 다시 빌드 및 다시 실행 옵션을 선택 취소합니다.
배포가 완료된 후 출력 창에 표시된 URL을 열어 실행 중인 서비스를 확인할 수 있습니다.
상세 로그를 보려면 출력 창에서 자세한 Cloud Run 보기로 전환합니다.
세션이 완료되면 마우스 오른쪽 버튼을 클릭하여 다음 명령어를 사용합니다.
로그 보기: Cloud Code 로그 탐색기를 사용하여 특정 배포의 애플리케이션 로그를 엽니다.
URL 열기: 웹브라우저에서 특정 서비스의 애플리케이션 서비스 URL을 엽니다.
시작 구성에서 감시 모드를 사용 중지한 상태에서 애플리케이션을 변경하고 애플리케이션을 다시 빌드 및 다시 배포하려면 Cloud Code 상태 표시줄을 클릭한 다음 감시 모드 사용 설정을 클릭합니다.
배포를 중지하려면 현재 배포의 작업 모음에서 중지 버튼을 클릭합니다.
보안 비밀 저장
코드에 API 키, 비밀번호, 인증서와 같은 민감한 정보가 포함되어 있는 경우 이를 보안 비밀로 저장하면 보안을 강화할 수 있습니다. Cloud Code Secret Manager 통합을 통해 이러한 보안 비밀을 안전하게 저장하고 프로그래매틱 방식으로 가져올 수 있습니다. Cloud Code를 사용하여 보안 비밀을 만들고 관리하는 방법에 대한 자세한 내용은 Secret Manager 가이드를 참조하세요.
기존 launch.json 구성 맞춤설정
실행 작업을 선택하면 Cloud Code 플러그인이 launch.json 구성 파일을 자동으로 업데이트합니다. 서비스 실행 방법을 추가로 맞춤설정하려면 .vscode/launch.json 파일에서 다음 필드를 지정합니다.
watch: 작업공간의 변경사항을 감시하고 서비스를 다시 실행합니다. 기본적으로 true입니다.
다음 샘플은 true로 설정된 감시를 보여줍니다.
"watch":true,
build: 이미지를 빌드할 빌더(Docker, jibMaven, jibGradle, 또는 buildpacks)를 지정합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-02-11(UTC)"],[[["\u003cp\u003eYou can develop services locally using a Cloud Run emulator before deploying them to Cloud Run, with configuration settings being stored in a \u003ccode\u003e.vscode/launch.json\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eThe Run/Debug on Cloud Run Emulator dialog or the command palette can be used to configure your service, allowing you to choose between Docker or Buildpacks, specify environment variables, and set Cloud SQL connections.\u003c/p\u003e\n"],["\u003cp\u003eOnce configured, you can run your service locally, monitor its deployment status in the output window, and view logs or access the service URL.\u003c/p\u003e\n"],["\u003cp\u003eSecrets like API keys can be securely managed using the Cloud Code Secret Manager integration, with details available in the Secret Manager guide.\u003c/p\u003e\n"],["\u003cp\u003eYou can customize your service's launch settings further by editing the \u003ccode\u003e.vscode/launch.json\u003c/code\u003e file, which allows for configuring options such as watching for changes, specifying the builder, setting the image and service, and defining debug settings.\u003c/p\u003e\n"]]],[],null,["# Develop a Cloud Run service locally in Cloud Code for VS Code\n\nBefore you\n[deploy a service to Cloud Run](/code/docs/vscode/deploy-service),\nyou can develop it locally using a Cloud Run emulator.\n\nConfiguring your service for development\n----------------------------------------\n\nIf you don't have a `.vscode/launch.json` file defined, the\n**Run/Debug on Cloud Run Emulator** dialog lets you configure your launch and\nthen saves your settings to `.vscode/launch.json`. If you have a\n`.vscode/launch.json` file configured, you can edit the file directly.\n\nTo run your service locally, specify your configuration:\n\n1. Open the command palette (press `Ctrl`/`Cmd`+`Shift`+`P` or click **View** \\\u003e **Command Palette** ) and then run the **Run on Cloud Run Emulator** command.\n2. In the Run/Debug on Cloud Run Emulator dialog, set the\n specifications for your configuration:\n\n - Only locally-installed build tools are available for Cloud Run Emulator\n - Choose **Docker** or **Buildpacks** as your builder and then specify the source\n - (Optional) To specify any environment variables to pass to the running containers, expand **Advanced Build Settings** and then click to specify key-value pairs.\n\n - (Optional) To specify Cloud SQL connections, expand **Advanced Service Settings** , click **Connections**, and then specify one Cloud SQL connection per line.\n - (Optional) Check the **Make the service accessible from other devices on the local network** option.\n - (Optional) If you only want to rebuild and run your service manually, instead of automatically when you make a change, clear the **Automatically re-build and re-run on changes** option.\n\nRunning your service locally\n----------------------------\n\n1. After you define your preferred settings, run your service by clicking\n **Run**.\n\n2. If prompted, [authenticate your credentials to run and debug an\n application locally](/code/docs/vscode/install#authenticate_credentials_for_debugging_applications_locally).\n\n3. Monitor the status of your deployment in the **output window**.\n\n After deployment is complete, you can view your running service by opening\n the URL displayed in the output window.\n4. To view verbose logs, switch to the detailed Cloud Run view\n in the output window.\n\n5. After your session completes, right-click to use the following commands:\n\n - **View Logs:** Open the application logs of a specific deployment with the Cloud Code logs explorer.\n - **Open URL:** Open the application service URL of a specific service in a web browser.\n6. If you've turned off watch mode in your launch configuration and you want to\n make changes to your application and rebuild and redeploy the application,\n click the Cloud Code status bar and then click\n **Turn on watch mode**.\n\n7. To stop your deployment, you can click the **Stop** button in the action bar\n for your current deployment.\n\nStoring secrets\n---------------\n\nIf your code includes potentially sensitive data like API keys, passwords, and\ncertificates, storing them as secrets can help secure them. The\nCloud Code Secret Manager integration lets you securely\nstore these secrets and fetch them programmatically. For a detailed look at how\nyou can create and manage secrets with Cloud Code, see\n\nthe [Secret Manager guide](/code/docs/vscode/secret-manager).\n\n\nCustomizing an existing launch.json configuration\n-------------------------------------------------\n\nThe Cloud Code plugin updates the `launch.json` configuration file\nautomatically when you choose a run action. To further customize how your\nservice is run, you can specify the following fields in your\n`.vscode/launch.json` file:\n\n- **watch**: Watches for changes in the workspace and reruns\n the service. True by default.\n\n The following sample shows watch set to `true`: \n\n \"watch\": true,\n\n- **build** : Specify the builder\n ([Docker](https://skaffold.dev/docs/pipeline-stages/builders/docker/),\n jibMaven, jibGradle, or\n [buildpacks](https://skaffold.dev/docs/pipeline-stages/builders/buildpacks/))\n to build your images with.\n\n The following sample shows a Docker builder: \n\n \"build\": {\n \"docker\": {\n \"path\": \"Dockerfile\"\n }\n },\n\n The following sample shows a buildpack builder: \n\n \"build\": {\n \"buildpacks\": {\n \"path\": \"src/requirements.txt\",\n \"builder\": \"gcr.io/buildpacks/builder:v1\"\n }\n },\n\n- **image**: Specify the name of the image to use.\n\n The following sample shows how to specify an image name: \n\n \"image\": \"hello-world\",\n\n- **service**: Specify the Cloud Run service to use.\n\n The following sample shows how to specify a service name, port, and resource\n limits: \n\n \"service\": {\n \"name\": \"hello-world\",\n \"containerPort\": 8080,\n \"resources\": {\n \"limits\": {\n \"memory\": \"256Mi\"\n }\n }\n },\n\n- **debug**: Specify debug settings such as remote path mapping to map a local\n path to a path on the remote container.\n\n The following sample shows a debug section that indicates the source files'\n location: \n\n \"debug\": {\n \"sourceFileMap\": {\n \"${workspaceFolder}\": \"/app\"\n }\n }\n\nGet Support\n-----------\n\nTo send feedback, report issues on [GitHub](https://github.com/GoogleCloudPlatform/cloud-code-vscode/issues), or ask a question on [Stack Overflow](https://stackoverflow.com/questions/ask?tags=cloud-code-vscode)."]]