Create a build configuration that pulls source from a local directory
If your source is on your local workstation, create a build configuration with settings that include information about where to pull source from the local directory. For the build output, you can specify registry details, or let Code Engine manage IBM Cloud Container Registry details.
You can create a build configuration that pulls source from a local directory by using only the Code Engine CLI.
When you submit a build that pulls code from a local directory, your source code is packed into an archive file and uploaded to your IBM Cloud Container Registry instance. Note that you can only target IBM Cloud Container Registry for your local builds. The source image is created in the same namespace as your build image.
You can ignore certain file patterns from within your source code by using the .ceignore
file, which behaves similarly to a .gitignore
file. For example, entries for a .ceignore
file for a Node.js application
might include node_modules
and .npm
. For more sample file patterns to ignore, see the GitHub .gitignore repository.
Creating a build configuration does not create an image, but creates the configuration to build an image. You must then run a build that references the build configuration to create an image. The build configuration is not validated or used to create an image until the build is run. The build configuration enables multiple subsequent builds of an image, such as when changes are applied to the source repository.
To create a build configuration that pulls code from a local directory with the CLI, use the build create
command and specify the build-type
as local
. For a complete listing of options, see
the ibmcloud ce build create
command.
With the build create
command, you can have Code Engine build the image from your source and store the image in IBM Cloud Container Registry. For this automatic access case, you do not need to specify a registry
secret or the location of the image registry. Or, you can specify the location for your build image output and provide a registry secret so that Code Engine can access and push the build result to your registry.
Creating a build configuration with the CLI (with local source and automatic access to registry)
In this scenario, Code Engine builds an image from your local source, and automatically uploads the image to IBM Cloud Container Registry. See Setting up authorities for image registries for more information about setting required permissions for Code Engine to automatically access these images in Container Registry.
Before you begin
Create a build configuration to build an image from source on your local workstation and let Code Engine automatically store and access the image. When you specify local
as the value for -build-type
, you can only target
IBM Cloud Container Registry for the output of your local build. In this example, the command uses the default dockerfile
strategy, and the default medium
build size. By not specifying the location of the image registry
or a registry secret, Code Engine pushes the build output to IBM Cloud Container Registry with automatic access.
ibmcloud ce build create --name build-local-dockerfile --build-type local
After you create the build configuration, you must run the build to create the image file. After your image file is created, you can deploy an app or run a job with your newly built image file.
Creating a build configuration with the CLI (with local source and user-provided access to registry)
In this scenario, Code Engine builds an image from your local source, and then uploads the image to your container registry with the registry access that you provide.
Before you begin
- Set up your Code Engine CLI environment.
- Create and work with a project.
- Create a registry secret so you can save your image.
Create a build configuration to build an image from source on your local workstation and specify the location of the image registry for the build output with a registry secret. With the build create
command, when
you specify local
as the value for --build-type
, you can only target IBM Cloud Container Registry for the output of your local build. Specify the --image
option to provide the location of the image registry,
and specify the --registry-secret
option to access the registry. In this example, the command uses the default dockerfile
strategy, and the default medium
build size.
ibmcloud ce build create --name build-local-dockerfile --build-type local --image us.icr.io/mynamespace/codeengine-build --registry-secret myregistry
After you create the build configuration, you must run the build to create the image file. After your image file is created, you can deploy an app or run a job with your newly built image file.