Container image construction method, device, server and storage medium

By monitoring the changes in the source code block of the container image and generating pipeline configuration files, the problem of rebuilding all images in the existing technology is solved, and the mirror construction of only rebuilding the variable source code blocks is realized, saving time and cost.

CN114595032BActive Publication Date: 2025-05-02BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210195656.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-01
Publication Date
2025-05-02
Estimated Expiration
2042-03-01

AI Technical Summary

Technical Problem

In the prior art, modifying the source code corresponding to the container image requires reconstructing all images, resulting in high time cost.

Method used

By obtaining monitoring data of multiple source code blocks in the source code warehouse of the target container, it is determined whether the source code block changes, and a pipeline configuration file is generated when the change occurs, and only the changing source code blocks are mirrored and reconstructed.

Benefits of technology

Avoid rebuilding all images, saving time and cost, and only mirroring the modified source blocks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114595032B_ABST
    Figure CN114595032B_ABST
Patent Text Reader

Abstract

The present application relates to a method, device, server and storage medium for building a container image, wherein the method for building a container image includes: obtaining monitoring data for monitoring multiple source code blocks in a source code repository of a target container, wherein the monitoring data includes multiple events, and the events are used to characterize the processing of the source code blocks; judging whether the source code blocks have changed according to the multiple events; when it is judged that the source code blocks have changed, generating a pipeline configuration file according to the changed source code blocks, and reconstructing the image objects corresponding to the changed source code blocks based on the pipeline configuration file. Through the present application, the problem that the source code corresponding to the modified image needs to be rebuilt for all images, resulting in high time cost, is solved, and it is avoided to build an image once for each service of the same source code repository, so that only the image of the service with the modified source code is built, saving time cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data storage, and in particular to a method, device, server and storage medium for constructing a container image. Background Art

[0002] In the related technology, when Rancher, an open source production deployment container association platform, generates pipelines, it will first push the code to Rancher's source code repository (Code repository), and then package the source code into an image according to the file configuration corresponding to the pipeline configuration file (rancher.yaml) of the pipeline (Rancherpipel ine) that constructs the image. If there are multiple file configurations, multiple source codes will be packaged into images. If there are multiple services or image objects that need to be packaged in the source code, when modifying the source code corresponding to some services or image objects in the source code, after submitting the modified source code to the source code repository, Rancher will re-image all services or image objects when generating pipelines, resulting in repeated image construction and high time cost.

[0003] In the related art, modifying the source code corresponding to the image requires rebuilding all the images, which causes a high time cost. There is no effective solution yet. Summary of the invention

[0004] The present application provides a method, device, server and storage medium for building a container image, so as to at least solve the problem in the related art that modifying the source code corresponding to the image requires rebuilding all images, resulting in high time cost.

[0005] In a first aspect, the present application provides a method for building a container image, comprising: obtaining monitoring data for monitoring multiple source code blocks in a source code repository of a target container, wherein the monitoring data includes multiple events, and the events are used to characterize the processing of the source code blocks; judging whether the source code blocks have changed based on the multiple events; when it is judged that the source code blocks have changed, generating a pipeline configuration file based on the changed source code blocks, and reconstructing the image object corresponding to the changed source code blocks based on the pipeline configuration file.

[0006] In a second aspect, the present application provides a container image construction device, including:

[0007] An acquisition module, used to acquire monitoring data for monitoring a plurality of source code blocks in a source code repository of a target container, wherein the monitoring data includes a plurality of events, and the events are used to characterize processing of the source code blocks;

[0008] A judgment module, used for judging whether the source code block has changed according to the multiple events;

[0009] The processing module is used to generate a pipeline configuration file according to the changed source code block when it is determined that the source code block has changed, and reconstruct the mirror object corresponding to the changed source code block based on the pipeline configuration file.

[0010] In a third aspect, a server is provided, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0011] Memory, used to store computer programs;

[0012] The processor is used to implement the steps of the method for building a container image as described in any one of the embodiments of the first aspect when executing the program stored in the memory.

[0013] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for building a container image as described in any embodiment of the first aspect are implemented.

[0014] Compared with the related art, the container image construction method, device, server and storage medium provided in this embodiment obtain monitoring data for monitoring multiple source code blocks in the source code repository of the target container, wherein the monitoring data includes multiple events, and the events are used to characterize the processing of the source code blocks; according to the multiple events, it is judged whether the source code block has changed; when it is judged that the source code block has changed, a pipeline configuration file is generated according to the changed source code block, and based on the pipeline configuration file, the image object corresponding to the changed source code block is reconstructed, which solves the problem that the source code corresponding to the modified image needs to be rebuilt for all images, resulting in high time cost, avoids building an image once for each service of the same source code repository, and realizes the construction of the image only for the service with modified source code, saving time cost.

[0015] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0018] Figure 1 A schematic diagram of a process for building a container image provided in an embodiment of the present application;

[0019] Figure 2 A schematic diagram of a container image building process provided in a preferred embodiment of the present application;

[0020] Figure 3 It is a structural block diagram of a container image construction device according to an embodiment of the present application;

[0021] Figure 4 It is a schematic diagram of the server structure of an embodiment of the present application. DETAILED DESCRIPTION

[0022] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0023] First, the relevant terms and prior art involved in the embodiments of the present application are explained as follows:

[0024] Rancher is an open source production deployment container management platform. Rancher is a container cluster orchestration tool based on

[0025] Docker (application container engine) comes with its own graphical user interface (GUI), which is particularly prominent in terms of ease of deployment and use; Rancher provides a package of infrastructure services for containers: network services, storage services, host management, load balancing, and firewalls that are compatible with the standard interface CNI (Container Network Interface); Rancher allows the above services to run across public clouds, private clouds, virtual machines, and physical machine environments, truly realizing one-click application deployment and management.

[0026] Git is an open source distributed version control system that can effectively and quickly handle version management of projects ranging from very small to very large.

[0027] Rancher pipeline, a pipeline for building images.

[0028] Code repository, source code repository.

[0029] DockerFile, the configuration file for building the image.

[0030] Rancher yaml, pipeline configuration file.

[0031] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0032] Figure 1 A flowchart of a method for building a container image provided in an embodiment of the present application is shown below. Figure 1 As shown, the embodiment of the present application provides a method for building a container image, which includes the following steps:

[0033] Step S101, obtaining monitoring data for monitoring a plurality of source code blocks in a source code repository of a target container, wherein the monitoring data includes a plurality of events, and the events are used to characterize processing of the source code blocks.

[0034] In this embodiment, the target container includes but is not limited to the container corresponding to the Kubernetes cluster that is orchestrated and deployed using Rancher.

[0035] In this embodiment, the subject of the method for executing the embodiment of the present application may be Rancher. According to the configuration of the Rancher pipeline, there will be a Rancher configuration for each source code repository. Based on the configuration, Rancher will trigger the pipeline steps. In this embodiment, the source code blocks in the source code repository include but are not limited to at least one of the following corresponding source code blocks: service, configuration, SDK, and an event listener event is added, and multiple source code blocks in the source code repository of the target container are monitored through GIT to obtain monitoring data including multiple events, and through events that characterize the processing of the source code blocks, the changed code blocks are obtained, that is, when there is a corresponding event, it can be determined that the corresponding source code block or the corresponding source code in the source code block has been modified, and the judgment and generation of related events can adopt existing technologies, which are not limited in this application.

[0036] Step S102, judging whether the source code block has changed according to multiple events.

[0037] In this embodiment, the event obtained by the event listener event is used to determine whether the source code block has changed based on the information corresponding to the event. For example, when the event indicates that the source code block has been processed, that is, it indicates that the corresponding event has occurred, Rancher can determine whether the source code block has changed based on the event, and thus obtain the changed source code block.

[0038] Step S103, when it is determined that a source code block has changed, a pipeline configuration file is generated according to the changed source code block, and based on the pipeline configuration file, the mirror object corresponding to the changed source code block is reconstructed.

[0039] In this embodiment, when Rancher determines that a source code block has changed based on an event, it will generate a pipeline configuration file based on the acquired changed source code block. Thereafter, the pipeline configuration file Rancher yaml will be read before building the image through Rancher to generate the pipeline steps.

[0040] In this embodiment, the change of a source code block may be that part of the source code is modified or all of the source code is modified. Since a source code block includes source codes corresponding to multiple services or mirror objects, in this embodiment, when the source code corresponding to a service or mirror object in the source code block changes, all services or mirror objects corresponding to the source code block will be mirrored and reconstructed. In this way, although some services or mirror objects are repeatedly built, the occurrence of building an image for each service or mirror object in the source code repository is avoided. In this embodiment, the source code change corresponding to a single service is equivalent to a change in a source code block, but all source code blocks in the source code repository are not recognized as changed.

[0041] Through the above steps S101 to S103, monitoring data for monitoring multiple source code blocks in the source code repository of the target container is obtained, wherein the monitoring data includes multiple events, and the events are used to characterize the processing of the source code blocks; according to the multiple events, it is determined whether the source code blocks have changed; when it is determined that the source code blocks have changed, a pipeline configuration file is generated according to the changed source code blocks, and based on the pipeline configuration file, the image objects corresponding to the changed source code blocks are reconstructed, which solves the problem that all images need to be rebuilt to modify the source code corresponding to the image, resulting in high time cost, avoids building an image once for each service of the same source code repository, and only builds images for services that modify the source code, saving time cost.

[0042] Figure 2 A schematic diagram of a container image building process provided by a preferred embodiment of the present application. Figure 2As shown, the preferred image construction in the embodiment of the present application is described as follows: a source code repository is set to contain service-1, service-2, service-3 (hereinafter referred to as s1, s2, s3, service-1, service-2, service-3 corresponds to a source code block), util-1, util-2, util-3 (hereinafter referred to as u1, u2, u3, util-1, util-2, util-3 corresponds to a source code block), sdk-1, sdk-2, sdk-3 (sdk-1, sdk-2, sdk-3 corresponds to a source code block), when the source code corresponding to s2, s3, u1, sdk-2 is modified, the changed source code block is obtained through git, and then the Rancher yaml file is dynamically generated according to the source code block of the modified part of the code, and the Rancher yaml file is read before the image is built through Rancher, thereby generating the pipeline steps. In this way, it is possible to avoid building an image for each service of the same source code repository.

[0043] In some embodiments, generating a pipeline configuration file according to the changed source code block further includes the following steps:

[0044] Step 21: Obtain a mirror configuration file corresponding to the changed source code block, wherein the mirror configuration file is used to guide the corresponding source code block to construct a corresponding mirror object.

[0045] In this embodiment, after each source code block generates the Rancher yaml file and generates the pipeline steps, when building the image, the image will be built according to the relevant information in the set image configuration file. For example, for the source code corresponding to the relevant service, the image is built according to the configuration information and / or processing process in the image configuration file. Before and after the image reconstruction, the configuration corresponding to the set image configuration file is fixed, that is, the image for image reconstruction is also the image construction completed according to the configuration of the previously generated image.

[0046] Step 22: Determine, among the multiple historical image objects of the generated pipeline, the target image object corresponding to the changed source code block according to the corresponding image configuration file.

[0047] In this embodiment, the target image object corresponding to the changed source code block is determined to determine the position of the image that needs to be rebuilt. In this embodiment, the image configuration file corresponding to the changed source code block is matched with the image configuration file corresponding to the historical image object. When they match, it means that the changed source code block corresponds to the historical image object, that is, the historical image object is rebuilt. At the same time, the pipeline configuration file is determined according to the position corresponding to the historical image to indicate the image configuration file used when building the image for the changed source code block.

[0048] Step 23: Generate a pipeline configuration file based on the configuration position information corresponding to the changed source code block and the target image object in the pipeline.

[0049] In this embodiment, when rebuilding the image, it is necessary to do so based on the source code and the image configuration file. Therefore, the pipeline configuration file needs to include the two parameters. Thus, after Rancher obtains the pipeline configuration file, it can obtain the source code block that sends the changes and the image configuration file based on which the image is built. In this embodiment, the generated pipeline configuration file carries the location information of the image configuration file used by the source code block that needs to be rebuilt and the corresponding source code block. When the image is rebuilt, the corresponding source code block is first obtained from the pipeline configuration file, and then the image configuration file corresponding to the historical image object at the configuration location information is obtained, thereby obtaining all the data for image building.

[0050] The mirror configuration file corresponding to the changed source code block is obtained through the above steps 21 to 23, wherein the mirror configuration file is used to guide the corresponding source code block to construct the corresponding mirror object; among the multiple historical mirror objects of the generated pipeline, the target mirror object corresponding to the changed source code block is determined according to the corresponding mirror configuration file; based on the corresponding configuration position information of the changed source code block and the target mirror object in the pipeline, the pipeline configuration file is generated, thereby realizing the dynamic generation of the pipeline configuration file according to the changed source code block.

[0051] In some of the embodiments, in order to reconstruct the image of the service with modified source code, the image object corresponding to the changed source code block is reconstructed based on the pipeline configuration file, further comprising the following steps:

[0052] Step 31: Get the configuration location information from the pipeline configuration file.

[0053] Step 32: Obtain the image configuration file corresponding to the historical image object corresponding to the configuration location information.

[0054] Step 33: Rebuild the corresponding image object based on the configuration corresponding to the image configuration file and the changed source code block.

[0055] In this embodiment, the generated pipeline configuration file carries the configuration location information of the mirror configuration file used by the source code block that needs to be rebuilt and the corresponding source code block. When the image is rebuilt, the corresponding source code block is first obtained from the pipeline configuration file, and then the mirror configuration file corresponding to the historical image object at the location information is obtained, and the source code of the corresponding source code block is rebuilt according to the configuration and / or processing process of the mirror configuration file.

[0056] Through the above steps 31 to 33, the configuration location information is obtained from the pipeline configuration file; the image configuration file corresponding to the historical image object corresponding to the configuration location information is obtained; based on the configuration corresponding to the image configuration file and the changed source code block, the corresponding image object is rebuilt, thereby realizing the reconstruction of the image object.

[0057] In some of the embodiments, to determine whether a source code block has changed, the following steps are further performed:

[0058] Step 41: Based on the event corresponding to each source code block among the multiple events, determine whether to modify each source code block.

[0059] In this embodiment, when there is a corresponding event, it indicates that the source code block has been modified. That is, in this embodiment, only the judgment of whether an event occurs is performed. How the event is generated can adopt corresponding means in related technologies or existing technologies.

[0060] Step 42: When it is determined that the source code block is modified, it is determined that the source code block is changed.

[0061] Through the above steps 41 to 42, based on the events corresponding to each source code block in the multiple events, it is determined whether each source code block is modified; when it is determined that the source code block is modified, it is determined that the source code block has changed, thereby realizing monitoring and determination of the changed source code block.

[0062] In some embodiments, the source code block includes a plurality of first source codes, and judging whether to modify each source code block based on an event corresponding to each source code block among the plurality of events may further include the following steps:

[0063] Step 51: Obtain all sub-events of the event corresponding to the source code block, and determine the sub-event corresponding to each first source code.

[0064] In this embodiment, each source code block corresponds to multiple first source codes. When detecting whether each source code block has changed, each first source code will be detected in turn, and correspondingly, multiple sub-events will be generated. When there is a corresponding sub-event, it indicates that the corresponding first source code has changed, that is, it has been modified.

[0065] Step 52: Based on each sub-event, determine whether the corresponding first source code is modified.

[0066] In this embodiment, when there is a corresponding sub-event, it indicates that the first source code block has been modified. That is, in this embodiment, only the judgment of whether a sub-event occurs is performed. How the sub-event is generated can adopt corresponding means in related technologies or existing technologies.

[0067] Step 53: When it is determined that at least one first source code has been modified, determine that the source code block has been modified.

[0068] In this embodiment, the change of the first source code corresponding to a single service is equivalent to the change of a source code block. Therefore, when it is determined that as long as there is a first source code that has been modified, all services of the source code block will be mirrored during the image construction.

[0069] Through the above steps 51 to 53, all sub-events of the event corresponding to the source code block are obtained, and the sub-event corresponding to each first source code is determined; based on each sub-event, it is determined whether the corresponding first source code is modified; when it is determined that at least one first source code is modified, it is determined that the source code block is modified, thereby realizing the judgment of whether the corresponding source code block is changed based on the partially modified source code.

