Mirror image packaging method and device, equipment and medium

By building Docker images in stages of project source code and dependency packages, using Docker's caching mechanism and hierarchical file system, the problem of slow image construction speed in the existing technology is solved, and a faster image construction and push process is achieved.

CN119902778APending Publication Date: 2025-04-29SHENZHEN QIANHAI EVOC ASIA-PACIFIC ELECTRONIC EQUIP TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411990540.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-04-29

AI Technical Summary

Technical Problem

In the prior art, Docker image construction speed is slower, and the larger the image file, the slower the upload speed to the image repository.

Method used

By building images in stages of project source code and dependency package, package the project source code and dependency package images respectively, and push them to the mirror repository. This method makes full use of Docker's caching mechanism and hierarchical file system, reducing the amount of data that needs to be transferred.

Benefits of technology

By separating image packaging, using Docker's caching mechanism and hierarchical file system, the speed of image construction and push is significantly accelerated, and the time and cost of network transmission is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119902778A_ABST
    Figure CN119902778A_ABST
Patent Text Reader

Abstract

The mirror image packaging method, device and equipment and the medium provided by the invention are used for mirror image packaging of an application container engine Docker, and the method comprises the following steps: obtaining a project source code and a dependency package from a to-be-packaged program, the dependency package being used for introducing a preset function of a third-party library; respectively carrying out mirror image packaging on the project source code and the dependency package; and pushing the project source code and the dependency package after mirror image packaging to a mirror image warehouse. Due to the fact that the project source code and the dependent package are separated and respectively packaged and pushed, whether an input file of each copy command is changed or not is checked by fully utilizing a cache mechanism of the Docker, and if some layers of the mirror image are not changed, the Docker skips the layers and only uploads the changed layers during pushing. Therefore, the time and cost of network transmission can be reduced, the use of network bandwidth can be reduced, and the pushing process of the mirror image can be accelerated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of software technology, and in particular to an image packaging method, device, equipment and medium. Background Art

[0002] Docker is an open source containerization technology that allows developers to package applications and their dependencies into a lightweight, portable container, and then run the container on any machine that supports Docker. Docker containers can run in a variety of environments, including virtual machines, physical machines, and cloud platforms, greatly improving the flexibility and efficiency of software deployment.

[0003] Among them, Docker images are the basic building blocks of Docker containers. These images are lightweight, read-only encapsulation units that contain everything to start an independent process - applications, runtimes, libraries, environment variables, and configuration files. Image repository, a repository is a centralized place to store images, similar to a code repository. It can be public or private.

[0004] In the prior art, the compiled source code files of the project and all related dependent jar files are packaged into a jar package, and the packaged jar files are directly copied to the image working directory using the copy command when building the Docker image. This method has a slow image building speed, and the larger the image file, the slower the upload speed to the image repository.

[0005] Therefore, the above problems existing in the prior art have yet to be solved. Summary of the invention

[0006] The embodiments of the present invention provide an image packaging method, apparatus, device and medium, which aim to solve the problem of slow Docker image building speed in the prior art by building images in stages based on project source code and dependent packages.

[0007] In a first aspect, an embodiment of the present invention provides an image packaging method for image packaging of an application container engine Docker, which includes:

[0008] Obtain project source code and dependency packages from the program to be packaged, where the dependency packages are used to introduce preset functions;

[0009] Mirror and package the project source code and the dependent packages respectively;

[0010] The project source code and the dependent packages after image packaging are pushed to the image warehouse.

[0011] In a second aspect, an embodiment of the present invention further provides an image packaging device for image packaging of an application container engine Docker, which includes:

[0012] An acquisition unit, used to acquire project source code and dependency packages from the program to be packaged, wherein the dependency packages are used to introduce preset functions of a third-party library;

[0013] A packaging unit, used to respectively mirror and package the project source code and the dependent package acquired by the acquisition unit;

[0014] The pushing unit is used to push the project source code and the dependent package after the packaging unit image is packaged to the image warehouse.

[0015] In a third aspect, an embodiment of the present invention further provides a computer device, which includes a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the method described in the first aspect is implemented.

[0016] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the method described in the first aspect above can be implemented.

