This topic describes how to build a DevOps environment based on containers in the Container Registry console.
Step 1: Create a repository
- If the account you used to log on to Container Registry has not activated Alibaba
Cloud Code, click Bind Account next to Alibaba Cloud Code on the Code Source page to activate Alibaba Cloud Code.
Note If your account has activated Alibaba Cloud Code, your projects on Alibaba Cloud Code are listed by default.
- You can create a repository based on the projects on Alibaba Cloud Code.
Note We recommend that you select Automatically build image in the Build Settings section. After you modify the code on Alibaba Cloud Code, an automatic build of the repository is triggered and the new image is pushed to Container Registry.
- Set the master branch of your project as the image tag latest.
Then, if you want to use this repository image, you can directly use registry.aliyuncs.com/**/dockertest, without specifying the tag as latest. The stable master branch is used by default to create the stable image tag latest.
Step 2: Build the repository
On the details page of the created repository, click Build to build the repository based on the two build rules added.
After you modify and commit the code in the test branch of your project on Alibaba Cloud Code, the repository is automatically built based on the second build rule to generate a new image tag.
Step 3: Bind a repository webhook
A repository webhook can subscribe to events upon the generation of new image tags.
We recommend that you use
http://requestb.in/ to generate a request URL and then bind it to the repository webhook. After a new
image is generated, you can view the webhook access record, including the request
time, request parameters, and request result. The request parameters provide information
about the current repository.
Step 4: Bind a webhook for Container Service
- Select the target cluster and click the name of the created application to enter the application details page.
- Click Create Trigger to create a redeployment webhook, and copy the webhook URL.
- Return to the image information page and click Add Rule. In the dialog box that appears,
enter the webhook URL.
After you modify the code on Alibaba Cloud Code, an image is automatically built, and Container Service is triggered to automatically redeploy the image for the relevant application.