Cache-dependent multi-mirror-image multi-stage construction method and device, equipment and storage medium

By dividing the construction process into multiple independent stages and introducing a dependency cache mechanism, the problems of long construction time, low resource utilization and complex dependency management in the existing technology are solved, and an efficient and reliable construction process is achieved and structured Error reporting, easy to troubleshoot.

CN119065684APending Publication Date: 2024-12-03SHANGHAI DONGPU INFORMATION TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411014906.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-26
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

When dealing with large-scale software projects, existing construction tools face problems such as long construction time, low resource utilization, large error impact, complex dependency management and large mirror size, resulting in low efficiency and poor reliability.

Method used

Divide the construction process into multiple independent stages, build different Docker images in each stage, introduce a dependency caching mechanism, avoid repeated downloads and installation of the same dependencies, generate structured reports through error checking and classification, and ensure that failures of each stage do not block. Follow-up stage.

Benefits of technology

It improves the efficiency and reliability of project construction, reduces the mirror volume, improves resource utilization, and facilitates troubleshooting and performance optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119065684A_ABST
    Figure CN119065684A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of information processing, in particular to a cache dependency multi-mirror-image multi-stage construction method, device and equipment and a storage medium, all stage dependency packages needed by a project are analyzed from a cache according to a project configuration file, different stage dependency packages are used for constructing a plurality of Docker mirror images with a basic mirror image as a starting point, and the Docker mirror images are constructed according to the Docker mirror images. A dependency cache mechanism is introduced in each stage, repeated downloading and installation of the same dependency are avoided, the resource utilization rate is improved, the mirror image size is reduced, the construction process is divided into a plurality of independent stages, different Docker mirror images are constructed in each stage to complete specific tasks, error check is performed at the end of each stage, and the task efficiency is improved. According to the method, the error information is recorded according to the check result, errors generated by construction are isolated in each stage, it is ensured that failure of a single stage does not block the subsequent stage, the project construction efficiency and reliability are improved, a structured error report is generated according to the error classification result, and later troubleshooting and performance optimization are facilitated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information processing technology, and in particular to a cache-dependent multi-mirror multi-stage construction method, device, equipment and storage medium. Background Art

[0002] At present, with the increasing complexity of software projects, the build process has become more and more complicated and time-consuming. Although existing build tools can complete build tasks, they often face the following challenges when dealing with large-scale projects: 1. Long build time. The single-stage build process takes a long time, affecting the development and release efficiency; 2. Low resource utilization. The utilization rate of resources (such as CPU and memory) during the build process is not high, resulting in waste; 3. The impact of build failure is large. Errors in the build process may cause the entire build process to fail, wasting time and resources; 4. Dependency management is difficult. In large projects, dependency management and version control are complex and easily cause dependency conflicts; 5. Large image size. A single image contains all build steps and dependencies, resulting in a large image size and low transmission and deployment efficiency. Summary of the invention

[0003] In order to overcome the shortcomings of the prior art, the purpose of the present invention is to provide a method, device, equipment and storage medium for caching dependency multi-image multi-stage construction, which divides the construction process into multiple independent stages, builds different Docker images in each stage to complete specific tasks, isolates construction errors in each stage to avoid affecting the entire construction process, improves the efficiency and reliability of project construction, and introduces a dependency caching mechanism in each stage to avoid repeated downloading and installation of the same dependency, improves resource utilization and reduces the image size.

[0004] A first aspect of the present invention provides a cache-dependent multi-image multi-stage construction method, comprising: obtaining a project configuration file, parsing all the dependency packages of each stage required for the project from the cache according to the project configuration file; selecting a base image, and using different dependency packages of each stage to build multiple Docker images with the base image as the starting point; specifying the corresponding Docker image for each stage, and executing the construction of each stage according to the Docker image; performing an error check at the end of each stage, and recording the error information according to the check result to obtain record information; performing classification based on the record information to obtain an error classification result, and generating a structured error report according to the error classification result.

[0005] Optionally, in a first implementation method of the first aspect of the present invention, the project configuration file is obtained, and all dependency packages required for the project at each stage are parsed from the cache according to the project configuration file, including: saving the dependency packages and dependency lists to a locally stored cache, and regularly updating the cache to obtain the latest cache; obtaining the project configuration file, identifying all dependencies in the project configuration file; determining whether the dependency packages corresponding to the dependencies exist in the latest cache; if so, loading all the dependency packages corresponding to all the dependencies respectively from the latest cache to obtain multiple dependency packages for each stage.

[0006] Optionally, in a second implementation method of the first aspect of the present invention, the selecting of a base image and the use of different dependency packages of each stage to build multiple Docker images with the base image as the starting point include: pulling a base image from a container image repository; writing a Dockerfile instruction for each dependency package of each stage; and using different Dockerfile instructions to build multiple Docker images with the base image as the starting point.

[0007] Optionally, in a third implementation of the first aspect of the present invention, the corresponding Docker image is specified for each stage, and the construction of each stage is performed according to the Docker image, including: specifying the corresponding Docker image for each stage, the Docker image is one of a static checking tool image, a test framework image, a compilation tool image and a packaging tool image; using the static checking tool image to perform code checking, and using the test framework image to run unit tests; using the compilation tool image to compile the code into bytecode or binary files, and using the packaging tool image to package the project into a deployable format.