[0017] The embodiment of the present invention provides an image packaging method, device, equipment and medium for image packaging of an application container engine Docker, the method comprising: obtaining a project source code and a dependency package from a program to be packaged, the dependency package being used to introduce preset functions of a third-party library; mirroring and packaging the project source code and the dependency package respectively; and pushing the mirrored project source code and the dependency package to an image warehouse. Since the project source code and the dependency package are packaged independently, the cache mechanism of Docker is fully utilized to check whether the input file of each copy command has changed. If the input file has not changed, the corresponding layer will be cached, and there is no need to re-execute the instruction. Since the project source code and the dependency package are separately packaged and pushed, the amount of data required for image push transmission can be reduced. If some layers of the image have not changed, Docker will skip these layers when pushing, and only upload those layers that have changed. This helps to reduce the time and cost of network transmission, reduce the use of network bandwidth, and speed up the image push process. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.

[0019] Figure 1 A flowchart of an embodiment of the image packaging method provided by the present invention;

[0020] Figure 2 A flowchart of another embodiment of the image packaging method provided by the present invention;

[0021] Figure 3 A flowchart of another embodiment of the image packaging method provided by the present invention;

[0022] Figure 4 A schematic diagram of the image packaging device provided by the present invention;

[0023] Figure 5 The present invention is a schematic block diagram of a computer device provided by the present invention. DETAILED DESCRIPTION

[0024] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0025] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0026] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0027] It should be further understood that the term "and / or" used in the present description and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.

[0028] See also Figure 1 The image packaging method provided in the embodiment of the present application includes the following steps.

[0029] S110. Obtain project source code and dependent packages from the program to be packaged.

[0030] In this embodiment, the program to be packaged is a program file that needs to be packaged into the image repository. The program file includes two parts: the project source code and the dependency package. The dependency package is also called the dependency jar package, which is a commonly used concept in Java development and is mainly used to introduce preset functions provided by third-party libraries or frameworks to develop applications faster. The dependency jar package is a file in the Java Archive (JAR) format, containing Java class files, resource files, and metadata. It is usually used to package a group of related class and resource files into one file for easy sharing and use in different projects.

[0031] S120, mirror-package the project source code and the dependent packages respectively.

[0032] In this embodiment, the project source code and dependent packages are packaged separately. The advantage of this method over the overall packaging is that it makes full use of Docker's cache mechanism. During the image packaging process, Docker will check whether the input file of each instruction is the same as the last build. If the input file has not changed, Docker will reuse this layer from the cache instead of re-executing the instruction. As a result, during the project construction process, if only one of the project source code and the dependent package changes, only the changed part needs to be packaged in the image, and the entire project does not need to be repackaged in the image, thereby improving the speed of image packaging.

[0033] Alternatively, if Figure 2 As shown, S120 specifically includes the following steps:

[0034] S121. Pack the compiled files of the project source code into a first executable archive file package.

[0035] In this embodiment, the first executable archive file package is specifically a JAR package. A JAR file (Java ARchive) is an archive file used to package multiple Java class files, metadata, and resources, and usually has a .jar file extension. JAR files are built using the ZIP file format and are mainly used to distribute and deploy Java applications, libraries, plug-ins, or frameworks. JAR files contain not only Java class files, but may also contain related metadata and resource files, such as text, images, etc.

[0036] Specifically in the present application, the first executable archive file package is used to package the files compiled from the project source code, and the file name can be recorded as app.jar.

[0037] S122, copying the dependent package to the mirror directory.

[0038] In this embodiment, the image directory is the Docker image directory, which is the location used by the Docker engine to store image files. Its functions include storing image files, managing image files, and supporting image building.

[0039] Alternatively, if Figure 3 As shown, the mirror directory is an independent directory lib. Based on this, S122 specifically includes the following steps:

[0040] S1221. Set the independent directory lib as the working directory of the program to be packaged.

[0041] In this embodiment, the independent directory lib generally refers to a component of the " / lib" directory in the Linux system or the Docker data directory. However, in the context of Docker, it is more common to refer to directories related to Docker data storage.

[0042] S1222. Copy the project object model pom of the program to be packaged into the working directory.

