Building an Image and Pushing It to SWR
CodeArts Build provides many default build actions and templates. If necessary dependency packages and tools are missing, you can create an image from a Dockerfile and push it to the specified repository in SWR.
This document uses Maven build as an example.
Prerequisites
- You have in SWR. For details about organization restrictions, see of SWR.
- You have created a code repository by using system template "Java Maven Demo". For details, see . Alternatively, a third-party code repository is available.
- You have customized a build environment and uploaded the Dockerfile and other files required for image creation to the root directory of the code repository.
Graphical Build
Add Build Image and Push to SWR after Build with Maven, when configuring build actions.
In the Build with Maven action, retain default values of the parameters. In the Build Image and Push to SWR action, set the parameters as described in the following table.
| Parameter | Description |
|---|---|
| Action Name | Name of a build action. It can be customized. |
| Tool Version | Select the tool version. You can also use the default version. |
| Image Repository | By default, CodeArts Build provides the SWR repository address of each region. You do not need to change the address. NOTE: Images can be pushed to custom image repositories. |
| Authorized User | Current user. Ensure that you have the permissions to edit or manage all images in the organization. |
| Push Region | Select the target region of your push. The built image will be pushed to the SWR repository in this region. |
| Organization | Select the organization created in Prerequisites from the drop-down list. |
| Image Name | Name of the created image, which can be customized. |
| Image Tag | Specify the image tag, which can be customized. You can use Image name:Tag to uniquely specify an image. |
| Working Directory | The context path parameter in the docker build command is the relative path of the root directory of the CodeArts Repo repository. Context path: When Docker builds an image, the docker build command packs all contents in the path and sends them to the container engine to help build the image. |
| Dockerfile Path | Path of a Dockerfile. Set this parameter to a path relative to the working directory. For example, if the working directory is a root directory and the Dockerfile is in the root directory, set this parameter to ./Dockerfile. |
| Add Build Metadata to Image | Add the build information to the image. After the image is created, run the docker inspect command to view the image metadata. |
Code-based Build
1 2 3 4 5 6 7 8 9 10 11 12 | version: 2.0 # The value must be 2.0. steps: BUILD: - build_image: name: buildImage inputs: regions: ["x-x-x", "x-x-xxx"] organization: codeci_test image_name: demo image_tag: ${GIT_COMMIT} dockerfile_path: dockerfile/Dockerfile # set_meta_data: true |
| Parameter | Type | Description | Mandatory | Default Value |
|---|---|---|---|---|
| regions | List | Select the region of SWR where the image is to be uploaded to. By default, the image is uploaded to SWR in the region where the current task is located. | No | None |
| organization | String | The organization of SWR where the image is to be uploaded to. | Yes | None |
| image_name | String | Image name. | No | demo |
| image_tag | String | Image tag. | No | v1.1 |
| context_path | String | Docker context path. | No | . |
| dockerfile_path | String | Path of the dockerfile relative to context_path. | No | ./Dockerfile |
| set_meta_data | Bool | Whether to add build metadata to the image. | No | false |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot