Mirror image file construction method and device, equipment, storage medium and program product
By adding version readme information during the image production process, the problem of lack of uniqueness of Docker images is solved, and the unique identification and verification value of the mirror file are realized, avoiding the confusion of multiple versions of the mirror tag.
Patent Information
- Application Number
- CN202411102510.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-11-01
AI Technical Summary
The Docker images built in the prior art lack uniqueness, resulting in confusion in multiple versions of the image tag and the inability to accurately identify version information.
During the mirror production process, the code information is obtained by obtaining the commands of the code management program, combined it into version readme information, and added it to the target location of the basic image file, dynamically modify the content of the image file, and generate the target image file to ensure that each time the construction is done The image file is unique.
Through the uniqueness of the version reader information, the verification value of the mirror media also changes, realizing the uniqueness identification of the mirror, avoiding the problem of confusion in multiple versions of the mirror tag.
Smart Images

Figure CN118885208A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, equipment, storage medium and program product for constructing an image file. Background Art
[0002] With the popularity of cloud-native development and deployment methods, Docker image production in the pipeline has become a common phenomenon; Docker image production is the process of packaging an application and its dependent libraries, file systems, and configurations into a portable image file.
[0003] In the prior art, in order to enable the image file to be run in any environment that supports Docker, and to enable the application to maintain consistency and portability in different development, testing and production environments, the developer needs to fill in the code compilation command and image path in the input box provided by the pipeline system, and declare the image name and image tag, and then build the image.
[0004] However, since the image tag can be assigned multiple values, the image constructed in the above way lacks uniqueness. Summary of the invention
[0005] The present application provides a method, device, equipment, storage medium and program product for constructing an image file, so as to solve the problem that the image constructed in the prior art lacks uniqueness.
[0006] In a first aspect, the present application provides a method for constructing an image file, the method comprising:
[0007] After executing the compile command, obtaining at least one code information for executing the current pipeline task through the command of the code management program;
[0008] Combining the at least one code information based on user requirements to obtain version self-description information; the version self-description information is used to identify metadata required to execute pipeline tasks in image files of different versions;
[0009] The target position in the base image file is found through a matching algorithm, and the version self-description information is added to the target position to obtain the target image file.
[0010] In a possible design, the code information includes: code repository information, code branch information, code submission information, and identification information of pipeline tasks; the at least one code information is combined based on user needs to obtain version self-description information, including:
[0011] determining target code information from the at least one code information based on user requirements;
[0012] The target code information and the time of executing the current pipeline task are combined to obtain version self-description information.
[0013] In a possible design, searching for the target location in the base image file by using a matching algorithm includes:
[0014] Identify keywords in the base image file through regular expressions;
[0015] The target location is determined based on the keyword; the keyword is used to specify the starting point location of the base image.
[0016] In a possible design, adding the version self-description information to the target location to obtain a target image file includes:
[0017] Add the version self-description information in the line where the target location is located and in the line below the line where the target location is located;
[0018] The version self-description information is set as an environment variable in the target image file to obtain the target image file.
[0019] In one possible design, the method further includes:
[0020] Packing the target image file to obtain a target image;
[0021] The image name and the image tag input by the user are obtained, and the target image is image-identified based on the image name and the image tag.
[0022] In one possible design, the method further includes:
[0023] Get the application scenario for executing the current pipeline task;
[0024] The version self-description information is determined from the code matching library based on the application scenario; the code matching library pre-stores the version self-description information corresponding to different application scenarios in advance, and updates the version self-description information obtained based on different user demand combinations.
[0025] In a second aspect, the present application provides an image file construction device, the device comprising:
[0026] An acquisition module, used to acquire at least one code information for executing a current pipeline task through a command of a code management program after executing a compile command;
[0027] A combination module, used to combine the at least one code information based on user requirements to obtain version self-description information; the version self-description information is used to identify metadata required to execute pipeline tasks in image files of different versions;
[0028] The search module is used to search for a target location in a basic image file through a matching algorithm, and add the version self-description information to the target location to obtain a target image file.
[0029] In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement the image file construction method described in the first aspect and various possible designs of the first aspect.
[0030] In a fourth aspect, the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the image file construction method described in the first aspect and various possible designs of the first aspect.
[0031] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the image file construction method described in the first aspect and various possible designs of the first aspect.
[0032] The image file construction method, device, equipment, storage medium and program product provided by the present application avoid the multi-version confusion problem of image tags by adding version self-description information to the content of the image file during the image production process. Specifically, after the execution of the pipeline compilation command is completed, the version self-description enhancement device is executed to dynamically modify the basic image file content of the pipeline task configuration, and the version self-description information composed of at least one code information is added to the target location to obtain the target image file, and then the image program packages the image based on the target image file. Since different version self-description information corresponds to each construction of the target image file, the version self-description information is unique. Furthermore, the image obtained by packaging based on the target image file, the check value of the image medium will also change accordingly. Therefore, there is a one-to-one correspondence between the version self-description information and the check value, and the image constructed in this way is unique. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0034] Figure 1 It is the display interface diagram of the existing input box;
[0035] Figure 2 A current status flow chart for specific pipeline task execution;
[0036] Figure 3 The invention concept diagram provided for the embodiment of the present application;
[0037] Figure 4 An application scenario diagram of a method for constructing an image file provided in an embodiment of the present application;
[0038] Figure 5 A schematic diagram of a process for constructing an image file provided in an embodiment of the present application;
[0039] Figure 6 A schematic diagram of the structure of a version self-description enhancement device provided in an embodiment of the present application;
[0040] Figure 7 An execution flow chart of the version self-description module provided in the embodiment of the present application;
[0041] Figure 8 An execution flow chart of the image file modification module provided in the embodiment of the present application;
[0042] Fig. 9 A schematic diagram of the structure of an image file construction device provided in an embodiment of the present application;
[0043] Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0044] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0045] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0046] In the technical solution of this application, the collection, storage, use, processing, transmission, provision and disclosure of information such as financial data or user data involved shall comply with the provisions of relevant laws and regulations and shall not violate public order and good morals.
[0047] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0048] Terminology explanation:
[0049] Code repository: refers to a code base that stores software code, similar to a centralized code base. Developers can perform version control, management, and collaboration based on the code repository to better develop and maintain software. The code repository usually includes a main branch and various code branches, which support developers to perform different operations to merge code into the main branch. In the compilation pipeline, since the compilation pipeline needs to obtain code from the code repository and perform operations such as compilation and testing, the code repository is an important database.
[0050] Code branch: refers to an independent development line in a code repository, where developers can make code changes and experiments without affecting the main branch; code branches are usually used to implement new features, fix bugs, or conduct experimental development, and developers can make multiple commits and tests on the code branch to merge the code back to the main branch. In software development, code branches can effectively collaborate and manage code development and maintenance.
[0051] Code submission record: refers to the code changes submitted by developers to the code repository, which can include operations such as addition, deletion, and modification. Each code submission record will be assigned a unique hash value (hash value) to identify the code submission record. The hash value can be calculated and generated by a hash algorithm to ensure that each code submission record is unique.
[0052] It should be noted that when multiple commits and tests are made on a code branch and the code is merged back to the main branch, the hash value of each code commit record will also be recorded in the commit history of the code repository, making it easier for developers to manage and backtrack code versions.
[0053] Image name: refers to the name used to identify the container image. A container image is a lightweight, portable software package that contains all the components required to run a container, including code, runtime, system tools, library files and other components. When using container technology, you need to specify the required container image to create and run a container instance based on the container image. Image names are usually named in the format of "warehouse name / image name: label" to facilitate users to quickly find the required image when needed. The embodiments of this application do not limit the specific format corresponding to the image name.
[0054] Image tag: refers to a string used to identify the version of a container image, usually included in the image name. Image tags can help developers quickly distinguish different versions of images in the same repository. For example, different image tags can be used to identify different software versions of images, different operating system versions, etc. When using container technology, users can select the required image version by specifying the image tag in the image name.
[0055] Dockerfile file: refers to the file for building a Docker container image. It is a text file that contains a series of commands and parameters for automatically building a Docker image. By writing a Dockerfile file, you can define the environment, configuration, application, and service information of the container. Specifically, you can use the Docker CLI command to build the Dockerfile file into a Docker image.
[0056] It is understandable that users can use Docker images to start containers on any platform that supports Docker, and the Dockerfile file built each time can be used to ensure the consistency and repeatability of the image.
[0057] In enterprise software development projects, continuous integration can be used for software development. Continuous integration is a software development process that helps developers detect and resolve code problems more quickly, thereby improving software quality and development efficiency; the working principle of continuous integration is to automatically integrate the code compiled by developers into a shared code library and automatically run tests every time the compiled code is submitted to ensure the quality and stability of the code. If there is a problem with the test, the developer can immediately receive feedback based on the terminal device, and then quickly modify and adjust the code to correct the code, thereby improving the quality and efficiency of software development.
[0058] Docker image creation refers to the process of packaging an application and its dependent libraries, file systems, and configurations into a portable image file. Specifically, the image creation process includes writing a basic Dockerfile file, defining the operating system, application, and dependent libraries required for the image, and then using Docker commands and tools to build, package, and publish the image file. Through Docker image creation, developers can more easily develop, test, and deploy applications, thereby improving the reliability and maintainability of applications; among them, the image version can be distinguished by marking the image name and image tag on the created image medium.
[0059] In one possible implementation, during the code development process, developers can perform continuous compilation through code compilation pipeline tasks. During the compilation process, a type of pipeline system will provide an input box for developers to fill in code compilation commands and image paths to build container images. The image name and image tag can be set by the developer himself, or the pipeline task manager can uniformly assign values to the image name and image tag to describe the image version.
[0060] For example, Figure 1 The display interface diagram of the existing input box is as follows: Figure 1 As shown, the display interface corresponding to the XX pipeline task includes options such as compilation command, image file path, image name and image tag. The display box after each option is a compilation command input box. Taking Dockerfile file construction as an example, the developer selects the code repository, code branch and other information, and enters the code compilation command or script and the Dockerfile path in the display interface. The Dockerfile path instructs the pipeline system to compile code and make images, and then the Dockerfile pipeline image production system builds the Dockerfile file. Among them, the developer can enter the custom image name and image tag provided additionally in the display interface.
[0061] Optional, Figure 2 The current status flow chart of the specific pipeline task execution is as follows: Figure 2 As shown, based on the code management program, the code of the pipeline task is obtained, and then the pipeline executes the compilation command. In response to the user's operation, the image program packages the image according to the basic image file, and marks the image with a version identifier according to the image name and image tag, so that the image can be uniquely identified.
[0062] However, when creating an image, the following problem may arise by assigning an image name and an image tag. After the image is created and the medium is copied to different environments, the image tag can be assigned multiple values, such as naming the image tag version V1 and version V2 at the same time. However, the checksum value corresponding to the image medium will not change, resulting in a one-to-one correspondence between the image tag and the checksum value, which can easily cause confusion and make it impossible to accurately identify the version information, making the image constructed in the above manner lack uniqueness.
[0063] In view of the above problems, the present application provides a method for building an image file, which can avoid the confusion of multiple versions of image tags by adding version self-description information to the content of the image file during the image production process. Figure 3 The invention concept diagram provided for the embodiment of this application is as follows: Figure 3 As shown, in Figure 2 On the basis of, after the execution of the pipeline compilation command is completed, the version self-description enhancement device is executed to dynamically modify the basic image file content of the pipeline task configuration, and the version self-description information composed of at least one code information is added to the target position to obtain the target image file, and then the image program packages the image based on the target image file. Since different version self-description information corresponds to each construction of the target image file, the version self-description information is unique. Furthermore, the image obtained by packaging based on the target image file, the check value of the image medium will also change. Therefore, there is a one-to-one correspondence between the version self-description information and the check value, and then the image constructed based on this method is unique.
[0064] Among them, Figure 3 As shown, the version self-description enhancement device can be added to the pipeline system in the form of a pipeline plug-in or an extension module, or can be added to the pipeline system in other forms to construct an image file, and the embodiments of the present application do not make specific limitations on this.
[0065] Optionally, after obtaining the image, you can also label the image according to the image name and image tag to identify different image versions, so that different versions of images can be clearly distinguished and managed in development, testing, and production environments.
[0066] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0067] For example, Figure 4 This is an application scenario diagram of an image file construction method provided in an embodiment of the present application. The application scenario can be applied in the software development process, such as Figure 4 As shown, the application scenario includes: a developer's terminal device 101 and a pipeline image production system 102. The terminal device 101 corresponds to a display device for displaying various interfaces in the code compilation process.
[0068] In response to the developer's compilation operation on the terminal device 101, the terminal device 101 can send a compilation command to the pipeline image production system 102. After the pipeline image production system 102 receives the compilation command and executes the compilation command, it can obtain at least one code information for executing the current pipeline task through the command of the code management program. Furthermore, based on the needs of the developer, the required code information is determined from the at least one code information and combined to obtain version self-description information, and then the version self-description information is written into the target image file. The target image generated based on the target image file does not perform version self-description based on the image name and image tag, thereby avoiding the problem of multi-version confusion of image tags.
[0069] It should be noted that the pipeline image production system 102 can also be deployed in the terminal device 101 and integrated as a part of the terminal device 101, so that the above-mentioned image file construction method can be executed based on the terminal device 101. The embodiment of the present application does not specifically limit the execution subject of the above-mentioned image file construction method.
[0070] For example, Figure 5 A flowchart of a method for constructing an image file provided in an embodiment of the present application is shown in FIG. Figure 5 As shown, the execution subject of the image file construction method can be the above-mentioned pipeline image production system or terminal device, and the embodiment of the present application does not specifically limit this. The method is implemented based on the version self-description enhancement device. Figure 6 A schematic diagram of the structure of the version self-description enhancement device provided in the embodiment of the present application, such as Figure 6 As shown, the version self-description enhancement device includes a version self-description module and an image file modification module, the version self-description module is used to generate version self-description information, and the image file modification module is used to dynamically modify the content of the image file based on the version self-description information; the image file construction method includes the following steps:
[0071] S501. After executing a compile command, obtain at least one code information for executing a current pipeline task through a command of a code management program.
[0072] In an embodiment of the present application, code information may include code repository information, code branch information, code submission information, identification information of the pipeline task, etc. The identification information of the pipeline task is the metadata of the pipeline task. The metadata refers to additional data that describes the structure, content, source, purpose and other information of the pipeline task. For example, the identification information of the pipeline task includes the name of the pipeline task, the pipeline executor and other information. The embodiment of the present application does not limit the specific content corresponding to the identification information of the pipeline task, which can be determined based on the application scenario.
[0073] Exemplarily, in a continuous integration / continuous deployment pipeline, after executing the compilation command, at least one code information for executing the current pipeline task is obtained through the command of the code management program. The code information can be extracted code information related to the current build image file, such as code engineering, code branches, code submission records, pipeline build time and other information. The embodiment of the present application does not specifically limit the content included in the code information.
[0074] It should be noted that the embodiments of the present application do not limit the specific content corresponding to the code repository information, code branch information, and code submission information. They can be set based on the application scenarios of software development or manually. For example, the code repository information includes the code project name, and the code branch information includes the code branch name, etc.
[0075] S502: Combining the at least one code information based on user requirements to obtain version self-description information; the version self-description information is used to identify metadata required to execute pipeline tasks in image files of different versions.
[0076] In an embodiment of the present application, the version self-description information is a document used to record and publish updated content, fixed errors, new functions, improved performance, and other important change information in each version of the image file during the software development process. It is used to identify the metadata required to execute pipeline tasks in different versions of image files. The metadata refers to auxiliary information for describing and managing pipeline tasks, such as code repositories, branch information, or submission hash values in image files.
[0077] It is understandable that the content that needs to be included in the version description information can be determined based on user needs. The user needs may include descriptions of new features of the code, bug fixes, performance improvements, known issues, and other important changes. The embodiments of the present application do not specifically limit user needs.
[0078] Optionally, S502 includes: determining target code information from the at least one code information based on user requirements;
[0079] The target code information and the time of executing the current pipeline task are combined to obtain version self-description information.
[0080] For example, Figure 7 The execution flow chart of the version self-description module provided in the embodiment of the present application is as follows: Figure 7As shown, in the version description module, the code information executed by the current pipeline task is obtained through the commands of the code management program, such as git / svn and other commands. The code information includes code repository information, code branch information, code submission information, pipeline task name, pipeline executor and other information. Further, according to user needs, the target code information is determined to have the code project name, code branch name, code submission record, and further, combined with the time of the current pipeline task, such as the pipeline build time, to combine the version description information.
[0081] It should be noted that the commands of the code management program in the embodiment of the present application are not specifically limited. The code management program can also be called a version control system (VCS). The commands and functions of the code management program are mainly determined by the specific version control system used, such as git, svn, hg and other commands.
[0082] In this way, the embodiment of the present application combines code information based on user needs to generate version self-description information. This automatic generation of version self-description information reduces the time and errors of manual compilation by developers, and does not require human participation. By automatically generating version self-description information, the accuracy and consistency of the information are ensured, and omissions or errors caused by human factors are avoided. Among them, the version self-description information includes the target code information and the time to execute the current pipeline task, so that the change record of each version is clearly visible, and the version self-description information can be seamlessly integrated into the pipeline, further improving the degree of automation of development and release.
[0083] S503 , searching for a target location in the base image file through a matching algorithm, and adding the version self-description information to the target location to obtain a target image file.
[0084] In the embodiment of the present application, the matching algorithm is used to search for a specific subset or keyword in the base image file. For example, the matching algorithm can be a string matching algorithm, a regular expression, a machine learning algorithm, etc. The embodiment of the present application does not limit the specific algorithm corresponding to the matching algorithm.
[0085] In this step, the target position in the base image file is found through a matching algorithm. The target position may be the position of a line or a string in the base image file. The embodiment of the present application does not limit the specific position corresponding to the target position. Furthermore, the version description information is added to the target position to obtain the target image file.
[0086] It should be noted that the specific position corresponding to the target position to which the self-description information of the embodiment of the present application is added is not limited. For example, the target position can be the next line of the line where the target position is located, the end or the first position of the line where the target position is located, etc.
[0087] Optionally, searching for the target location in the base image file by using a matching algorithm includes:
[0088] Identify keywords in the base image file through regular expressions;
[0089] The target location is determined based on the keyword; the keyword is used to specify the starting point location of the base image.
[0090] In the embodiments of the present application, a regular expression refers to a pattern of character combinations in a matching string. The syntax of a regular expression is basically the same in different platforms and programming languages. Using regular expressions for string matching has strong versatility and portability. Regular expressions support a variety of matching rules, such as greedy matching, lazy matching, etc., which can accurately control matching behavior to meet different matching requirements. Therefore, keywords in the base image file are identified through regular expressions, which improves the flexibility and versatility of matching.
[0091] Among them, the keyword is a pre-defined string, and the keyword is used to specify the starting point position of the base image. The embodiment of the present application does not limit the specific content of the keyword, which can be "From base image".
[0092] For example, Figure 8 The execution flow chart of the image file modification module provided in the embodiment of the present application is as follows: Figure 8 As shown, taking the Dockerfile file as the base image file as an example, in the image file modification module, the version readme information obtained by the version readme module is used to identify the position of the "From base image" line in the Dockerfile file through a regular expression, and the version readme information is added to the next line of the "From base image" line to build the target image file.
[0093] In this way, by identifying keywords through regular expressions and determining the target location based on the keywords, the keywords in the base image file can be efficiently identified and matched, the target location can be quickly determined, and the accuracy of the target location can be ensured through precise matching. In addition, the use of regular expressions can simplify code logic and improve code development and maintenance efficiency.
[0094] Optionally, the adding the version self-description information to the target location to obtain a target image file includes:
[0095] Add the version self-description information in the line where the target location is located and in the line below the line where the target location is located;
[0096] The version self-description information is set as an environment variable in the target image file to obtain the target image file.
[0097] In the embodiment of the present application, environment variables refer to the configuration information required for storing the application runtime. Setting the version self-description information as the environment variable in the target image file means storing the version self-description information in the environment variable of the container image so that the information can be easily accessed when the container is running.
[0098] Among them, by storing version information through environment variables, the code version corresponding to the running container can be quickly determined, which is convenient for problem troubleshooting and version tracing. In addition, environment variables can be set dynamically when the container is started, supporting different configuration requirements in different environments such as development, testing, and production. This makes the management of version information more flexible and can adapt to different deployment requirements.
[0099] For example, Figure 8 As shown, after identifying the position of the "From base image" line in the Dockerfile file, the content of the Dockerfile file can be dynamically modified, such as adding version self-description information in the line after the position of the "From base image" line, and setting the version self-description information as the environment variable information in the image.
[0100] Therefore, the embodiments of the present application can clearly record and identify the version of the image by including version self-description information in the image file, embed the version information in the image file as part of the document, and identify the image file. Moreover, by setting the version information in the form of environment variables, it can ensure that consistent version information is used in different environments, thereby reducing problems caused by environmental differences.
[0101] In combination with the above embodiments, the embodiments of the present application provide a method for constructing an image file, in which version self-description information is automatically written into the image file during the process of constructing the image file in the pipeline, without human intervention, and the version self-description information contains rich code information related to code engineering. The code information is combined based on user needs to generate version self-description information that meets specific needs, and the version self-description information determined based on user needs is unique, so that when the version self-description information in the image file is modified again to rebuild the target image, the checksum value of the image medium is also changed accordingly. Therefore, the target image file and the target image constructed based on the target image file are unique in version information. Among them, the present application implements version self-description enhancement for all pipeline tasks through a unified version self-description enhancement device, without the need for each development team to modify its own pipeline tasks, reducing manual intervention and improving the efficiency of building image files.
[0102] In one possible design, the method further includes:
[0103] Packing the target image file to obtain a target image;
[0104] The image name and the image tag input by the user are obtained, and the target image is image-identified based on the image name and the image tag.
[0105] Among them, the image name and image tag are associated with the version self-description information, which can further enhance the traceability of the image.
[0106] Exemplary, combined Figure 3 and Figure 1 After adding the version self-description information to the target location and obtaining the target image file, the image program packages the target image file to generate the target image. Figure 1 In the display interface shown, the developer enters content in the input boxes corresponding to the image name and image label to label the image.
[0107] In this way, the embodiment of the present application can also quickly understand the version and status of the image through label management, and can clearly identify the version and purpose of each image through the dual identification of the image identification and the version self-description information.
[0108] In one possible design, the method further includes:
[0109] Get the application scenario for executing the current pipeline task;
[0110] The version self-description information is determined from the code matching library based on the application scenario; the code matching library pre-stores the version self-description information corresponding to different application scenarios in advance, and updates the version self-description information obtained based on different user demand combinations.
[0111] In an embodiment of the present application, an application scenario may refer to an application scenario required to execute the current pipeline task during the software development process. Different application scenarios correspond to different code information. Therefore, the version self-description information corresponding to each application scenario may be pre-stored in the code matching library in advance. In this way, after determining the application scenario, the required version self-description information may be directly obtained from the code matching library, and then the version self-description information may be added to the target location to obtain the target image file, thereby reducing intermediate steps, improving the response speed, and thereby accelerating the processing rate.
[0112] In this application, in addition to combining code information based on user needs to obtain version self-description information, you can also directly obtain the application scenario for executing the current pipeline task, determine the version self-description information based on the mapping relationship between the application scenario and the version self-description information, and support diverse needs.
[0113] It should be noted that the code matching library pre-stores version self-description information corresponding to different application scenarios, which can be compiled and pre-stored by the user in advance, or based on Figure 5The described embodiment is continuously executed, and after obtaining the version self-description information, it is stored after being associated with the application scenario. The embodiment of the present application does not specifically limit the manner in which the application scenario and the version self-description information with a mapping relationship pre-stored in the code matching library are stored.
[0114] Therefore, the embodiments of the present application can also reduce manual intervention and improve the degree of automation of the process by automatically obtaining application scenarios and determining version self-description information from the code matching library. The pre-stored code matching library can quickly provide the required version self-description information, reducing the time for generating version self-description information. Based on the automated version information update mechanism, it can ensure that the version self-description information is updated in real time and the version self-description information in the code matching library is continuously enriched to adapt to different development and deployment environments, thereby improving the flexibility of the application.
[0115] In the foregoing embodiments, the image file construction method provided by the embodiments of the present application is introduced, and in order to realize the functions in the method provided by the embodiments of the present application, the electronic device as the execution subject may include a hardware structure and / or a software module, and the above functions are realized in the form of a hardware structure, a software module, or a hardware structure plus a software module. Whether one of the above functions is executed in the form of a hardware structure, a software module, or a hardware structure plus a software module depends on the specific application and design constraints of the technical solution.
[0116] For example, Fig. 9 A schematic diagram of the structure of an image file construction device provided in an embodiment of the present application is shown in FIG. Fig. 9 As shown, the device comprises:
[0117] The acquisition module 901 is used to acquire at least one code information for executing the current pipeline task through the command of the code management program after executing the compile command;
[0118] A combination module 902 is used to combine the at least one code information based on user requirements to obtain version self-description information; the version self-description information is used to identify metadata required to execute pipeline tasks in image files of different versions;
[0119] The search module 903 is used to search for a target location in the basic image file through a matching algorithm, and add the version self-description information to the target location to obtain a target image file.
[0120] In a possible design, the code information includes: code repository information, code branch information, code submission information, and identification information of pipeline tasks; the combination module 902 is specifically used to:
[0121] determining target code information from the at least one code information based on user requirements;
[0122] The target code information and the time of executing the current pipeline task are combined to obtain version self-description information.
[0123] In a possible design, the search module 903 includes a search unit and an adding unit; the search unit is used to:
[0124] Identify keywords in the base image file through regular expressions;
[0125] The target location is determined based on the keyword; the keyword is used to specify the starting point location of the base image.
[0126] In a possible design, the adding unit is used to:
[0127] Add the version self-description information in the line where the target location is located and in the line below the line where the target location is located;
[0128] The version self-description information is set as an environment variable in the target image file to obtain the target image file.
[0129] In a possible design, the apparatus further includes an identification module, wherein the identification module is configured to:
[0130] Packing the target image file to obtain a target image;
[0131] The image name and the image tag input by the user are obtained, and the target image is image-identified based on the image name and the image tag.
[0132] In a possible design, the apparatus further includes an identification module, and the determination module is configured to:
[0133] Get the application scenario for executing the current pipeline task;
[0134] The version self-description information is determined from the code matching library based on the application scenario; the code matching library pre-stores the version self-description information corresponding to different application scenarios in advance, and updates the version self-description information obtained based on different user demand combinations.
[0135] The image file construction device provided in the embodiment of the present application can be used to execute the technical solution of the image file construction method in the above embodiment. Its implementation principle and technical effect are similar and will not be repeated here.
[0136] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software calling through processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software calling through processing elements, and some modules can be implemented in the form of hardware. For example, the search module 903 can be a separately established processing element, or it can be integrated in a chip of the above device. In addition, it can also be stored in the memory of the above device in the form of program code, and called and executed by a processing element of the above device. The function of the above search module 903. The implementation of other modules is similar. In addition, all or part of these modules can be integrated together, or they can be implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
[0137] Fig.10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.10 As shown, the electronic device may include: a transceiver 1001 , a processor 1002 , and a memory 1003 .
[0138] The processor 1002 executes the computer execution instructions stored in the memory, so that the processor 1002 executes the scheme in the above embodiment. The processor 1002 can be a general-purpose processor, including a central processing unit CPU, a network processor (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 gates or transistor logic devices, and discrete hardware components.
[0139] The memory 1003 is connected to the processor 1002 via a system bus and completes communication between them. The memory 1003 is used to store computer program instructions.
[0140] The transceiver 1001 may be configured to obtain at least one code information for executing a current pipeline task through a command of a code management program after executing a compile command.
[0141] The system bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The transceiver is used to realize the communication between the database access device and other computers (such as clients, read-write libraries, and read-only libraries). The memory may include random access memory (RAM) and may also include non-volatile memory (Non-volatile Memory).
[0142] The electronic device provided in the embodiment of the present application may be the terminal device of the above embodiment.
[0143] The embodiment of the present application also provides a chip for executing instructions, which is used to execute the technical solution of the image file construction method in the above embodiment.
[0144] The embodiment of the present application further provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed on a computer, the computer executes the technical solution of the image file construction method of the above embodiment.
[0145] An embodiment of the present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. At least one processor can read the computer program from the computer-readable storage medium. When at least one processor executes the computer program, the technical solution of the image file construction method in the above embodiment can be implemented.
[0146] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0147] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to implement the solution of this embodiment.
[0148] In addition, each functional module in each embodiment of the present application can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit. The above-mentioned module-composed unit can be implemented in the form of hardware or in the form of hardware plus software functional units.
[0149] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the methods of various embodiments of the present application.
[0150] It should be understood that the above processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the invention can be directly embodied as being executed by a hardware processor, or can be executed by a combination of hardware and software modules in the processor.
[0151] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.
[0152] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of this application is not limited to only one bus or one type of bus.
[0153] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.
[0154] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the storage medium can also exist as discrete components in an electronic control unit or a main control device.
[0155] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0156] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for building an image file, It is characterized in that The method comprises: After executing the compile command, obtaining at least one code information for executing the current pipeline task through the command of the code management program; Combining the at least one code information based on user requirements to obtain version self-description information; the version self-description information is used to identify metadata required to execute pipeline tasks in image files of different versions; The target position in the base image file is found through a matching algorithm, and the version self-description information is added to the target position to obtain the target image file.
2. The method according to claim 1, It is characterized in that The code information includes: code repository information, code branch information, code submission information, and pipeline task identification information; the at least one code information is combined based on user needs to obtain version self-description information, including: determining target code information from the at least one code information based on user requirements; The target code information and the time of executing the current pipeline task are combined to obtain version self-description information.
3. The method according to claim 1, It is characterized in that The searching of the target location in the base image file by the matching algorithm includes: Identify keywords in the base image file through regular expressions; The target location is determined based on the keyword; the keyword is used to specify the starting point location of the base image.
4. The method according to claim 1, It is characterized in that The step of adding the version self-description information to the target location to obtain a target image file includes: Add the version self-description information in the line where the target location is located and in the line below the line where the target location is located; The version self-description information is set as an environment variable in the target image file to obtain the target image file.
5. The method according to claim 1, It is characterized in that The method further comprises: Packing the target image file to obtain a target image; The image name and the image tag input by the user are obtained, and the target image is image-identified based on the image name and the image tag.
6. The method according to any one of claims 1 to 5, It is characterized in that The method further comprises: Get the application scenario for executing the current pipeline task; The version self-description information is determined from the code matching library based on the application scenario; the code matching library pre-stores the version self-description information corresponding to different application scenarios in advance, and updates the version self-description information obtained based on different user demand combinations.
7. A device for constructing an image file, It is characterized in that The device comprises: An acquisition module, used to acquire at least one code information for executing a current pipeline task through a command of a code management program after executing a compile command; A combination module, used to combine the at least one code information based on user requirements to obtain version self-description information; the version self-description information is used to identify metadata required to execute pipeline tasks in image files of different versions; The search module is used to search for a target location in a basic image file through a matching algorithm, and add the version self-description information to the target location to obtain a target image file.
8. An electronic device, It is characterized in that include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 6 when executed by a processor.
10. A computer program product, It is characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 6 when being executed by a processor.
Citation Information
Cited By
Mirror image file construction method and device, computer equipment and storage medium
CN119668631A
A mirror file construction method and device, computer equipment and storage medium
CN119668631B
Mirror image file configuration method and device and electronic equipment
CN121349480A
Assembling method of multi-branch product and electronic equipment
CN122633199A
