이 페이지에서는 VS Code용 Cloud Code 원격 개발을 사용하는 방법을 설명합니다. 즉, 애플리케이션을 빌드, 디버깅, 배포하는 원격 컨테이너에서 코드베이스를 여는 방법을 설명합니다. 이렇게 하면 개발 머신의 OS에 관계없이 이동성이 있는 애플리케이션이 생성됩니다.
Dockerfile에서 >> $HOME/.bashrc 명령어 앞에 localhost의 gcloud CLI 및 Skaffold 구성을 복사하기 위한 안내를 추가합니다. 또는 gcloud CLI 및 Skaffold를 설치하도록 명령어를 재작성할 수 있습니다.
# Copy localhost's ~/.kube/config file into the container and swap out localhost
# for host.docker.internal whenever a new shell starts to keep them in sync.
RUN echo '\n\
if [ "$SYNC_LOCALHOST_KUBECONFIG" == "true" ]; then\n\
mkdir -p $HOME/.kube\n\
cp -r $HOME/.kube-localhost/* $HOME/.kube\n\
sed -i -e "s/localhost/host.docker.internal/g" $HOME/.kube/config\n\
\n\
fi' \
if [ "$SYNC_LOCALHOST_GCLOUD" == "true" ]; then\n\
mkdir -p $HOME/.config/gcloud\n\
cp -r $HOME/.gcloud-localhost/* $HOME/.config/gcloud\n\
\n\
fi' \
Devcontainer.json 파일을 열고 localhost에서 gcloud CLI 및 Skaffold 구성을 복사하도록 다음 실행 인수를 추가합니다.
devcontainer.json 파일은 원격 컨테이너 확장에 컨테이너에서 노출할 포트, 드라이브 마운트 방법, 원격 컨테이너에서 설치할 확장을 지정합니다. 다음 샘플 devcontainer.json 파일은 원격 컨테이너 확장이 VS Code용 Cloud Code 확장을 설치하도록 지정합니다.
[[["이해하기 쉬움","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\u003eThis guide outlines how to use Cloud Code for VS Code with Remote Development, enabling the building, debugging, and deployment of applications within a portable remote container.\u003c/p\u003e\n"],["\u003cp\u003eSetting up involves configuring a \u003ccode\u003e.devcontainer\u003c/code\u003e folder with a Dockerfile and \u003ccode\u003eDevcontainer.json\u003c/code\u003e file, tailored to your development language, to define the container's environment.\u003c/p\u003e\n"],["\u003cp\u003eThe Dockerfile should include instructions for installing the Google Cloud CLI and Skaffold, essential tools for working with Cloud Code, which you can add by following the official installation guides.\u003c/p\u003e\n"],["\u003cp\u003eThe process involves copying gcloud CLI and Skaffold configurations from the local host into the container, or rewriting the commands, to synchronize and maintain consistent settings between environments.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eDevcontainer.json\u003c/code\u003e file manages the container's settings like exposed ports and extensions, with an example provided that includes the installation of the Cloud Code extension.\u003c/p\u003e\n"]]],[],null,["# Develop a Kubernetes app with remote development\n\n\u003cbr /\u003e\n\nThis page explains how to use Cloud Code for VS Code\n[Remote Development](https://code.visualstudio.com/docs/remote/ssh),\nthat is, to open your codebase in a remote container where your application is\nbuilt, debugged, and deployed. This creates an application that's portable,\nregardless of the OS of your development machine.\n| **Note:** For steps to set up remote debugging on Chrome OS, see [Build a dev workflow with Cloud Code on a Pixelbook](/blog/products/application-development/build-a-dev-workflow-with-cloud-code-on-a-pixelbook).\n\nPrerequisites\n-------------\n\nIn addition to the setup described in\n[Install the Cloud Code extension](/code/docs/vscode/install),\ninstall the\n[Remote Development](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack)\nVS Code extension pack.\n\nSetup\n-----\n\n1. To set up a `.devcontainer` folder with a Dockerfile and `Devcontainer.json`\n file configured for the language you're using, click\n **Open a Remote Window** \\\u003e **Add Dev Container Config Files** .\n Alternatively, you can follow the steps in\n [Remote development in Containers](https://code.visualstudio.com/docs/remote/containers-tutorial).\n\n After you follow the prompts, your workspace will include:\n - Dockerfile --- defines a container image that holds the developer tools to\n install in a remote development container.\n\n - `Devcontainer.json` --- Instructs the VS Code Remote Tools extension how to run\n the remote development container.\n\n2. Open the Dockerfile and add instructions to install the\n [Google Cloud CLI](/sdk/docs/downloads-interactive) and\n [Skaffold](https://skaffold.dev/docs/install/). For up-to-date\n commands, see the installation guides.\n\n3. In the Dockerfile, add instructions to copy localhost's\n gcloud CLI and Skaffold configs before the `\u003e\u003e $HOME/.bashrc`\n command. Alternatively,\n you can rewrite the commands to install the gcloud CLI\n and Skaffold.\n\n # Copy localhost's ~/.kube/config file into the container and swap out localhost\n # for host.docker.internal whenever a new shell starts to keep them in sync.\n RUN echo '\\n\\\n if [ \"$SYNC_LOCALHOST_KUBECONFIG\" == \"true\" ]; then\\n\\\n mkdir -p $HOME/.kube\\n\\\n cp -r $HOME/.kube-localhost/* $HOME/.kube\\n\\\n sed -i -e \"s/localhost/host.docker.internal/g\" $HOME/.kube/config\\n\\\n \\n\\\n fi' \\\n if [ \"$SYNC_LOCALHOST_GCLOUD\" == \"true\" ]; then\\n\\\n mkdir -p $HOME/.config/gcloud\\n\\\n cp -r $HOME/.gcloud-localhost/* $HOME/.config/gcloud\\n\\\n \\n\\\n fi' \\\n\n4. Open the `Devcontainer.json` file and add the following run arguments to\n copy the gcloud CLI and Skaffold configs from localhost:\n\n \"-e\", \"SYNC_LOCALHOST_KUBECONFIG=true\",\n \"-e\", \"SYNC_LOCALHOST_GCLOUD=true\",\n\n5. After your files have the required contents, click\n\n **Open a Remote Window**.\n\nSample devcontainer.json file\n-----------------------------\n\nThe `devcontainer.json` file tells the Remote Container extension which ports to\nexpose in the container, how to mount drives, and which extensions to install\nin the remote container. The following sample `devcontainer.json` file\nspecifies that the Remote Container extension should install the\nCloud Code for VS Code extension: \n\n \"runArgs\": [\n \"-v\",\"/var/run/docker.sock:/var/run/docker.sock\",\n \"--mount\", \"type=bind,source=${env:HOME}${env:USERPROFILE}/.kube,target=/root/.kube-localhost\",\n \"--mount\", \"type=bind,source=${env:HOME}${env:USERPROFILE}/.config/gcloud,target=/root/.gcloud-localhost\",\n \"-e\", \"SYNC_LOCALHOST_KUBECONFIG=true\",\n \"-e\", \"SYNC_LOCALHOST_GCLOUD=true\",\n \"--cap-add=SYS_PTRACE\", \"--security-opt\", \"seccomp=unconfined\"\n ]\n\nWhat's next\n-----------\n\n- Read the Visual Studio docs on [remote development using SSH](https://code.visualstudio.com/docs/remote/ssh).\n- Take a tutorial to [run Visual Studio Code in a docker container](https://code.visualstudio.com/docs/devcontainers/tutorial). using the Dev containers extension.\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)."]]