[0008] Optionally, in a fourth implementation method of the first aspect of the present invention, an error check is performed at the end of each of the stages, and the error information is recorded based on the check results to obtain record information, including: at the end of each of the stages, using the exit status of the RUN instruction to check whether the stage is successfully executed; if the execution fails, stopping the construction of the stage and capturing the error information; marking the current stage as a failed state, and recording the current stage and the error information to obtain record information.

[0009] Optionally, in a fifth implementation method of the first aspect of the present invention, the classification is performed based on the record information to obtain an error classification result, and a structured error report is generated based on the error classification result, including: identifying the error type, error time, error location and error cause of the record information; classifying the record information according to the error type, the error time, the error location and the error cause to obtain an error classification result; analyzing the record information according to the error type, the error time, the error location and the error cause to obtain an error analysis result; generating a structured error report based on the error classification result and the error analysis result, the error report including error type information, occurrence time information, affected construction phase information, possible cause information and repair suggestion information.

[0010] Optionally, in a sixth implementation method of the first aspect of the present invention, after the classification is performed based on the record information to obtain an error classification result, and a structured error report is generated according to the error classification result, it also includes: sending the error report to a management terminal so that the management terminal generates and displays a report page based on the error report; creating a repair listener, and using the repair listener to listen to the repair information corresponding to the error information; when the repair listener listens to the repair information, obtaining the current repair information; merging the repair information and the corresponding error information to obtain merged information; encrypting the merged information to obtain encrypted information, and uploading the encrypted information to the blockchain.

[0011] The second aspect of the present invention provides a cache-dependent multi-image multi-stage construction device, including: an acquisition and parsing module, used to obtain a project configuration file, and parse all the dependency packages of each stage required for the project from the cache according to the project configuration file; a selection and construction module, used to select a basic image, and use different dependency packages of each stage to build multiple Docker images with the basic image as the starting point; a specified execution module, used to specify the corresponding Docker image for each stage, and execute the construction of each stage according to the Docker image; a check and record module, used to perform error checking at the end of each stage, and record the error information according to the check result to obtain record information; a classification generation module, used to classify based on the record information, obtain error classification results, and generate a structured error report according to the error classification results.

[0012] Optionally, in a first implementation method of the second aspect of the present invention, the acquisition and parsing module includes: a saving and updating unit, used to save the dependency package and the dependency list to a locally stored cache, and periodically update the cache to obtain the latest cache; an acquisition and identification unit, used to obtain a project configuration file and identify all dependencies in the project configuration file; a judgment unit, used to judge whether the dependency package corresponding to the dependency exists in the latest cache; and a loading unit, used to load all the dependency packages corresponding to all the dependencies respectively from the latest cache, if so, to obtain multiple dependency packages for each stage.

[0013] Optionally, in a second implementation of the second aspect of the present invention, the selection and construction module includes: a pulling unit, used to pull a base image from a container image repository; a writing unit, used to write a Dockerfile instruction for each of the dependency packages in each stage; and a construction unit, used to use different Dockerfile instructions to build multiple Docker images with the base image as the starting point.

[0014] Optionally, in a third implementation of the second aspect of the present invention, the designated execution module includes: a designation unit, used to specify the corresponding Docker image for each stage, the Docker image being one of a static checking tool image, a test framework image, a compilation tool image, and a packaging tool image; a checking and testing unit, used to perform code checking using the static checking tool image, and to run unit tests using the test framework image; a compilation and packaging unit, used to compile the code into bytecode or binary files using the compilation tool image, and to package the project into a deployable format using the packaging tool image.

[0015] Optionally, in a fourth implementation of the second aspect of the present invention, the inspection and recording module includes: an inspection unit, used to use the exit status of the RUN instruction to check whether the stage is successfully executed at the end of each stage; a stop capture unit, used to stop the construction of the stage and capture error information if the execution fails; a marking and recording unit, used to mark the current stage as a failure state, and record the current stage and the error information to obtain record information.

[0016] Optionally, in a fifth implementation of the second aspect of the present invention, the classification generation module includes: an identification unit, used to identify the error type, error time, error location and error cause of the record information; a classification unit, used to classify the record information according to the error type, the error time, the error location and the error cause to obtain an error classification result; an analysis unit, used to analyze the record information according to the error type, the error time, the error location and the error cause to obtain an error analysis result; a generation unit, used to generate a structured error report based on the error classification result and the error analysis result, the error report including error type information, occurrence time information, affected construction stage information, possible cause information and repair suggestion information.

[0017] Optionally, in a sixth implementation method of the second aspect of the present invention, it also includes: a sending module, used to send the error report to a management terminal, so that the management terminal generates and displays a report page based on the error report; a creation monitoring module, used to create a repair listener, and use the repair listener to monitor the repair information corresponding to the error information; an acquisition module, used to obtain the current repair information when the repair listener monitors the repair information; a merging module, used to merge the repair information and the corresponding error information to obtain merged information; an encryption upload module, used to encrypt the merged information to obtain encrypted information, and upload the encrypted information to the blockchain.

[0018] A third aspect of the present invention provides a cache-dependent multi-image multi-stage construction device, the cache-dependent multi-image multi-stage construction device comprising: a memory and at least one processor, the memory storing instructions; at least one of the processors calls the instructions in the memory to enable the cache-dependent multi-image multi-stage construction device to perform each step of the cache-dependent multi-image multi-stage construction method described above.

[0019] A fourth aspect of the present invention provides a computer-readable storage medium having instructions stored thereon, and when the instructions are executed by a processor, the steps of any of the above-mentioned cache-dependent multi-image multi-stage construction methods are implemented.