[0043] In this embodiment, the full name of the pom file is Project Object Model, which is one of the core files of the project. It defines the basic information, dependencies, build configuration, etc. of the project. The pom file is an XML file, usually located in the root directory of the project, and the file name is pom.xml. In the solution of this application, the pom file specifies the dependency packages, specifically, the pom file specifies the dependency packages required by the project, including their groupId, artifactId, version, etc.

[0044] S1223. Copy the dependent package specified by the pom to the independent directory lib.

[0045] In this embodiment, the independent directory lib records the dependent packages specified by the pom file. Therefore, in the subsequent image packaging and pushing process, if the project's pom file does not change, it means that the dependent packages will not change. Therefore, when these dependent packages are copied to the lib directory in the Docker image, if they do not change, the corresponding copy instruction will also reuse the previous layer from the cache. This reduces the file size of the image packaging and improves the image speed.

[0046] Optionally, the above step S1223 can be executed by a plug-in execution command Maven. The main function of the Maven plug-in execution command is to automate various tasks in the construction process, including compiling code, running tests, packaging and deploying applications, etc. The Maven plug-in can execute corresponding tasks in a specific construction phase by binding to the Maven life cycle phase, thereby simplifying and automating these processes.

[0047] In some embodiments, S1223 specifically includes the following steps:

[0048] (1) Get the plug-in execution command maven.

[0049] (2) Maven downloads the dependent packages from the local repository or remote repository according to the dependent packages listed in the pom file.

[0050] In this embodiment, the pom file is where the dependency packages are declared and configured. It tells Maven which dependency packages the project needs, as well as the versions and scopes of these dependency packages. Maven parses and downloads the dependencies to the local repository based on the configuration of the pom file.

[0051] (3) Copy the dependency package downloaded by Maven to the independent directory lib.

[0052] In this embodiment, during the Docker image building process, the parsed and downloaded dependencies are copied from the local repository to the lib directory of the Docker image through the Maven plugin. As a result, when the Docker container is running, the project can load the required dependency packages from the lib directory without having to download them from the external repository. In this embodiment, the pom file is the configuration source of the dependency package, the lib directory is the storage location of the dependency package, and the dependency package itself is an external library or framework required for the project to run. These three together ensure the correct operation of the project in the Docker container.

[0053] The above steps complete the steps of copying the dependent packages to the image directory. On this basis, the following steps are further disclosed.

[0054] S123: Copy the first executable archive file package to the mirror directory.

[0055] In this embodiment, as mentioned above, the first executable archive file package is app.jar. This step is a specific operation in the Docker image building process, which is executed based on the instructions in the Dockerfile. By copying app.jar to the image directory, it is ensured that when the container is started from the image, app.jar will exist in the working directory of the container and can be executed. This step is completed based on the app.jar generated in the previous step and the dependent environment prepared in the previous step. The above steps together constitute the process of packaging the project into a Docker image and preparing to run in the container.

[0056] Optionally, the copying step in the above step S123 can be completed by using a copy command.

[0057] S130: Set the first executable archive file package in the image directory to a preset path.

[0058] In this embodiment, this step is a step of modifying the startup command.

[0059] Optionally, the program to be packaged is a JAVA program, and this step includes: setting the first executable archive file package in the image directory to the JAVA class path. This step is a bridge connecting all the above steps, and it tells the Java Virtual Machine (JVM) where to find the application code and the libraries it depends on. Without this step, even if the app.jar and lib directories are in the image, the JVM does not know how to load them, so the application cannot run.

[0060] The above steps S110 to S130 are the complete process of packaging the docker image. After completing the above steps, further complete the following steps:

[0061] S140: Push the project source code and the dependent packages after image packaging to the image repository.

[0062] In this embodiment, the source code and dependency packages of the project are mirrored and packaged separately and pushed to the image repository. When the image push is executed, Docker will check which layers are new or have changed, and only upload these layers. Since most of the layers may not change (especially those containing project dependency packages or basic environment settings), the amount of data pushed will be greatly reduced. This method of reducing the amount of data transmitted not only saves network bandwidth, but also speeds up the image push process, because less data needs to be uploaded, so the transmission time is also shorter. In summary, through the carefully designed Docker build and push process, the Docker cache mechanism can be fully utilized to speed up the build process, and the image push process can be accelerated and network costs can be reduced by reducing the amount of data that needs to be transmitted.