[0070] In this embodiment, a device for building a container image is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and will not be repeated hereafter. The terms "module", "unit", "subunit", etc. used below can implement a combination of software and / or hardware of predetermined functions. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0071] Figure 3 is a structural block diagram of a container image construction device according to an embodiment of the present application, such as Figure 3 As shown, the device comprises:

[0072] An acquisition module 31 is used to acquire monitoring data for monitoring a plurality of source code blocks in a source code repository of a target container, wherein the monitoring data includes a plurality of events, and the events are used to characterize processing of the source code blocks;

[0073] The judging module 32 is coupled to the obtaining module 31 and is used to judge whether a source code block has changed according to a plurality of events;

[0074] The processing module 33 is coupled to the judging module 32 and is used to generate a pipeline configuration file according to the changed source code block when it is judged that the source code block has changed, and reconstruct the mirror object corresponding to the changed source code block based on the pipeline configuration file.

[0075] Through the access control device of the embodiment of the present application, monitoring data for monitoring multiple source code blocks in the source code repository of the target container is obtained, wherein the monitoring data includes multiple events, and the events are used to characterize the processing of the source code blocks; based on the multiple events, it is determined whether the source code block has changed; when it is determined that the source code block has changed, a pipeline configuration file is generated according to the changed source code block, and based on the pipeline configuration file, the image object corresponding to the changed source code block is reconstructed, which solves the problem that all images need to be rebuilt to modify the source code corresponding to the image, resulting in high time cost, avoids building an image once for each service of the same source code repository, and only builds an image for the service that modifies the source code, saving time cost.

[0076] In some embodiments, the processing module 33 may further include:

[0077] The first acquisition unit is used to acquire a mirror configuration file corresponding to a changed source code block, wherein the mirror configuration file is used to guide the corresponding source code block to construct a corresponding mirror object.

[0078] The first determining unit is coupled to the first acquiring unit and is used to determine, among the multiple historical image objects of the generated pipeline, a target image object corresponding to the changed source code block according to the corresponding image configuration file.

[0079] The first generating unit is coupled to the first determining unit and is used to generate a pipeline configuration file based on the configuration position information corresponding to the changed source code block and the target image object in the pipeline.

[0080] In some embodiments, the processing module 33 may further include:

[0081] A second acquisition unit is used to acquire configuration location information from a pipeline configuration file;

[0082] A third acquisition unit is coupled to the second acquisition unit and is used to acquire an image configuration file corresponding to the historical image object corresponding to the configuration location information;

[0083] The reconstruction unit is coupled to the third acquisition unit and is used to reconstruct the corresponding image object based on the configuration corresponding to the image configuration file and the changed source code block.

[0084] In some of the embodiments, the judgment module 32 is also used to determine that the first TGT gateway is connected to the distributed coordination service module when the first detection result indicates that there is a first TGT gateway in the distributed coordination service module, wherein the first connection state includes the first TGT gateway being connected to the distributed coordination service module; or is used to determine that the first TGT gateway is connected to the distributed coordination service module when it is re-checked that there is a first TGT gateway in the distributed coordination service module.

[0085] In some of the embodiments, if the first TGT gateway is not rechecked in the distributed coordination service module or the first TGT gateway is found not to exist in the distributed coordination service module, the container image construction device is also used to exit the first TGT gateway from the distributed coordination service module.

[0086] In some embodiments, the determination module 32 further includes:

[0087] A first judgment unit, configured to judge whether to modify each source code block based on an event corresponding to each source code block among the multiple events;

[0088] The second determining unit is coupled to the first judging unit, and is used to determine that the source code block has been changed when it is determined that the source code block has been modified.

[0089] In some of the embodiments, the source code block includes multiple first source codes, and the first judgment unit is further used to obtain all sub-events of the event corresponding to the source code block, and determine the sub-event corresponding to each first source code; based on each sub-event, determine whether the corresponding first source code is modified; when it is determined that at least one first source code is modified, determine that the source code block is modified.

[0090] Figure 4 Schematic diagram of the server structure of the embodiment of the present application. Figure 4 As shown, an embodiment of the present application provides a server, including a processor 41, a communication interface 42, a memory 43 and a communication bus 44, wherein the processor 41, the communication interface 42, and the memory 43 communicate with each other through the communication bus 44.