[0020] In the technical solution of the present invention, all dependency packages of each stage required for the project are parsed from the cache according to the project configuration file, and different dependency packages of each stage are used to build multiple Docker images with the base image as the starting point. A dependency cache mechanism is introduced in each stage to avoid repeated downloading and installation of the same dependency, improve resource utilization and reduce the image size, divide the construction process into multiple independent stages, build different Docker images in each stage to complete specific tasks, perform error checking at the end of each stage, and record error information based on the inspection results. Errors generated by the construction are isolated in each stage to ensure that the failure of a single stage will not block subsequent stages and avoid affecting the entire construction process, thereby improving the efficiency and reliability of project construction, and generating a structured error report based on the error classification results to facilitate subsequent troubleshooting and performance optimization. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 A first flow chart of a cache-dependent multi-image multi-stage construction method provided by an embodiment of the present invention;

[0022] Figure 2 A second flow chart of the cache-dependent multi-image multi-stage construction method provided by an embodiment of the present invention;

[0023] Figure 3 A third flow chart of the cache-dependent multi-image multi-stage construction method provided by an embodiment of the present invention;

[0024] Figure 4 A fourth flow chart of a cache-dependent multi-image multi-stage construction method provided by an embodiment of the present invention;

[0025] Figure 5 A schematic diagram of a structure of a cache-dependent multi-image multi-stage construction device provided by an embodiment of the present invention;

[0026] Figure 6 Another structural schematic diagram of a cache-dependent multi-image multi-stage construction device provided by an embodiment of the present invention;

[0027] Figure 7 A schematic diagram of the structure of a cache-dependent multi-image multi-stage construction device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0028] The present invention provides a cache-dependent multi-image multi-stage construction method, device, equipment and storage medium, which divides the construction process into multiple independent stages, builds different Docker images in each stage to complete specific tasks, isolates construction errors in each stage to avoid affecting the entire construction process, improves the efficiency and reliability of project construction, and introduces a dependency caching mechanism in each stage to avoid repeated downloading and installation of the same dependency, improves resource utilization and reduces image size.

[0029] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0030] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 , an embodiment of the cache-dependent multi-image multi-stage construction method in an embodiment of the present invention includes:

[0031] 101. Get the project configuration file, and parse all the dependency packages required for the project at each stage from the cache according to the project configuration file;

[0032] In this embodiment, the location of the project configuration file is located, the content of the configuration file is read, and the content of the configuration file is parsed into an operable data structure (such as a JavaScript object, a Python dictionary, etc.) using an XML parsing library. According to the project type and build requirements, the part related to the dependency package is parsed, including the name and version of the dependency package, and the local cache system is accessed. The cache system should contain the dependency packages previously downloaded or built. The list of dependency packages parsed from the configuration file is traversed to check whether each dependency package exists in the cache. If so, they are classified and prepared for subsequent build processes according to the project's build stage (such as development, testing, production, etc.) and the purpose of the dependency package (such as direct dependency, development dependency, etc.). If they do not exist, these dependency packages need to be downloaded from external sources (such as npm repositories, Maven central repositories, etc.) and the local cache is updated.

[0033] 102. Select a base image and use different dependency packages at each stage to build multiple Docker images based on the base image.

[0034] In this embodiment, a suitable base image is selected according to the requirements of the project (such as language, runtime environment, framework, etc.). The base image should be as lightweight as possible and contain the minimum environment required for project construction and operation. The base image can be obtained from public or private image repositories such as Alibaba Cloud Image Repository. Before building the Docker image, ensure that all necessary dependency packages have been obtained according to the requirements of the project. These dependency packages include libraries, frameworks, tools, etc., which will be used in different construction stages of the project (such as code inspection, testing, compilation, packaging, etc.). Create a special Dockerfile instruction for each stage and specify the dependency packages required for that stage. Use different Dockerfile instructions to build multiple Docker images starting from the base image.

[0035] 103. Specify the corresponding Docker image for each stage, and execute the build of each stage according to the Docker image;

[0036] In this embodiment, each Dockerfile should be based on a suitable base image and contain all the dependencies and configurations required for the stage. A different context and label are specified for each Dockerfile. A continuous integration / continuous deployment (CI / CD) tool is used to build the Docker image of each stage. After the image is built, a container is started and the commands are executed in it.

[0037] 104. Perform an error check at the end of each stage, and record the error information according to the check result to obtain record information;

[0038] In this embodiment, it is clear which stages are included in the build process, such as code acquisition, dependency installation, compilation, testing, packaging, etc., and error checkpoints are set at the end of each stage or after key operations. These checkpoints will be used to verify whether the stage is successfully completed and whether any errors occur. For each checkpoint, a corresponding script or command is written to perform error checking. These scripts can check the exit status code, log files, output files, etc. to determine whether an error occurs. The error checking script is integrated into the build process to ensure automatic execution at each checkpoint. When executing the check script, its output is captured. This information contains detailed information about the error. The captured error information is formatted in a format that is easy to understand and store, including timestamp, stage name, error type, error description, etc. If an error is detected, a recording operation is performed.

[0039] 105. Classify based on the recorded information to obtain error classification results, and generate a structured error report according to the error classification results;

[0040] In this embodiment, all relevant log files and error records are collected, the collected data are organized to ensure that they are stored in a consistent and processable format, a series of common error types are defined based on business logic, technology stack or past experience, clear classification standards are established for each error type, scripts or programs are written to automatically classify record information into predefined error types, error report templates are designed according to requirements, the classified error records are filled into the report template, and analysis of the cause of the error, impact assessment, and solution suggestions are added to the report.

