Configura le immagini di compilazione ed esecuzione
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Buildpack utilizza un builder predefinito, costituito da tutti i componenti necessari per eseguire una compilazione del servizio, incluse un'immagine di compilazione e di esecuzione:
Immagine di compilazione: utilizzata dall'immagine del generatore per creare l'ambiente di compilazione
in cui viene eseguito il ciclo di vita
del buildpack. È qui che la tua applicazione o funzione viene preparata per la contenimento.
Esegui immagine: l'immagine di base da cui viene creata l'immagine container del servizio. Si tratta dell'immagine che ospita l'applicazione o la funzione creata.
Entrambe le immagini possono essere personalizzate ed estese in base alle tue esigenze. Ad esempio, puoi personalizzare le immagini per aggiungere i pacchetti necessari per la compilazione del servizio o per installare i pacchetti di sistema in modo che siano disponibili quando il servizio viene eseguito.
Prima di iniziare
Utilizza l'interfaccia a riga di comando pack per creare localmente il servizio in un'immagine container.
Prima di iniziare
Installa Docker Community Edition (CE)
sulla tua workstation. Docker viene utilizzato da pack come generatore di immagini OCI.
Personalizzare le immagini di compilazione ed esecuzione
I buildpack utilizzano un'immagine del generatore per creare il servizio in un'immagine container. Al termine del processo di compilazione, l'applicazione o la funzione viene inserita in un'immagine di esecuzione. Scopri di più sulla procedura di compilazione
in Concetti di Buildpack.
Estensione dell'immagine del builder
Per personalizzare l'immagine del generatore predefinita:
Crea un builder.Dockerfile personalizzato dall'immagine del generatore predefinita. Devi
specificare il tag per la
versione del builder che supporta l'immagine di base. Ad esempio, il tag immagine base :v1 non è supportato dal tag del generatore :google-22.
Sostituisci BUILDER_IMAGE_NAME con il nome scelto per l'immagine del generatore personalizzato.
Esegui il pack build
comando
con l'immagine del generatore personalizzato per creare la nuova immagine del container della tua
applicazione o funzione:
SERVICE_IMAGE_NAME con il nome che hai scelto per l'immagine dell'applicazione o della funzione.
BUILDER_IMAGE_NAME con il nome dell'immagine del generatore personalizzato.
Estensione dell'immagine di esecuzione
Per personalizzare l'immagine del container di esecuzione predefinita:
Crea un run.Dockerfile personalizzato dall'immagine di esecuzione predefinita. Devi
specificare il tag per la
versione del builder che supporta l'immagine di esecuzione. Ad esempio, il tag immagine di esecuzione :v1 non è supportato dal tag del generatore :google-22.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eBuildpacks utilize a builder image, consisting of both a build image for creating the build environment and a run image that hosts the built application or function.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003epack\u003c/code\u003e CLI tool is used to build a service into a container image locally, requiring Docker, Pack CLI, and Git to be installed beforehand.\u003c/p\u003e\n"],["\u003cp\u003eBuilder images can be customized by creating a \u003ccode\u003ebuilder.Dockerfile\u003c/code\u003e and using \u003ccode\u003edocker build\u003c/code\u003e to add necessary packages or components to the building process, and then can be used via \u003ccode\u003epack build\u003c/code\u003e to build a service.\u003c/p\u003e\n"],["\u003cp\u003eRun images can also be customized by creating a \u003ccode\u003erun.Dockerfile\u003c/code\u003e, using \u003ccode\u003edocker build\u003c/code\u003e to add necessary system packages or components, and then using \u003ccode\u003epack build\u003c/code\u003e with the \u003ccode\u003e--run-image\u003c/code\u003e flag to build a service using the customized image.\u003c/p\u003e\n"]]],[],null,["# Configure your build and run images\n\nBuildpacks uses a default\n[builder](https://buildpacks.io/docs/for-platform-operators/concepts/builder/),\nwhich consists of all the components necessary to execute a build of your\nservice including both a *build* and *run* image:\n\n- **Build image** : Used by the builder image to create the build environment where the buildpacks [lifecycle](https://buildpacks.io/docs/for-platform-operators/concepts/lifecycle/) is executed. This is where your application or function is prepared for containerization.\n- **Run image**: The base image from which the container image of your service is built. This is the image that hosts your built application or function.\n\nBoth images can be customized and extended to suit your needs. For example, you\ncan customize images to add the packages that are required for building your\nservice, or to install system packages so they are available when your\nservice runs.\n\nBefore you begin\n----------------\n\nYou use the `pack` CLI to locally build your service into a container image.\n\n### Before you begin\n\n1. Install [Docker Community Edition (CE)](https://docs.docker.com/engine/installation/) on your workstation. Docker is used by `pack` as an OCI image builder.\n2. Install [Pack CLI](https://buildpacks.io/docs/tools/pack/).\n3. Install the [Git source control](https://git-scm.com/downloads) tool to fetch the sample application from GitHub.\n\nCustomize the build and run images\n----------------------------------\n\nBuildpacks use a builder image to construct your service into a\ncontainer image. When the build process is complete, your application or\nfunction is inserted into a run image. Learn more about the build process\nat [Buildpacks Concepts](https://buildpacks.io/docs/for-platform-operators/concepts/).\n\n### Extending the builder image\n\nTo customize the default builder image:\n\n1. Create a custom `builder.Dockerfile` from the default builder image. You\n must specify the tag for the\n [version of the builder](/docs/buildpacks/builders) that supports your base\n image. For example, the `:v1` base image tag is unsupported by the\n `:google-22` builder tag.\n\n Example: \n\n FROM gcr.io/buildpacks/builder\n USER root\n RUN apt-get update && apt-get install -y --no-install-recommends \\\n subversion && \\\n apt-get clean && \\\n rm -rf /var/lib/apt/lists/*\n USER cnb\n\n2. Build your custom builder image from the `builder.Dockerfile` file:\n\n docker build -t \u003cvar translate=\"no\"\u003eBUILDER_IMAGE_NAME\u003c/var\u003e -f builder.Dockerfile .\n\n Replace `BUILDER_IMAGE_NAME` with the name that you choose for your custom\n builder image.\n3. Run the [`pack build`\n command](https://buildpacks.io/docs/tools/pack/cli/pack_build/)\n with your custom builder image to build the new container image of your\n application or function:\n\n pack build \u003cvar translate=\"no\"\u003eSERVICE_IMAGE_NAME\u003c/var\u003e --builder \u003cvar translate=\"no\"\u003eBUILDER_IMAGE_NAME\u003c/var\u003e\n\n Replace:\n - `SERVICE_IMAGE_NAME` with the name that you choose for your application or function image.\n - `BUILDER_IMAGE_NAME` with the name of your custom builder image.\n\n### Extending the run image\n\nTo customize the default run container image:\n\n1. Create a custom `run.Dockerfile` from the default run image. You\n must specify the tag for the\n [version of the builder](/docs/buildpacks/builders) that supports your run\n image. For example, the `:v1` run image tag is unsupported by the\n `:google-22` builder tag.\n\n Example: \n\n FROM gcr.io/buildpacks/gcp/run\n USER root\n RUN apt-get update && apt-get install -y --no-install-recommends \\\n imagemagick && \\\n apt-get clean && \\\n rm -rf /var/lib/apt/lists/*\n USER 33:33\n\n2. Build your custom run image from the `run.Dockerfile` file:\n\n docker build -t \u003cvar translate=\"no\"\u003eRUN_IMAGE_NAME\u003c/var\u003e -f run.Dockerfile .\n\n Replace `RUN_IMAGE_NAME` with the name that you choose for your custom run\n image.\n3. Run the [`pack build`\n command](https://buildpacks.io/docs/tools/pack/cli/pack_build/)\n with your custom run image to build the new container image of your\n application or function:\n\n pack build \u003cvar translate=\"no\"\u003eSERVICE_IMAGE_NAME\u003c/var\u003e --builder gcr.io/buildpacks/builder:v1 --run-image \u003cvar translate=\"no\"\u003eRUN_IMAGE\u003c/var\u003e\n\n Replace:\n - `SERVICE_IMAGE_NAME` with the name that you choose for your application or function image.\n - `RUN_IMAGE_NAME` with the name of your custom run image."]]