이 페이지에서는 Cloud Build에서 커뮤니티 기부 빌더 및 커스텀 빌더를 사용하는 방법을 설명합니다. Cloud Build 개발자 커뮤니티는 태스크를 실행하는 데 사용할 수 있는 오픈소스 빌더를 제공합니다. 수행하려는 작업에 기존 이미지로 제공되지 않는 기능이 필요하면 고유 커스텀 이미지를 빌드하고 이를 빌드 단계에 사용할 수 있습니다. 다른 유형의 빌더에 대해 자세히 알아보려면 클라우드 빌더를 참조하세요.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2024-12-21(UTC)"],[[["\u003cp\u003eCloud Build allows the use of community-contributed builders, which are open-source tools provided by the developer community, after building and pushing them to Container Registry.\u003c/p\u003e\n"],["\u003cp\u003eTo utilize a community-contributed builder, clone the \u003ccode\u003ecloud-builders-community\u003c/code\u003e repository, navigate to the desired builder's directory, submit it using \u003ccode\u003egcloud builds submit\u003c/code\u003e, and then reference it in your Cloud Build config file.\u003c/p\u003e\n"],["\u003cp\u003eCustom builders can be created and used when existing builders do not meet specific task requirements, such as downloading external code, using external toolchains, or pre-building source code.\u003c/p\u003e\n"],["\u003cp\u003eCreating a custom builder involves defining a \u003ccode\u003eDockerfile\u003c/code\u003e, building and pushing it to Container Registry, and then specifying the image in the \u003ccode\u003ename\u003c/code\u003e field of a Cloud Build step.\u003c/p\u003e\n"],["\u003cp\u003eContainer Registry, which is used to store the builders, is scheduled for shutdown on March 18, 2025 and organizations which have not used it prior to January 8, 2024 will have new repositories hosted on Artifact Registry by default.\u003c/p\u003e\n"]]],[],null,["# Using community-contributed builders and custom builders\n\nThis page explains how to use [community-contributed builders](https://github.com/GoogleCloudPlatform/cloud-builders-community) and custom builders in Cloud Build. The\nCloud Build developer community provides [open-source\nbuilders](https://github.com/GoogleCloudPlatform/cloud-builders-community)\nthat you can use to execute your tasks. If the task you want to perform requires\ncapabilities that are not provided by an existing image, you can build your own\ncustom image and use it in a build step. To learn about the different types of\nbuilders, see [Cloud Builders](/build/docs/cloud-builders).\n\nIf you're new to Cloud Build, read the [quickstarts](/build/docs/quickstarts)\nand the [Build configuration overview](/build/docs/build-config) first.\n\nUsing community-contributed builders\n------------------------------------\n\nPrebuilt images are not available for community-contributed builders; to use\nthese builders in a Cloud Build config file, you must first build the\nimage and push it to [Artifact Registry](/artifact-registry/docs/overview) in\nyour project.\n\nTo use a community-contributed builder:\n\n1. Build and push the builder:\n\n 1. Navigate to your project root directory.\n\n 2. Clone the [cloud-builders-community](https://github.com/GoogleCloudPlatform/cloud-builders-community) repository:\n\n git clone https://github.com/GoogleCloudPlatform/cloud-builders-community.git\n\n 3. Navigate to the builder image you want to use, where \u003cvar translate=\"no\"\u003ebuilder-name\u003c/var\u003e\n is the directory that contains the builder:\n\n cd cloud-builders-community/\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003ebuilder\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e-\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003ename\u003c/span\u003e\u003c/var\u003e\n\n 4. Submit the builder to your project:\n\n gcloud builds submit .\n\n 5. Navigate back to your project root directory:\n\n cd ../..\n\n 6. Remove the repository from your root directory:\n\n rm -rf cloud-builders-community/\n\n2. In your Cloud Build config file, use the builder in a build step:\n\n ### YAML\n\n steps:\n - name: 'gcr.io/\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e/\u003cvar translate=\"no\"\u003ebuilder-name\u003c/var\u003e'\n args: ['\u003cvar translate=\"no\"\u003earg1\u003c/var\u003e', '\u003cvar translate=\"no\"\u003earg2\u003c/var\u003e', ...]\n ...\n\n ### JSON\n\n {\n \"steps\": [\n {\n \"name\": \"gcr.io/\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e/\u003cvar translate=\"no\"\u003ebuilder-name\u003c/var\u003e\",\n \"args\": [\n \"\u003cvar translate=\"no\"\u003earg1\u003c/var\u003e\",\n \"\u003cvar translate=\"no\"\u003earg2\u003c/var\u003e\",\n ...\n ]\n ...\n }\n ]\n }\n\n3. Use the build config file to start the [build manually](/build/docs/running-builds/start-build-manually)\n or [build using triggers](/build/docs/automating-builds/create-manage-triggers).\n\nFor examples on using community-contributed builders, see\n[Deploy to Firebase](/build/docs/deploying-builds/deploy-firebase)\nand [Build VM images using Packer](/build/docs/building/build-vm-images-with-packer).\n\nCreating a custom builder\n-------------------------\n\nIf the task you want to perform requires capabilities that are not provided by\n[a public image, a supported builder, or a community-contributed builder](/build/docs/cloud-builders),\nyou can build your own image and use it in a build step.\n\nSome examples of when you might want to use a custom builder image are:\n\n- Downloading source code or packages from external locations.\n- Using an external tool chain.\n- Caching any necessary libraries.\n- Pre-building source (with Cloud Build responsible only for potentially packaging the build into an image).\n\nLike any other builder, a custom builder runs with the source mounted under\n`/workspace`, and is run with a working directory in `/workspace`. Any files left\nin `/workspace` by a given build step are available to other build steps.\n\nYour custom builder can push to or pull from a repository in\n[Artifact Registry](/artifact-registry/docs/overview) (hosted at `gcr.io/$PROJECT-NAME/`)\nto which your [build service account](/build/docs/securing-builds/configure-user-specified-service-accounts) has\naccess.\n\nThe following steps show how to create and use a custom builder with an example\n`Dockerfile`:\n\n1. Create a custom builder image:\n\n 1. Create the `Dockerfile` for the custom builder. The following\n code shows an example `Dockerfile`:\n\n FROM alpine\n RUN apk add curl\n CMD curl https://httpbin.org/ip -s \u003e myip.txt; echo \"*** My IP is: $(cat myip.txt)\"\n\n 2. Build and push the custom builder to the Artifact Registry in your project,\n replacing values for \u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e and \u003cvar translate=\"no\"\u003eimage-name\u003c/var\u003e:\n\n gcloud builds submit --tag gcr.io/\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eproject\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e-\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003eid\u003c/span\u003e\u003c/var\u003e/\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eimage\u003c/span\u003e\u003cspan class=\"devsite-syntax-o\"\u003e-\u003c/span\u003e\u003cspan class=\"devsite-syntax-n\"\u003ename\u003c/span\u003e\u003c/var\u003e\n\n2. Use the custom builder image in Cloud Build by specifying the builder\n in the `name` field of a build step:\n\n ### YAML\n\n steps:\n - name: 'gcr.io/\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e/\u003cvar translate=\"no\"\u003eimage-name\u003c/var\u003e'\n id: Determine IP of this build worker\n\n ### JSON\n\n {\n \"steps\": [\n {\n \"name\": \"gcr.io/\u003cvar translate=\"no\"\u003eproject-id\u003c/var\u003e/\u003cvar translate=\"no\"\u003eimage-name\u003c/var\u003e\",\n \"id\": \"Determine IP of this build worker\"\n }\n ]\n }\n\n3. Use the build config file to start the [build manually](/build/docs/running-builds/start-build-manually)\n or [build using triggers](/build/docs/automating-builds/create-manage-triggers).\n\n| **Note:** Users can specify a working directory using the `dir` field in a build config file. Because your custom builder's users may specify any `dir` value, the builder should avoid hard-coding `/workspace` if possible. Instead, use the current working directory and relative paths.\n\nWhat's next\n-----------\n\n- Learn how to [run bash scripts in build steps](/build/docs/configuring-builds/run-bash-scripts).\n- Learn how to [configure build step order](/build/docs/configuring-builds/configure-build-step-order).\n- Learn how to [write a basic build config file](/build/docs/configuring-builds/create-basic-configuration)."]]