[0041] In an embodiment of the present invention, all dependency packages of each stage required for the project are parsed from the cache according to the project configuration file, and different dependency packages of each stage are used to build multiple Docker images with the base image as the starting point. A dependency cache mechanism is introduced in each stage to avoid repeated downloading and installation of the same dependency, improve resource utilization and reduce the image size, divide the construction process into multiple independent stages, build different Docker images in each stage to complete specific tasks, perform error checking at the end of each stage, and record error information based on the checking results. Errors generated by the construction are isolated in each stage to ensure that the failure of a single stage will not block subsequent stages and avoid affecting the entire construction process, thereby improving the efficiency and reliability of project construction, and generating a structured error report based on the error classification results to facilitate subsequent troubleshooting and performance optimization.

[0042] See also Figure 2 The second embodiment of the cache-dependent multi-image multi-stage construction method in the embodiment of the present invention includes:

[0043] 201. Save the dependency package and dependency list to the cache stored locally, and update the cache regularly to obtain the latest cache;

[0044] In this embodiment, the dependency package is downloaded from a remote repository (such as npm, PyPI, RubyGems, etc.) to a local temporary directory. Before saving to the cache, the integrity and validity of the dependency package are verified, and the verified dependency package is copied to the specified cache storage location. According to the project requirements and operating environment, a suitable timed task tool (such as cron, Windows scheduled task, etc.) is selected, and a script is written to execute the logic of cache update, including checking the dependency of the new version, downloading and verifying, replacing the old version, etc. The selected timing tool is used to configure the scheduled task, and the time and frequency of task execution are specified. The scheduled task is automatically triggered according to the set time and frequency. After triggering, the written update script is executed to update the dependency package and dependency list in the cache according to the predetermined logic. Detailed log information is recorded during the update process for tracking and debugging. Old version dependency packages that are no longer needed are regularly cleaned up to free up storage space, and cache storage is optimized, such as compressing files, merging database records, etc., to improve access efficiency and reduce storage costs.

[0045] 202. Obtain a project configuration file and identify all dependencies in the project configuration file;

[0046] In this embodiment, the storage location of the project configuration file (such as the project root directory, a specific configuration folder) as well as the file type and file format are determined, the project configuration file is obtained, the content of the project configuration file is read, and the project configuration file is parsed according to the format of the project configuration file to identify and extract all dependency information.

[0047] 203. Determine whether there is a dependency package corresponding to the dependency item in the latest cache;

[0048] In this embodiment, according to the storage structure of the cache and the extracted dependency information, the cache is traversed to find out whether there is a dependency package corresponding to the dependency. If the cache is stored in the file system, the corresponding folders and files can be traversed according to the name and version number of the dependency package (if provided). If the cache is stored in a database, the name and version number of the dependency package (if provided) can be used as query conditions to execute SQL queries to find matching records. After finding the dependency package, its integrity and validity need to be verified. For dependency packages in the file system, hash checks (such as MD5, SHA-256, etc.) can be used to verify the integrity of the file. The search results are recorded for subsequent processing. The search results include information such as whether the dependency package exists, its storage location, and integrity and validity verification results.

[0049] 204. If yes, all dependency packages corresponding to all dependencies are loaded from the latest cache to obtain multiple dependency packages at different stages;

[0050] In this embodiment, if there is a dependency package corresponding to the dependency item in the latest cache, all dependency packages corresponding to all dependency items are loaded from the latest cache to obtain multiple dependency packages in different stages.

[0051] 205. Pull a basic image from the container image repository;

[0052] In this embodiment, the specific base image name and tag are determined according to the instructions in the project configuration file, which specify the source, name and tag of the base image. The Docker command line tool or other tools that support container image management are used to pull the base image. After pulling the base image, it is necessary to verify whether the base image has been successfully downloaded locally.

[0053] 206. Write a Dockerfile instruction for each stage dependency package;

[0054] In this embodiment, a multi-stage build strategy is adopted to optimize the basic image, and specifically a Dockerfile instruction is written for each dependent package in each stage.

[0055] 207. Use different Dockerfile instructions to build multiple Docker images starting from a base image;

[0056] In this embodiment, the base image contains the common parts of all Dockerfiles. For each stage that requires an independent image, a different Dockerfile instruction needs to be used based on the base image. After having the Dockerfile instruction for each stage, the corresponding Docker image is built.

[0057] 208. Specify a corresponding Docker image for each stage, where the Docker image is one of a static inspection tool image, a test framework image, a compilation tool image, and a packaging tool image;

[0058] In this embodiment, a corresponding Docker image is specified for each stage, and the Docker image is one of a static inspection tool image, a test framework image, a compilation tool image, and a packaging tool image.

[0059] 209. Use static inspection tool images to check code and use test framework images to run unit tests;

[0060] In this embodiment, a stage is configured in a continuous integration / continuous deployment (CI / CD) pipeline for running static checks, a script is written that starts a static check tool image and passes the code to it as input, the script is executed in the CI / CD pipeline, the static check tool analyzes the code, and reports any problems found, a stage is configured in the CI / CD pipeline for running unit tests, a script is written that starts a test framework image and runs a test suite, the script is executed in the CI / CD pipeline, the test framework image executes the tests, and reports the test results.

[0061] 210. Use the compilation tool image to compile the code into bytecode or binary files, and use the packaging tool image to package the project into a deployable format;