[0063] The method provided in the embodiment of the present application also has the following advantages:

[0064] 1. Separate project source code and dependent packages:

[0065] In the traditional solution, the project source code and all dependent packages are packaged into a large jar package. In the embodiment of the present application, the project source code (app.jar) and the dependent library (stored in the lib directory) are separated. The advantage of this is that when the dependent package is updated, only the corresponding jar package in the lib directory needs to be replaced, without repackaging the entire application.

[0066] 2. More flexible classpath management:

[0067] In traditional solutions, the class path is usually embedded in a large jar package, or specified by hard coding when the Docker image is built. In the embodiment of the present application, the class path is explicitly set during the Docker image construction process, which makes the management of the class path more flexible and transparent. For example, dependent packages can be easily added or deleted without repackaging the entire application.

[0068] 3. Smaller image size:

[0069] In the prior art, if multiple projects share the same dependency packages, the Docker image of each project will contain copies of these dependency packages, resulting in an increase in the image size. The embodiment of the present application allows sharing of these dependency packages between multiple different projects by placing the dependency packages in a separate lib directory, which can significantly reduce the size of the Docker image. In addition, Docker's multi-stage build can be used to further optimize the image size.

[0070] 4. Easier debugging and updating:

[0071] In the prior art, if there is a problem with the project source code, it may be necessary to decompress the entire large jar package to find and fix the problem. In the embodiment of the present application, since the project source code and the dependent package are separated, it is easier to locate and solve the problem. In addition, updating the dependent package or the project source code also becomes simpler and more direct.

[0072] 5. Better modular support:

[0073] Managing project source code and dependent packages separately helps achieve better modularity. Each module (whether it is project source code or dependent library) can be developed, tested, and deployed independently. This is especially important for large projects or projects that require long-term maintenance, as it can improve the maintainability and scalability of the code.

[0074] In summary, the solution provided by the embodiments of the present application shows significant advantages and innovations in terms of flexibility, maintainability, modular support, and image size optimization compared to the prior art.

[0075] In summary, the image packaging method provided in the embodiment of the present application includes: obtaining the project source code and the dependency package from the program to be packaged, and the dependency package is used to introduce the preset function; the project source code and the dependency package are respectively packaged by mirroring; and the project source code and the dependency package after the image packaging are pushed to the image warehouse. Since the project source code and the dependency package are packaged independently, the cache mechanism of Docker is fully utilized to check whether the input file of each copy command has changed. If the input file has not changed, the corresponding layer will be cached and there is no need to re-execute the instruction. Since the project source code and the dependency package are separately packaged and pushed, the amount of data that needs to be pushed and transmitted by the image can be reduced. If some layers of the image have not changed, then when pushing, Docker will skip these layers and only upload those layers that have changed. This helps to reduce the time and cost of network transmission, reduce the use of network bandwidth, and speed up the push process of the image.

[0076] Figure 4 The present invention also provides an image packaging device 100, which is used for image packaging of the application container engine Docker to implement the aforementioned method of the embodiment of the present application, wherein, Figure 4 As shown, the image packaging device 100 includes: an acquisition unit 110 , a packaging unit 120 and a pushing unit 130 .

[0077] The acquisition unit 110 is used to acquire project source code and dependency packages from the program to be packaged, where the dependency packages are used to introduce preset functions of a third-party library.

[0078] In this embodiment, the program to be packaged is a program file that needs to be packaged into the image repository. The program file includes two parts: the project source code and the dependency package. The dependency package is also called the dependency jar package, which is a commonly used concept in Java development and is mainly used to introduce preset functions provided by third-party libraries or frameworks to develop applications faster. The dependency jar package is a file in the Java Archive (JAR) format, containing Java class files, resource files, and metadata. It is usually used to package a group of related class and resource files into one file for easy sharing and use in different projects.

[0079] The packaging unit 120 is used to mirror and package the project source code and the dependent package obtained by the obtaining unit respectively.