[0091] A memory 43, for storing computer programs;

[0092] The processor 41 is used to execute the program stored in the memory 43 to achieve Figure 1 The method steps in .

[0093] The processing implementation in the distributed coordination server Figure 1 The method steps in the embodiment have the same technical effects as those of the above embodiment. Figure 1 The technical effect of the container image construction method in is the same, so it will not be repeated here.

[0094] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0095] The communication interface is used for communication between the above terminal and other devices.

[0096] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0097] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0098] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the method for building a container image provided in any of the aforementioned method embodiments are implemented.

[0099] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the method for building a container image described in any of the above embodiments.

[0100] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0101] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for building a container image, characterized in that: include: Acquire monitoring data for monitoring a plurality of source code blocks in a source code repository of a target container, wherein the monitoring data includes a plurality of events, and the events are used to characterize processing of the source code blocks; Determining whether the source code block has changed according to the plurality of events; When it is determined that the source code block has changed, a pipeline configuration file is generated according to the changed source code block, and based on the pipeline configuration file, the mirror object corresponding to the changed source code block is reconstructed; Among them, generating a pipeline configuration file according to the changed source code block includes: obtaining a mirror configuration file corresponding to the changed source code block, wherein the mirror configuration file is used to guide the corresponding source code block to build a corresponding mirror object; among multiple historical mirror objects of the generated pipeline, determining a target mirror object corresponding to the changed source code block according to the corresponding mirror configuration file; generating the pipeline configuration file based on the configuration position information corresponding to the changed source code block and the target mirror object in the pipeline.

2. The method according to claim 1, characterized in that Reconstructing the image object corresponding to the changed source code block based on the pipeline configuration file, including: Obtaining the configuration location information from the pipeline configuration file; Obtain the image configuration file corresponding to the historical image object corresponding to the configuration location information; Based on the configuration corresponding to the mirror configuration file and the changed source code block, the corresponding mirror object is rebuilt.

3. The method according to claim 1, characterized in that Determining whether the source code block has changed according to the multiple events includes: Based on the event corresponding to each of the source code blocks among the multiple events, determining whether to modify each of the source code blocks; When it is determined that the source code block is modified, it is determined that the source code block is changed.

4. The method according to claim 3, characterized in that The source code block includes a plurality of first source codes, and judging whether to modify each of the source code blocks based on the event corresponding to each of the source code blocks among the plurality of events includes: Acquire all sub-events of the event corresponding to the source code block, and determine the sub-event corresponding to each of the first source codes; Based on each of the sub-events, determining whether the corresponding first source code is modified; When it is determined that at least one of the first source codes has been modified, it is determined that the source code block has been modified.

5. The method according to claim 1, characterized in that: The changed source code block is obtained through a preset distributed version control system GIT.

6. The method according to claim 1, characterized in that The source code block includes a source code block corresponding to at least one of the following: service, configuration, SDK.

7. A container image construction device, characterized in that: include: An acquisition module, used to acquire monitoring data for monitoring a plurality of source code blocks in a source code repository of a target container, wherein the monitoring data includes a plurality of events, and the events are used to characterize processing of the source code blocks; A judging module, used for judging whether the source code block has changed according to the plurality of events; A processing module, configured to generate a pipeline configuration file according to the changed source code block when it is determined that the source code block has changed, and reconstruct the mirror object corresponding to the changed source code block based on the pipeline configuration file; Wherein, the processing module includes: A first acquisition unit is used to acquire a mirror configuration file corresponding to a changed source code block, wherein the mirror configuration file is used to guide the corresponding source code block to construct a corresponding mirror object; A first determining unit is coupled to the first acquiring unit and is used to determine, among the multiple historical image objects of the generated pipeline, a target image object corresponding to the changed source code block according to the corresponding image configuration file; The first generating unit is coupled to the first determining unit and is used to generate a pipeline configuration file based on the configuration position information corresponding to the changed source code block and the target image object in the pipeline.

8. A server, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, configured to implement the steps of the method for building a container image according to any one of claims 1 to 6 when executing a program stored in a memory.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for building a container image according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Method, system and device for automatically deploying project to public cloud containerization platform

    CN112162761A