[0062] In this embodiment, a stage is configured in a continuous integration / continuous deployment (CI / CD) pipeline for compiling the code into bytecode or binary files, a script is written that starts a compilation tool image and passes the code to it as input, the script is executed in the CI / CD pipeline, the compilation tool image compiles the code into bytecode or binary files, a stage is configured in the CI / CD pipeline for packaging the project into a deployable format, a script is written that starts a packaging tool image and passes the project to it as input, the script is executed in the CI / CD pipeline, and the packaging tool image packages the project into a deployable format.

[0063] In an embodiment of the present invention, by saving dependent packages and dependency lists in a local cache and updating them regularly, the increase in build time caused by network delays or unstable dependent sources can be significantly reduced. The cache mechanism allows the project to load dependent packages directly from the local when building, rather than downloading them from a remote warehouse each time, thereby speeding up the build speed. Regular updates of the cache ensure that the dependencies used by the project are the latest and verified, which helps maintain the stability and security of the project. The automated build process reduces the possibility of human errors and improves the standardization and repeatability of the build process. By writing Dockerfile instructions for the dependent packages of each stage and building multiple Docker images, the process supports complex build requirements such as static checking, testing, compilation, and packaging. Since each stage can run independently in a different Docker image, multiple build tasks can be processed in parallel, further improving build efficiency. The isolation of Docker images helps reduce potential security risks because each build stage runs in its own container and is isolated from each other.

[0064] See also Figure 3 A third embodiment of the cache-dependent multi-image multi-stage construction method in the embodiment of the present invention includes:

[0065] 301. At the end of each stage, use the exit status of the RUN instruction to check whether the stage was successfully executed;

[0066] In this embodiment, at the end of each stage, the exit status of the RUN instruction is used to check whether the stage is successfully executed. In the Docker building process, the RUN instruction is used to execute commands in each layer of the image and create a new image layer. If the command executed by the RUN instruction is successfully completed, Docker will continue the building process. If the command fails, Docker will stop the building and return an error. Therefore, although Docker itself will automatically check whether it is successfully executed based on the exit status of the RUN instruction.

[0067] 302. If the execution fails, stop the build of the stage and capture the error information;

[0068] In this embodiment, during the Docker build process, if the command execution in a certain stage fails, Docker will stop the build by default and display an error message.

[0069] 303. Mark the current stage as a failed state, and record the current stage and error information to obtain record information;

[0070] In this embodiment, when an error or abnormal situation is detected, the status flag is set to the "failure" state, and a logging mechanism is designed to collect and record various information during the operation of the system, including normal information and error information. When the current stage fails, the execution time, execution environment, execution parameters, input data and other key information of this stage are captured and recorded. At the same time, specific error information such as error code, error description, stack trace, etc. are captured and recorded to locate the cause of the problem. The recorded information can be stored in a log file, a database or a special error tracking system. The recorded information is organized into a structured format to obtain recorded information for subsequent analysis, processing and display.

[0071] 304. Identify the error type, error time, error location and error cause of the recorded information;

[0072] In this embodiment, specific error codes are assigned to different types of errors or descriptive error messages are provided, a series of error types are predefined, and they are mapped to corresponding categories when an error occurs. When the error information is recorded, an accurate timestamp is also recorded to indicate the time when the error occurred. By analyzing the log file, the timestamp associated with the error is found, and the call stack information is captured and recorded when the error occurs. Combined with the stack trace and source code, the code position where the error occurs can be accurately located. By analyzing the error code and description, the cause of the error can be inferred, and the log entries associated with the error can be viewed to find the operations or conditions that may cause the error. The system monitoring tool is used to observe the changes in the system state before and after the error occurs to find out the possible triggering factors.

[0073] 305. Classify the recorded information according to the error type, error time, error location and error cause to obtain an error classification result;

[0074] In this embodiment, the dimensions for clear classification are error type, error time, error location and error cause. The error type describes the nature or source of the error, such as configuration error, logical error, insufficient resources, etc. The error time refers to the exact time when the error occurs, which may include date, time and time zone information. The error location refers to the specific location where the error occurs, such as file name, line number, function name, etc. The error cause is the root cause of the error. Based on these dimensions, a reasonable classification strategy is designed to determine which dimensions have a higher priority in the classification. For example, the error type may be a primary classification basis, while the error time and location are used for further subdivision. According to the classification strategy, a unique classification identifier is generated for each error record to obtain an error classification result.

[0075] 306. Analyze the recorded information according to the error type, error time, error location and error cause to obtain an error analysis result;

[0076] In this embodiment, the nature or source of the error is understood in order to determine an applicable solution strategy, the time pattern of the error occurrence is determined in order to track the root cause of the problem or identify the system bottleneck, the code segment or system component where the error occurs is accurately located for rapid repair, and the root cause of the error is deeply explored in order to develop an effective solution. The above analysis results are combined to form a comprehensive understanding of the error, and a comprehensive analysis framework including the error type, time, location and cause is constructed. The analysis results are presented in the form of charts, reports or presentations, and the potential connections and common characteristics between the errors are identified to obtain the error analysis results.

[0077] 307. Generate a structured error report based on the error classification results and error analysis results. The error report includes error type information, occurrence time information, affected build phase information, possible cause information, and repair suggestion information;

[0078] In this embodiment, the basic structure of the error report is determined, and the relevant information in the error classification results and the error analysis results are integrated into various parts of the error report. The error report includes error type information, occurrence time information, affected construction phase information, possible cause information and repair suggestion information.