[0080] In this embodiment, the project source code and dependent packages are packaged separately. The advantage of this method over the overall packaging is that it makes full use of Docker's cache mechanism. During the image packaging process, Docker will check whether the input file of each instruction is the same as the last build. If the input file has not changed, Docker will reuse this layer from the cache instead of re-executing the instruction. As a result, during the project construction process, if only one of the project source code and the dependent package changes, only the changed part needs to be packaged in the image, and the entire project does not need to be repackaged in the image, thereby improving the speed of image packaging.

[0081] The pushing unit 130 is used to push the project source code and the dependent package after the packaging unit image is packaged to the image warehouse.

[0082] In this embodiment, the source code and dependency packages of the project are mirrored and packaged separately and pushed to the image repository. When the image push is executed, Docker will check which layers are new or have changed, and only upload these layers. Since most of the layers may not change (especially those containing project dependency packages or basic environment settings), the amount of data pushed will be greatly reduced. This method of reducing the amount of data transmitted not only saves network bandwidth, but also speeds up the image push process, because less data needs to be uploaded, so the transmission time is also shorter. In summary, through a carefully designed Docker build and push process, Docker's caching mechanism can be fully utilized to speed up the build process, and the image push process can be accelerated and network costs can be reduced by reducing the amount of data that needs to be transmitted.

[0083] In one embodiment, the packaging unit 120 is specifically used for:

[0084] Packing the compiled files of the project source code into a first executable archive file package;

[0085] Copy the dependency package to the mirror directory;

[0086] The first executable archive file package is copied to the mirror directory.

[0087] In this embodiment, the first executable archive file package is specifically a JAR package. A JAR file (Java ARchive) is an archive file used to package multiple Java class files, metadata, and resources, and usually has a .jar file extension. JAR files are built using the ZIP file format and are mainly used to distribute and deploy Java applications, libraries, plug-ins, or frameworks. JAR files contain not only Java class files, but may also contain related metadata and resource files, such as text, images, etc.

[0088] Specifically in the present application, the first executable archive file package is used to package the files compiled from the project source code, and the file name can be recorded as app.jar.

[0089] In this embodiment, the image directory is the Docker image directory, which is the location used by the Docker engine to store image files. Its functions include storing image files, managing image files, and supporting image building.

[0090] In one embodiment, the mirror directory is an independent directory lib, and copying the dependent package to the mirror directory includes:

[0091] Set the independent directory lib as the working directory of the program to be packaged;

[0092] Copy the project object model pom of the program to be packaged into the working directory, wherein the pom specifies the dependent package;

[0093] Copy the dependency package specified by the pom to the independent directory lib.

[0094] In one embodiment, copying the dependent package specified by the pom to the independent directory lib includes:

[0095] Get the plugin execution command maven;

[0096] The Maven downloads the dependency package from the local warehouse or the remote warehouse according to the dependency package listed in the pom file;

[0097] Copy the dependency package downloaded by Maven to the independent directory lib.

[0098] In one embodiment, copying the first executable archive file package to the mirror directory includes:

[0099] Use the copy command to copy the first executable archive file package to the mirror directory.

[0100] In one embodiment, after the packaging unit 120, the image packaging device 100 further includes:

[0101] The first executable archive file package in the image directory is set to a preset path.

[0102] In one embodiment, the program to be packaged is a JAVA program, and the step of setting the first executable archive file package in the image directory to a preset path includes:

[0103] The first executable archive file package in the mirror directory is set to the JAVA class path.

[0104] See also Figure 5 , Figure 5 The present invention provides a schematic block diagram of a computer device provided in an embodiment of the present invention. The computer device integrates any image packaging device provided in an embodiment of the present invention.

[0105] See also Figure 5 The computer device 400 includes a processor 402 , a memory and a network interface 405 connected via a system bus 401 , wherein the memory may include a storage medium 403 and an internal memory 404 .

[0106] The storage medium 403 includes an operating system 4031 and a computer program 4032. The computer program 4032 includes program instructions, and when the program instructions are executed, the processor 402 can execute an image packaging method.

[0107] The processor 402 is used to provide computing and control capabilities to support the operation of the entire computer device.

