Application mirror image creating method and device, server, medium and product
By judging and using basic dependency images to build application images during the container deployment and running process, the problem of low applicable scope of the existing technology is solved, and the image creation suitable for containers other than those that support directory loading is realized, which improves the applicable scope and reduces the cost of loading. Storage space occupied.
Patent Information
- Application Number
- CN202410894795.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-04
- Publication Date
- 2024-09-06
AI Technical Summary
The existing technology builds application images based on file directories, which is only applicable to containers that support directory loading, resulting in a low scope of application.
Determine whether the basic dependency image exists in the container. If it exists and has not changed, add it, the application resource file and the container startup script to the application image script file template, generate the application image script file, and build the application during the container deployment and running process. Mirror, applicable to containers except those that support directory loading.
Improves the applicability of application images and reduces the storage space occupied by application images when there are basic dependent images.
Smart Images

Figure CN118606007A
Abstract
Description
Technical Field
[0001] The present application relates to the field of big data technology, and in particular to a method, device, server, medium and product for creating an application image. Background Art
[0002] In container technology, one of the core concepts of images is resource reuse. Images can be used multiple times without having to be recreated each time, thus achieving resource reuse.
[0003] Currently, the existing technology builds application images based on file directories.
[0004] However, this method in the prior art is only applicable to containers that support directory loading, which reduces the scope of application. Summary of the invention
[0005] The present application provides a method, device, server, medium and product for creating an application image, so as to solve the problem of low application scope.
[0006] In a first aspect, the present application provides a method for creating an application image, comprising:
[0007] Create an original distribution package of the target application; decompress the original distribution package to obtain multiple application resource files; obtain the application resource files in the multiple application resource files; determine whether there is a basic dependency image in the container; if it is determined that there is a basic dependency image in the container and the basic dependency image of the target application has not changed, add the basic dependency image, the preset execution directory, the application resource file, the container startup script, and the container startup identifier to the application image script file template to generate an application image script file; save the application image script file to the application resource build directory; execute the application image script file through the build command in the application resource build directory, so that the application resource file and the container startup script are copied to the preset execution directory, and by executing the container startup script, the application resource file in the preset execution directory is compressed to obtain an application resource package; move the application resource package to the deployment directory of the container, start the container according to the container startup identifier, and during the container deployment and operation process, create an application image of the target application according to the basic dependency image and the application resource package in the container deployment directory.
[0008] In a possible design, by executing a container startup script, application resource files are compressed in a preset execution directory to obtain an application resource package; the application resource package is moved to the deployment directory of the container, and the container is started according to the container startup identifier. During the container deployment and operation process, an application image of the target application is built according to the basic dependency image and the application resource package in the deployment directory of the container, including: obtaining multiple instructions in the container startup script; the multiple instructions include compression instructions, move instructions and start instructions; according to the compression instructions, the application resource files are compressed in the preset execution directory to obtain an application resource package; according to the move instructions, the application resource package is moved to the deployment directory of the container; according to the start instruction, the container startup identifier is identified to start the container, and during the container deployment and operation process, the application image of the target application is built according to the basic dependency image and the application resource package in the deployment directory of the container.
[0009] In one possible design, obtaining an application resource file from a plurality of application resource files includes: obtaining the application resource file from the plurality of application resource files according to a directory structure of the plurality of application resource files.
[0010] In a possible design, before determining whether there is a base dependency image in the container, it also includes: obtaining a base dependency resource file in multiple application resource files; accordingly, after determining whether there is a base dependency image in the container, it also includes: if it is determined that there is no base dependency image in the container, or a base dependency image exists but the base dependency image of the target application has changed, then adding a preset base image, a preset execution directory and a base dependency resource file to a base dependency image script file template to obtain a base dependency image script file; saving the base dependency image script file to a base dependency image build directory; and in the base dependency image build directory, executing the base dependency image script file through a build command to generate a base dependency image.
[0011] In a possible design, it also includes: setting configuration information of the target application to obtain a configuration information library; wherein the configuration information library includes a preset execution directory, an application image script file template, a basic dependency image script file template, an application resource build directory, and a container deployment directory.
[0012] In a possible design, it also includes: pushing the basic dependency image and the application image to the enterprise private image warehouse, and setting the warehouse address of the enterprise private image warehouse in the configuration file of the target application.
[0013] In a second aspect, the present application provides a device for creating an application image, comprising:
[0014] A first creation module, used to create an original distribution package of a target application;
[0015] A decompression module, used for decompressing the original distribution package to obtain multiple application resource files;
[0016] An acquisition module, used for acquiring an application resource file from a plurality of application resource files;
[0017] The judgment module is used to determine whether the basic dependent image exists in the container;
[0018] A generation module, for adding the basic dependency image, the preset execution directory, the application resource file, the container startup script, and the container startup identifier to the application image script file template to generate an application image script file if it is determined that the basic dependency image exists in the container and the basic dependency image of the target application has not changed;
[0019] The save module is used to save the application image script file to the application resource build directory;
[0020] The second creation module is used to execute the application image script file through the build command in the application resource build directory, so that the application resource files and the container startup script are copied to the preset execution directory, and the application resource files are compressed in the preset execution directory by executing the container startup script to obtain the application resource package; the application resource package is moved to the deployment directory of the container, and the container is started according to the container startup identifier. During the container deployment and operation process, the application image of the target application is created according to the basic dependency image and the application resource package in the deployment directory of the container.
[0021] In a third aspect, an embodiment of the present application provides a server, comprising: at least one processor and a memory; the memory stores computer execution instructions; the at least one processor executes the computer execution instructions stored in the memory, so that the at least one processor executes the method for creating an application image as described in the first aspect and various possible designs of the first aspect.
[0022] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer execution instructions are stored. When a processor executes the computer execution instructions, the method for creating an application image as described in the first aspect and various possible designs of the first aspect is implemented.
[0023] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements the method for creating an application image as described in the first aspect and various possible designs of the first aspect.
[0024] The application image creation method, device, server, medium and product provided by the present application, if there is a basic dependent image, the basic dependent image, the preset execution directory, the application resource file, the container startup script and the container startup identifier are added to the application image script file template to generate an application image script file. The application image script file is executed by building a command, so that the application resource file and the container startup script are copied to the preset execution directory, and the application resource file is compressed into an application resource package by executing the container startup script. During the container deployment and operation process, the application image is built according to the basic image and the application resource package. This method is applicable to containers other than containers that support directory loading, which increases the scope of application. In addition, if there is a basic dependent image, the basic dependent image is set as the basic image to avoid adding the basic dependent resource file to the application image construction process, thereby reducing the storage space occupied by the application image. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0026] Figure 1 A schematic diagram of an application scenario of a method for creating an application image according to an embodiment of the present application;
[0027] Figure 2 A flowchart of a method for creating an application image provided by an embodiment of the present application;
[0028] Figure 3 A schematic diagram of the structure of an application image creation device provided in an embodiment of the present application;
[0029] Figure 4 A schematic diagram of the structure of a server provided in an embodiment of the present application.
[0030] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0031] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0032] It should be noted that in the technical solution of this application, the collection, storage, use, processing, transmission, provision and disclosure of information such as financial data or user data involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals. The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards, and provide corresponding operation entrances for users to choose to authorize or refuse. It should be noted that in the embodiments of this application, some existing solutions in the industry such as certain software, components, models, etc. may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of the implementation of the technical solution of this application, but it does not mean that the applicant has or will necessarily use the solution.
[0033] In container technology, one of the core concepts of images is resource reuse. Images can be used multiple times without having to be recreated each time, thus achieving resource reuse. Currently, the existing technology builds application images based on file directories. However, this method of the existing technology is only applicable to containers that support directory loading, which reduces the scope of application.
[0034] In view of the above technical problems, the present application proposes the following technical concept: Considering that the construction of application images based on the file directory method cannot be applied to containers other than those that support directory loading, resulting in a low scope of application. The inventor thought of building an application image during the container deployment and operation process. By judging whether there is a basic dependency image in the container, if there is a basic dependency image, the basic dependency image, the preset execution directory, the application resource file, the container startup script and the container startup identifier are added to the application image script file template to generate an application image script file. The application image script file is executed by building a command, so that the application resource file and the container startup script are copied to the preset execution directory, and the application resource file is compressed in the preset execution directory by executing the container startup script to obtain an application resource package; the application resource package is moved to the deployment directory of the container, and the container is started according to the container startup identifier. During the container deployment and operation process, the application image of the target application is constructed according to the application resource package in the deployment directory of the container and the basic dependency image, thereby improving the scope of application.
[0035] Figure 1 Schematic diagram of an application scenario of the method for creating an application image provided in an embodiment of the present application. Figure 1 As shown, the application scenario includes: a server 10 and an enterprise private image repository 20;
[0036] The server 10 includes a construction service device 101, a file processing service device 102, an execution service device 103 and a configuration information library 104. The construction service device 101 is used to create an original distribution package of the target application, and send it to the file processing service device 102 for decompression to obtain the application resource file; the execution service device 103 determines whether there is a basic dependent image in the container, and builds the application image according to the determination result; the configuration information library 104 sets the configuration information of the target application.
[0037] The server 10 pushes the created application image to the enterprise private image repository 20 for storage.
[0038] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0039] Figure 2 This is a flowchart of a method for creating an application image provided by an embodiment of the present application. The execution subject of this embodiment may be Figure 1 The server in the embodiment shown may also be other devices with similar functions, and this embodiment is not particularly limited here. Figure 2 As shown, the method includes:
[0040] S201: Creating an original distribution package of a target application.
[0041] In this embodiment, all resources of the target application are packaged into one file, including all codes, configuration files, and static resources of the application.
[0042] Optionally, these files and resources can be compressed into a raw distribution package by a build tool, without limitation.
[0043] Optionally, the original distribution package in war format.
[0044] In this embodiment, the configuration information library is used to record the process configurable information of the whole process to guide the operation of the entire application image creation method. Specifically, the configuration information of the target application is set to obtain the configuration information library; wherein the configuration information library includes a preset execution directory, an application image script file template, a basic dependency image script file template, an application resource construction directory, and a container deployment directory.
[0045] In this embodiment, the configuration information repository also includes the name and version number of the original distribution package, such as: demo1.0.war.
[0046] S202: Decompress the original distribution package to obtain multiple application resource files.
[0047] In this embodiment, in order to access the content in the original distribution package, it needs to be decompressed and restored to the original file. The distribution package is decompressed using a decompression tool, and the decompression target directory is specified so that these application resource files can be easily accessed in subsequent steps.
[0048] S203: Acquire an application resource file from a plurality of application resource files.
[0049] Specifically, according to the directory structure of the multiple application resource files, the application resource files among the multiple application resource files are obtained.
[0050] In this embodiment, the directory structure of the multiple application resource files obtained after decompression includes WEB-INF, META-INF and other resources or directories. Among them, the files under WEB-INF / lib are basic dependency resource files, and the files other than the basic dependency resource files are application resource files.
[0051] S204: Determine whether there is a basic dependent image in the container.
[0052] In this embodiment, before building a new application image, it is checked whether a basic dependency image that can be used as a basis already exists in the container. If it exists and the version is appropriate, there is no need to rebuild the basic dependency image.
[0053] S205: If it is determined that a basic dependency image exists in the container and the basic dependency image of the target application has not changed, the basic dependency image, the preset execution directory, the application resource file, the container startup script, and the container startup identifier are added to the application image script file template to generate an application image script file.
[0054] The application image script file includes multiple command lines, each of which includes an instruction.
[0055] Specifically, use the application image script file template in the configuration information library. Fill in the basic dependency image, preset execution directory, application resource file, container startup script, and container startup identifier into the template to generate an application image script file. The application image script file contains multiple command lines, each of which contains an instruction keyword.
[0056] In this embodiment, the instruction keyword FROM is used to generate a command line that sets the base dependency image as the base image for building the application image; the instruction keyword WORKDIR is used to generate a command line that sets the preset execution directory as the working directory; the instruction keyword COPY is used to generate a command line that copies the application resource files and the container startup script to the preset execution directory; the instruction keyword ENTRYPOINT is used to generate a command line that sets the container startup identifier to the entry identifier of the container startup script to obtain the application image script file.
[0057] S206: Save the application image script file to the application resource construction directory.
[0058] S207: Execute the application image script file through the build command in the application resource build directory, so that the application resource files and the container startup script are copied to the preset execution directory, and the application resource files are compressed in the preset execution directory by executing the container startup script to obtain an application resource package; move the application resource package to the deployment directory of the container, start the container according to the container startup identifier, and during the container deployment and operation process, create an application image of the target application according to the basic dependency image and the application resource package in the deployment directory of the container.
[0059] In this embodiment, through the build command, the application image script file is searched in the application resource build directory, and then the application image script file is executed.
[0060] Specifically, multiple instructions in the container startup script in the application image script file are obtained; the multiple instructions include compression instructions, move instructions and startup instructions; according to the compression instructions, the application resource files are compressed in the preset execution directory to obtain an application resource package; according to the move instructions, the application resource package is moved to the deployment directory of the container; according to the startup instructions, the container startup identifier is identified to start the container, and during the container deployment and operation process, the application image of the target application is built according to the basic dependency image and the application resource package in the deployment directory of the container.
[0061] Exemplarily, based on the basic image of tomcat, the file with the file name or directory path of demo is compressed into demo.war through the zip command; demo.war is moved to the deployment directory of tomcat through the mv command; and the container is started through the sh command.
[0062] It can be seen from the description of the above embodiment that if there is a basic dependent image, the basic dependent image, the preset execution directory, the application resource file, the container startup script and the container startup identifier are added to the application image script file template to generate an application image script file. The application image script file is executed by building a command, so that the application resource file and the container startup script are copied to the preset execution directory, and the application resource file is compressed into an application resource package by executing the container startup script. During the container deployment and operation process, the application image is built according to the basic image and the application resource package. This method can be applied to containers other than containers that support directory loading, which increases the scope of application. In addition, if there is a basic dependent image, the basic dependent image is set as the basic image to avoid adding the basic dependent resource file to the application image construction process, thereby reducing the storage space occupied by the application image.
[0063] In another embodiment of the present application, based on the above embodiment, the situation where the basic dependent image does not exist in the container is described in detail. The execution subject of this embodiment can be Figure 1 The server in the illustrated embodiment may also be other devices with similar functions, which are not particularly limited in this embodiment, and specifically include:
[0064] S301: Obtain a basic dependent resource file from a plurality of application resource files.
[0065] Specifically, according to the directory structure of the multiple application resource files, the basic dependent resource files in the multiple application resource files are obtained.
[0066] In this embodiment, the directory structure of the multiple application resource files obtained after decompression includes WEB-INF, META-INF and other resources or directories, wherein the basic dependent resource files are under WEB-INF / lib.
[0067] S302: If it is determined that there is no base dependency image in the container, or a base dependency image exists but the base dependency image of the target application has changed, the preset base image, the preset execution directory and the basic dependency resource file are added to the basic dependency image script file template to obtain the basic dependency image script file.
[0068] The basic dependency image script file contains multiple command lines, each of which contains an instruction.
[0069] Specifically, the basic dependency image script file template in the configuration information library is used. Information such as the preset basic image, the preset execution directory, and the basic dependency resource file are filled into the template to generate a basic dependency image script file. The basic dependency image script file contains multiple command lines, each of which contains an instruction keyword.
[0070] In this embodiment, the instruction keyword FROM is used to generate a command line for setting the preset base image as the base image for building the base dependent image; the instruction keyword WORKDIR is used to generate a command line for setting the preset execution directory as the working directory; the instruction keyword COPY is used to generate a command line for copying the basic dependent resource file to the preset execution directory to obtain the basic dependent image script file.
[0071] S303: Save the basic dependency image script file to the basic dependency image building directory;
[0072] S304: In the base dependency image building directory, execute the base dependency image script file through the building command to generate the base dependency image.
[0073] In this embodiment, the base dependency image script file is searched in the base dependency image build directory through the build command, and the base dependency image is generated by executing the base dependency image script file. The version number of the generated base dependency image is also set in the configuration information library.
[0074] Optionally, the basic dependency image and the application image are pushed to the enterprise private image repository, and the repository address of the enterprise private image repository is set in the configuration file of the target application.
[0075] In summary, it can be seen that the basic dependency image is built only when it is determined that the basic dependency image does not exist in the container, and the basic dependency resource files are avoided from being added to the process of building the application image when the basic dependency image exists, thereby reducing the storage space occupied by the application image.
[0076] In another embodiment of the present application, based on the above embodiment, the configuration information library is described in detail. The execution subject of this embodiment can be Figure 1 The server in the illustrated embodiment may also be other devices with similar functions, which are not particularly limited in this embodiment, and specifically include:
[0077] Set the configuration information of the target application to obtain a configuration information library. Set the configuration information of the target application to obtain a configuration information library; the configuration information library includes a preset execution directory, an application image script file template, a basic dependency image script file template, an application resource build directory, and a container deployment directory.
[0078] Among them, the configuration information library records the configurable information of the entire process, including the naming and version number of the original distribution package for creating the target application, the save path after the original distribution package is decompressed, the application resource files and the naming and version numbers of the application resource files, and the basic dependent resource files and the naming and version numbers of the basic dependent resource files.
[0079] Optionally, the configuration information repository is configured with creation content, including a basic dependency image and an application image. The application image is a required build content, and the basic dependency image can select an existing image dependency.
[0080] Optionally, the configuration information repository is configured with the name and version number of the created basic dependency image and the name and version number of the created application image.
[0081] Optionally, the configuration information repository is configured with resource names used when creating a basic dependency image and directories corresponding to the resource names.
[0082] Optionally, the base image used when building the base dependency image, that is, the preset base image mentioned in the above embodiment, needs to be configured in the configuration information library. Optionally, the preset base image can be set to a TOMCAT base image.
[0083] In summary, by setting up a configuration information library, on the one hand, it is possible to avoid management confusion and errors caused by decentralized storage of configuration information; on the other hand, the configuration information library guides the entire process and, as part of the automation process, can avoid human configuration errors.
[0084] Figure 3 A schematic diagram of the structure of the device for creating an application image provided in an embodiment of the present application. Figure 3 As shown, the device for creating an application image includes: a first creation module 301 , a decompression module 302 , an acquisition module 303 , a judgment module 304 , a generation module 305 , a storage module 306 and a second creation module 307 .
[0085] The first creation module 301 is used to create an original distribution package of the target application.
[0086] The decompression module 302 is used to decompress the original distribution package to obtain multiple application resource files.
[0087] The acquisition module 303 is used to acquire an application resource file from a plurality of application resource files.
[0088] The determination module 304 is used to determine whether there is a basic dependent image in the container.
[0089] The generation module 305 is used to add the basic dependency image, the preset execution directory, the application resource file, the container startup script, and the container startup identifier to the application image script file template to generate an application image script file if it is determined that there is a basic dependency image in the container and the basic dependency image of the target application has not changed.
[0090] The saving module 306 is used to save the application image script file to the application resource construction directory.
[0091] The second creation module 307 is used to execute the application image script file through the build command in the application resource build directory, so that the application resource files and the container startup script are copied to the preset execution directory, and the application resource files are compressed in the preset execution directory by executing the container startup script to obtain an application resource package; the application resource package is moved to the deployment directory of the container, and the container is started according to the container startup identifier. During the container deployment and operation process, the application image of the target application is created according to the basic dependency image and the application resource package in the deployment directory of the container.
[0092] The device provided in this embodiment can be used to execute the technical solution of the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be repeated here.
[0093] In one possible design, the second creation module 307 is specifically used to: obtain multiple instructions in the container startup script; wherein the multiple instructions include compression instructions, move instructions and startup instructions; according to the compression instructions, compress the application resource files in a preset execution directory to obtain an application resource package; according to the move instructions, move the application resource package to the deployment directory of the container; according to the startup instructions, identify the container startup identifier to start the container, and during the container deployment and operation process, build the application image of the target application according to the basic dependency image and the application resource package in the deployment directory of the container.
[0094] In a possible design, the acquisition module 303 is specifically used to: acquire application resource files from multiple application resource files according to the directory structure of the multiple application resource files.
[0095] In one possible design, a basic dependency resource file is obtained from multiple application resource files. Accordingly, the judgment module 304 is also used to: if it is determined that there is no basic dependency image in the container, or a basic dependency image exists but the basic dependency image of the target application has changed, then add the preset basic image, the preset execution directory and the basic dependency resource file to the basic dependency image script file template to obtain the basic dependency image script file; save the basic dependency image script file to the basic dependency image build directory; and execute the basic dependency image script file through the build command in the basic dependency image build directory to generate the basic dependency image.
[0096] In one possible design, the application image creation device also includes: a setting module, which is used to set the configuration information of the target application to obtain a configuration information library; wherein the configuration information library includes a preset execution directory, an application image script file template, a basic dependency image script file template, an application resource build directory, and a container deployment directory.
[0097] In a possible design, the application image creation device also includes: a push module, which is used to push the basic dependency image and the application image to the enterprise private image warehouse, and set the warehouse address of the enterprise private image warehouse in the configuration file of the target application.
[0098] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software called by processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software called by processing elements, and some modules can be implemented in the form of hardware. Each module can be a separately established processing element, or it can be integrated in a chip of the above device. In addition, it can also be stored in the memory of the above device in the form of program code, and called and executed by a processing element of the above device. The functions of each module. In addition, all or part of these modules can be integrated together, or they can be implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
[0099] Figure 4 This is a schematic diagram of the structure of the server provided in the embodiment of the present application. Figure 4 As shown, the server may include: a transceiver 401 , a processor 402 , and a memory 403 .
[0100] The processor 402 executes the computer execution instructions stored in the memory, so that the processor 402 executes the scheme in the above embodiment. The processor 402 can be a general-purpose processor, including a central processing unit CPU, a network processor (network processor, NP), etc.; it can also be a digital signal processor DSP, an application-specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0101] The memory 403 is connected to the processor 402 via a system bus and completes communication between them. The memory 403 is used to store computer program instructions.
[0102] The system bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The transceiver is used to realize the communication between the database access device and other computers (such as clients, read-write libraries, and read-only libraries). The memory may include random access memory (RAM) and may also include non-volatile memory.
[0103] The embodiment of the present application also provides a chip for running instructions, which is used to execute the technical solution of the method for creating an application image in the above embodiment.
[0104] An embodiment of the present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the method for creating an application image of any one of the first aspects.
[0105] An embodiment of the present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. At least one processor can read the computer program from the computer-readable storage medium. When the at least one processor executes the computer program, the technical solution of the method for creating an application image in the above embodiment can be implemented.
[0106] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0107] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to implement the solution of this embodiment.
[0108] In addition, each functional module in each embodiment of the present application can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit. The above-mentioned module-composed unit can be implemented in the form of hardware or in the form of hardware plus software functional units.
[0109] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the methods of various embodiments of the present application.
[0110] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.
[0111] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.
[0112] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.
[0113] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.
[0114] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the storage medium can also exist as discrete components in an electronic control unit or a main control device.
[0115] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0116] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for creating an application image, characterized in that: Applicable to servers, including: Create an original distribution package of the target application; Decompressing the original distribution package to obtain multiple application resource files; Acquire an application resource file from the multiple application resource files; Determine whether the basic dependent image exists in the container; If it is determined that the basic dependency image exists in the container and the basic dependency image of the target application has not changed, then the basic dependency image, the preset execution directory, the application resource file, the container startup script, and the container startup identifier are added to the application image script file template to generate an application image script file; Save the application image script file to the application resource construction directory; The application image script file is executed by a build command in the application resource build directory, so that the application resource file and the container startup script are copied to the preset execution directory, and the application resource file is compressed in the preset execution directory by executing the container startup script to obtain an application resource package; the application resource package is moved to the deployment directory of the container, and the container is started according to the container startup identifier. During the container deployment and operation process, the application image of the target application is created according to the basic dependency image and the application resource package in the deployment directory of the container.
2. The method according to claim 1, characterized in that The container startup script is executed so that the application resource file is compressed in the preset execution directory to obtain an application resource package; The application resource package is moved to the deployment directory of the container, the container is started according to the container startup identifier, and during the container deployment and operation process, the application image of the target application is built according to the basic dependency image and the application resource package in the deployment directory of the container, including: Obtain multiple instructions in the container startup script; wherein the multiple instructions include compression instructions, move instructions and startup instructions; According to the compression instruction, compressing the application resource file in the preset execution directory to obtain an application resource package; According to the move instruction, move the application resource package to the deployment directory of the container; According to the startup instruction, the container startup identifier is identified to start the container. During the container deployment and operation process, the application image of the target application is built according to the basic dependency image and the application resource package under the deployment directory of the container.
3. The method according to claim 1, characterized in that The obtaining of the application resource file among the multiple application resource files comprises: According to the directory structure of the multiple application resource files, the application resource file among the multiple application resource files is obtained.
4. The method according to claim 1, characterized in that: Before determining whether the basic dependent image exists in the container, the method further includes: Obtaining a basic dependent resource file from the multiple application resource files; Accordingly, after determining whether the basic dependent image exists in the container, the method further includes: If it is determined that the basic dependency image does not exist in the container, or the basic dependency image exists but the basic dependency image of the target application has changed, then the preset basic image, the preset execution directory and the basic dependency resource file are added to the basic dependency image script file template to obtain a basic dependency image script file; Save the basic dependency image script file to the basic dependency image build directory; In the base dependency image building directory, the base dependency image script file is executed by a building command to generate the base dependency image.
5. The method according to claim 4, characterized in that Also includes: Setting the configuration information of the target application to obtain a configuration information library; The configuration information library includes the preset execution directory, the application image script file template, the basic dependency image script file template, the application resource construction directory and the container deployment directory.
6. The method according to any one of claims 1 to 5, characterized in that: Also includes: The basic dependency image and the application image are pushed to the enterprise private image warehouse, and the warehouse address of the enterprise private image warehouse is set in the configuration file of the target application program.
7. A device for creating an application image, characterized in that: Applicable to servers, including: A first creation module, used to create an original distribution package of a target application; A decompression module, used for decompressing the original distribution package to obtain a plurality of application resource files; An acquisition module, used for acquiring an application resource file from the multiple application resource files; The judgment module is used to determine whether the basic dependent image exists in the container; A generation module, configured to add the basic dependency image, the preset execution directory, the application resource file, the container startup script, and the container startup identifier to an application image script file template to generate an application image script file if it is determined that the basic dependency image exists in the container and the basic dependency image of the target application has not changed; A saving module, used to save the application image script file to the application resource construction directory; The second creation module is used to execute the application image script file through the build command in the application resource build directory, so that the application resource file and the container startup script are copied to the preset execution directory, and the application resource file is compressed in the preset execution directory by executing the container startup script to obtain an application resource package; the application resource package is moved to the deployment directory of the container, and the container is started according to the container startup identifier. During the container deployment and operation process, the application image of the target application is created according to the basic dependency image and the application resource package in the deployment directory of the container.
8. A server, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method for creating an application image according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method for creating an application image according to any one of claims 1 to 6.
10. A computer program product, characterized in that The invention comprises a computer program, which, when executed by a processor, implements the method for creating an application image according to any one of claims 1 to 6.