[0079] In the embodiment of the present invention, the exit status of the RUN instruction is checked immediately at the end of each stage, so that problems in the construction process can be quickly discovered, and the problems can be avoided from accumulating to subsequent stages, thereby reducing debugging time and cost. The automated error detection mechanism reduces the need for human intervention and improves the stability and reliability of the construction process. Once an error is found, the construction of the current stage is stopped immediately, which helps to quickly locate the problem and avoid unnecessary impact on other stages. The failed stage and error information are recorded in detail, which provides a reliable basis for subsequent debugging and problem solving. By identifying the error type, time, location and cause, the error information is analyzed in detail, which helps to understand the nature of the problem more accurately. The error information is classified and categorized, which helps to quickly identify common error patterns, thereby optimizing the construction process and tools. Based on the analysis of the error information, a more in-depth error analysis result can be generated, providing valuable insights for problem solving. The structured error report makes the presentation of error information clearer and more organized, which is convenient for team members to understand and discuss. By providing repair suggestion information, the error report helps team members to make decisions quickly and take appropriate measures to solve the problem.

[0080] See also Figure 4 The fourth embodiment of the cache-dependent multi-image multi-stage construction method in the embodiment of the present invention includes:

[0081] 401. Send the error report to the management terminal, so that the management terminal generates and displays a report page based on the error report;

[0082] In this embodiment, the data source of the error report is confirmed, and a suitable transmission protocol is selected to send the error report. The transmission protocol includes HTTP (for Web applications), FTP (File Transfer Protocol), SMTP (E-mail Protocol) or other protocols suitable for the specific environment. The receiving address or interface of the management terminal is determined to ensure that the error report is sent in a format that can be parsed by the management terminal. Once the error report is received, the management terminal needs to parse its content to extract key information, such as the error type, occurrence time, scope of impact, possible causes and repair suggestions, etc., design or select a suitable error report page template, fill the parsed error report data into the page template, and ensure that the generated report page can be viewed through a Web browser or other appropriate client.

[0083] 402. Create a repair listener, and use the repair listener to monitor the repair information corresponding to the error information;

[0084] In this embodiment, a repair listener is created, deployed to a production environment, and necessary initialization operations are performed to start the repair listener so that it starts to listen to repair information.

[0085] 403. When the repair listener listens to the repair information, the current repair information is obtained;

[0086] In this embodiment, when the repair listener receives an event or message, it first needs to parse the message to extract the content. The parsed content needs to be matched with predefined rules or patterns to determine whether the message contains repair information. When it is determined to be repair information, the current repair information is obtained.

[0087] 404. Merge the repair information and the corresponding error information to obtain merged information;

[0088] In this embodiment, an identifier (such as an error ID, a serial number, etc.) is used to associate the repair information with the corresponding error information, and a data processing function provided by a programming language is used to directly merge the repair information with the corresponding error information.

[0089] 405. Encrypt the merged information to obtain encrypted information, and upload the encrypted information to the blockchain;

[0090] In this embodiment, before encryption, the merged information needs to be preprocessed, such as removing redundant data, formatting data, etc., to improve encryption efficiency and security. The merged information is encrypted using a selected encryption algorithm. After encryption is completed, the correctness of the encryption result should be verified to ensure that the encryption process does not introduce errors or damage the data. According to the selected blockchain platform, the encrypted information is uploaded to the blockchain as part of the transaction, and the created transaction is broadcast to the blockchain network for verification and consensus by the nodes in the network. Once the transaction is verified and consensus is reached by enough nodes, the encrypted information will be added to the blockchain and become a tamper-proof part.

[0091] In an embodiment of the present invention, an error report can be sent to a management terminal in real time to ensure that the problem is discovered in a timely manner. The repair information is merged with the corresponding error information to help establish a clear connection between the two, which is convenient for subsequent analysis and processing. The merged information is encrypted to ensure the confidentiality and integrity of the information and prevent unauthorized access and tampering. The encrypted information is uploaded to the blockchain, and the distributed ledger characteristics and consensus mechanism of the blockchain are used to ensure that the information cannot be tampered with, providing a reliable basis for problem tracking and auditing.

[0092] The above describes the cache-dependent multi-image multi-stage construction method in the embodiment of the present invention. The following describes the cache-dependent multi-image multi-stage construction device in the embodiment of the present invention. Figure 5 In one embodiment of the present invention, a cache-dependent multi-image multi-stage construction device includes:

[0093] The acquisition and parsing module 501 is used to obtain the project configuration file and parse all the dependent packages required for the project at each stage from the cache according to the project configuration file;

[0094] A selection and construction module 502 is used to select a base image and use different dependency packages in each stage to build multiple Docker images based on the base image as a starting point;

[0095] A designated execution module 503 is used to specify a corresponding Docker image for each stage and execute the construction of each stage according to the Docker image;

[0096] The checking and recording module 504 is used to perform error checking at the end of each stage and record the error information according to the checking result to obtain the recording information;

[0097] The classification generation module 505 is used to perform classification based on the record information to obtain an error classification result, and generate a structured error report according to the error classification result.