[0108] The internal memory 404 provides an environment for the operation of the computer program 4032 in the storage medium 403. When the computer program 4032 is executed by the processor 402, the processor 402 can execute the above-mentioned intelligent dialogue implementation method based on DSL to generate SQL.

[0109] The network interface 405 is used to communicate with other devices over the network. Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present invention, and does not constitute a limitation on the computer device to which the solution of the present invention is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0110] The processor 402 is used to run the computer program 4032 stored in the memory to implement the following steps:

[0111] Obtain project source code and dependency packages from the program to be packaged, where the dependency packages are used to introduce preset functions;

[0112] Mirror and package the project source code and the dependent packages respectively;

[0113] The project source code and the dependent packages after image packaging are pushed to the image warehouse.

[0114] It should be understood that in the embodiment of the present invention, the processor 402 may be a central processing unit (CPU), and the processor 402 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0115] It can be understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing the relevant hardware through a computer program. The computer program includes program instructions, and the computer program can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiment of the above method.

[0116] Therefore, the present invention also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the processor executes the following steps:

[0117] Obtain project source code and dependency packages from the program to be packaged, where the dependency packages are used to introduce preset functions;

[0118] Mirror and package the project source code and the dependent packages respectively;

[0119] The project source code and the dependent packages after image packaging are pushed to the image warehouse.

[0120] The storage medium may be any computer-readable storage medium that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk.

[0121] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0122] In the several embodiments provided by the present invention, 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 each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.

[0123] The steps in the method of the embodiment of the present invention can be adjusted in order, combined and deleted according to actual needs. The units in the device of the embodiment of the present invention can be combined, divided and deleted according to actual needs. In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0124] 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 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, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention.

[0125] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A method for packaging images for application container engine Docker, characterized in that: include: Obtain project source code and dependency packages from the program to be packaged, where the dependency packages are used to introduce preset functions; Mirror and package the project source code and the dependent packages respectively; The project source code and the dependent packages after image packaging are pushed to the image warehouse.

2. The method according to claim 1, characterized in that The mirroring and packaging the project source code and the dependent packages respectively includes: Packing the compiled files of the project source code into a first executable archive file package; Copy the dependency package to the mirror directory; The first executable archive file package is copied to the mirror directory.

3. The method according to claim 2, characterized in that The mirror directory is an independent directory lib, and the step of copying the dependent package to the mirror directory includes: Set the independent directory lib as the working directory of the program to be packaged; Copy the project object model pom of the program to be packaged into the working directory, wherein the pom specifies the dependent package; Copy the dependency package specified by the pom to the independent directory lib.

4. The method according to claim 3, characterized in that The step of copying the dependent package specified by the pom to the independent directory lib includes: Get the plugin execution command maven; The Maven downloads the dependency package from the local warehouse or the remote warehouse according to the dependency package listed in the pom file; Copy the dependency package downloaded by Maven to the independent directory lib.

5. The method according to claim 2, characterized in that: The step of copying the first executable archive file package to the mirror directory includes: Use the copy command to copy the first executable archive file package to the mirror directory.

6. The method according to claim 2, characterized in that After the project source code and the dependent packages are mirrored and packaged respectively, the following is further included: The first executable archive file package in the image directory is set to a preset path.

7. The method according to claim 6, characterized in that The program to be packaged is a JAVA program, and the step of setting the first executable archive file package in the image directory to a preset path includes: The first executable archive file package in the mirror directory is set to the JAVA class path.

8. An image packaging device, used for image packaging of an application container engine Docker, characterized in that: include: An acquisition unit, used to acquire project source code and dependency packages from the program to be packaged, wherein the dependency packages are used to introduce preset functions of a third-party library; A packaging unit, used to respectively mirror and package the project source code and the dependent package acquired by the acquisition unit; The pushing unit is used to push the project source code and the dependent package after the packaging unit image is packaged to the image warehouse.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the image packaging method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the image packaging method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Container mirror image optimization management method and system for hierarchical multi-version extension adaptation

    CN121255223A

  • A layered multi-version extended adaptation container image optimization management method and system

    CN121255223B