[0098] In this embodiment, all dependency packages of each stage required for the project are parsed from the cache according to the project configuration file, and different dependency packages of each stage are used to build multiple Docker images with the base image as the starting point. A dependency cache mechanism is introduced in each stage to avoid repeated downloading and installation of the same dependency, improve resource utilization and reduce the image size. The build process is divided into multiple independent stages, and different Docker images are built in each stage to complete specific tasks. Error checking is performed at the end of each stage, and error information is recorded based on the check results. Errors generated by the build are isolated in each stage to ensure that the failure of a single stage will not block subsequent stages and avoid affecting the entire build process. The efficiency and reliability of the project build are improved, and a structured error report is generated based on the error classification results to facilitate subsequent troubleshooting and performance optimization.

[0099] See also Figure 6 Another embodiment of the cache-dependent multi-image multi-stage construction device in the embodiment of the present invention includes:

[0100] The acquisition and parsing module 501 is used to obtain the project configuration file and parse all the dependent packages required for the project at each stage from the cache according to the project configuration file;

[0101] A selection and construction module 502 is used to select a base image and use different dependency packages in each stage to build multiple Docker images based on the base image as a starting point;

[0102] A designated execution module 503 is used to specify a corresponding Docker image for each stage and execute the construction of each stage according to the Docker image;

[0103] The checking and recording module 504 is used to perform error checking at the end of each stage and record the error information according to the checking result to obtain the recording information;

[0104] A classification generation module 505 is used to classify based on the recorded information, obtain an error classification result, and generate a structured error report according to the error classification result;

[0105] In this embodiment, the acquisition and parsing module 501 includes: a saving and updating unit 5011, which is used to save the dependency package and the dependency list to a locally stored cache, and regularly update the cache to obtain the latest cache; an acquisition and identification unit 5012, which is used to obtain a project configuration file and identify all dependencies in the project configuration file; a judgment unit 5013, which is used to judge whether there is a dependency package corresponding to the dependency in the latest cache; a loading unit 5014, which is used to load all dependency packages corresponding to all dependencies from the latest cache if so, to obtain multiple dependency packages of each stage.

[0106] In this embodiment, the construction module 502 is selected to include: a pulling unit 5021, which is used to pull a basic image from a container image repository; a writing unit 5022, which is used to write a Dockerfile instruction for each dependent package in each stage; and a construction unit 5023, which is used to use different Dockerfile instructions to build multiple Docker images based on the basic image.

[0107] In this embodiment, the designated execution module 503 includes: a designation unit 5031, which is used to specify the corresponding Docker image for each stage, and the Docker image is one of a static inspection tool image, a test framework image, a compilation tool image and a packaging tool image; a check and test unit 5032, which is used to use the static inspection tool image to perform code inspection and use the test framework image to run unit tests; a compilation and packaging unit 5033, which is used to compile the code into bytecode or binary files using the compilation tool image, and use the packaging tool image to package the project into a deployable format.

[0108] In this embodiment, the inspection and recording module 504 includes: an inspection unit 5041, which is used to use the exit status of the RUN instruction to check whether the stage is successfully executed at the end of each stage; a stop capture unit 5042, which is used to stop the construction of the stage and capture error information if the execution fails; a marking and recording unit 5043, which is used to mark the current stage as a failure state, and record the current stage and error information to obtain record information.

[0109] In this embodiment, the classification generation module 505 includes: an identification unit 5051, which is used to identify the error type, error time, error location and error cause of the record information; a classification unit 5052, which is used to classify the record information according to the error type, error time, error location and error cause to obtain an error classification result; an analysis unit 5053, which is used to analyze the record information according to the error type, error time, error location and error cause to obtain an error analysis result; a generation unit 5054, which is used to generate a structured error report based on the error classification result and the error analysis result, and the error report includes error type information, occurrence time information, affected construction stage information, possible cause information and repair suggestion information.

[0110] In this embodiment, it also includes: a sending module 506, which is used to send the error report to the management terminal, so that the management terminal generates and displays a report page based on the error report; a creation monitoring module 507, which is used to create a repair listener, and use the repair listener to monitor the repair information corresponding to the error information; an acquisition module 508, which is used to obtain the current repair information when the repair listener monitors the repair information; a merging module 509, which is used to merge the repair information and the corresponding error information to obtain merged information; an encryption upload module 510, which is used to encrypt the merged information, obtain encrypted information, and upload the encrypted information to the blockchain.

[0111] above Figure 5 and Figure 6 The cache-dependent multi-image multi-stage construction device in the embodiment of the present invention is described in detail from the perspective of modular functional entities. The cache-dependent multi-image multi-stage construction device in the embodiment of the present invention is described in detail from the perspective of hardware processing.

[0112] Figure 7 1 is a schematic diagram of a cache-dependent multi-image multi-stage construction device provided by an embodiment of the present invention. The cache-dependent multi-image multi-stage construction device 600 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 610 (for example, one or more processors) and a memory 620, and one or more storage media 630 (for example, one or more mass storage devices) storing application programs 633 or data 632. Among them, the memory 620 and the storage medium 630 can be short-term storage or persistent storage. The program stored in the storage medium 630 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the cache-dependent multi-image multi-stage construction device 600. Furthermore, the processor 610 can be configured to communicate with the storage medium 630, and execute a series of instruction operations in the storage medium 630 on the cache-dependent multi-image multi-stage construction device 600 to implement the steps of the cache-dependent multi-image multi-stage construction method provided in the above-mentioned method embodiments.

[0113] The cache-dependent multi-image multi-stage construction device 600 may also include one or more power supplies 640, one or more wired or wireless network interfaces 650, one or more input and output interfaces 660, and / or one or more operating systems 631, such as Windows Serve, Mac OS X, Unix, Linux, FreeBSD, etc. Those skilled in the art will appreciate that Figure 7The illustrated cache-dependent multi-image multi-stage construction device structure does not constitute a limitation on the cache-dependent multi-image multi-stage construction device, and may include more or fewer components than illustrated, or a combination of certain components, or a different arrangement of components.

[0114] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When the instructions are executed on a computer, the computer executes the steps of the cache-dependent multi-image multi-stage construction method.

[0115] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system, device or unit described above can refer to the corresponding process in the aforementioned method embodiment and will not be repeated here.

[0116] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.

[0117] Finally, it should be noted that the above description is only a preferred example of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A cache-dependent multi-image multi-stage construction method, It is characterized in that include: Obtain a project configuration file, and parse all dependency packages required for the project at each stage from the cache according to the project configuration file; Select a base image, and use different dependency packages of each stage to build multiple Docker images based on the base image as a starting point; Specify the corresponding Docker image for each stage, and execute the construction of each stage according to the Docker image; Performing an error check at the end of each of the stages, and recording error information according to the check result to obtain record information; Classification is performed based on the record information to obtain an error classification result, and a structured error report is generated according to the error classification result.

2. According to the cache-dependent multi-image multi-stage construction method of claim 1, It is characterized in that The obtaining of the project configuration file, and parsing all the dependent packages required for the project at each stage from the cache according to the project configuration file, includes: The dependent packages and the dependency list are saved in a cache stored locally, and the cache is updated regularly to obtain the latest cache; Obtain a project configuration file, and identify all dependencies in the project configuration file; Determine whether the dependency package corresponding to the dependency item exists in the latest cache; If so, all the dependency packages corresponding to all the dependencies are loaded from the latest cache to obtain multiple dependency packages in each stage.

3. The cache-dependent multi-image multi-stage construction method according to claim 1, It is characterized in that The selecting of the base image, using different dependency packages of each stage to build multiple Docker images with the base image as the starting point, includes: Pull a base image from the container image repository; Write a Dockerfile instruction for each of the dependency packages in each stage; Using different Dockerfile instructions, multiple Docker images are built with the base image as a starting point.

4. The cache-dependent multi-image multi-stage construction method according to claim 1, It is characterized in that Specifying the corresponding Docker image for each stage and executing the construction of each stage according to the Docker image includes: Specifying the corresponding Docker image for each stage, wherein the Docker image is one of a static inspection tool image, a test framework image, a compilation tool image, and a packaging tool image; Use the static inspection tool image to perform code inspection, and use the test framework image to run unit tests; The code is compiled into bytecode or binary files using the compilation tool image, and the project is packaged into a deployable format using the packaging tool image.

5. The cache-dependent multi-image multi-stage construction method according to claim 1, It is characterized in that The error check is performed at the end of each stage, and the error information is recorded according to the check result to obtain the record information, including: At the end of each of the stages, the exit status of the RUN instruction is used to check whether the stage was successfully executed; If the execution fails, the build of the stage is stopped and the error information is captured; The current stage is marked as a failure state, and the current stage and the error information are recorded to obtain record information.

6. The cache-dependent multi-image multi-stage construction method according to claim 1, It is characterized in that The classifying based on the record information to obtain an error classification result, and generating a structured error report according to the error classification result, includes: Identify the error type, error time, error location and error cause of the recorded information; Classify the recorded information according to the error type, the error time, the error location and the error cause to obtain an error classification result; Analyze the recorded information according to the error type, the error time, the error location and the error cause to obtain an error analysis result; A structured error report is generated according to the error classification result and the error analysis result, wherein the error report includes error type information, occurrence time information, affected construction phase information, possible cause information and repair suggestion information.

7. The cache-dependent multi-image multi-stage construction method according to claim 1, It is characterized in that After classifying based on the record information to obtain an error classification result and generating a structured error report according to the error classification result, the method further includes: Sending the error report to a management terminal so that the management terminal generates and displays a report page based on the error report; Creating a repair listener, and using the repair listener to monitor the repair information corresponding to the error information; When the repair listener listens to the repair information, the current repair information is obtained; Merging the repair information with the corresponding error information to obtain merged information; The combined information is encrypted to obtain encrypted information, and the encrypted information is uploaded to the blockchain.

8. A cache-dependent multi-image multi-stage construction device, It is characterized in that include: Obtaining a parsing module, used to obtain a project configuration file, and parse all the dependency packages required for the project at each stage from the cache according to the project configuration file; Select a building module, which is used to select a base image, and use different dependency packages of each stage to build multiple Docker images with the base image as the starting point; Specify an execution module, which is used to specify the corresponding Docker image for each stage, and execute the construction of each stage according to the Docker image; A checking and recording module is used to perform error checking at the end of each stage and record error information according to the checking result to obtain record information; The classification generation module is used to perform classification based on the record information to obtain an error classification result, and generate a structured error report according to the error classification result.

9. A cache-dependent multi-image multi-stage build device, It is characterized in that The cache-dependent multi-image multi-stage construction device includes: a memory and at least one processor, wherein instructions are stored in the memory; At least one of the processors calls the instructions in the memory to enable the cache-dependent multi-image multi-stage construction device to perform each step of the cache-dependent multi-image multi-stage construction method as described in any one of claims 1-7.

10. A computer-readable storage medium having instructions stored thereon, It is characterized in that When the instructions are executed by the processor, the steps of the cache-dependent multi-image multi-stage construction method as described in any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • NPM packet offline deployment method and apparatus, and electronic device

    CN119376747A

  • File management method and device

    CN121597651A