Platform image construction method, device, computer equipment and storage medium

By obtaining the software installation package and basic image of the target platform, using a variety of decompression tools to process the image builder, and generating a platform image, it solves the problem that the docker image construction method needs to be compatible with multiple platforms, and achieves resource saving and fast image calling.

CN117555563BActive Publication Date: 2024-10-18GUANGZHOU DINGJIA COMPUTER TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311603203.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-28
Publication Date
2024-10-18
Estimated Expiration
2043-11-28

AI Technical Summary

Technical Problem

The existing docker image construction method needs to be compatible with multiple platforms, resulting in a waste of server resources and increased costs.

Method used

By obtaining the software installation package and basic image of the target platform, using various types of decompression tools to decompress the software installation package, and processing the image builder based on the soft link information of the image root directory to generate the platform image, and realize the construction and uploading of the platform image. Reduces the requirements on the type and quantity of server platforms.

Benefits of technology

It realizes the construction of platform images that do not need to be compatible with multiple platforms, saves resource costs, and quickly finds and calls platform images through the image list.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117555563B_ABST
    Figure CN117555563B_ABST
Patent Text Reader

Abstract

The present application provides a method, device, computer equipment and storage medium for building a platform image. The method includes: the docker server obtains the target platform corresponding to the platform image to be built, the software installation package and image builder corresponding to the target platform, and the software installation package of the target platform respectively. The software installation package is unzipped to the first target directory corresponding to each target platform, and the soft link information in the image root directory of the basic image of each target platform is processed to obtain the second target directory, and the content of the second target directory is written into the image root directory of each basic image, and finally the platform image corresponding to each target platform is obtained. The use of this method can realize that one platform image corresponds to one platform, and there is no need to be compatible with multiple platforms, which reduces the requirements for the type and number of server platforms and saves resource costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of container technology, and in particular to a method, apparatus, computer equipment, storage medium and computer program product for constructing a platform image. Background Art

[0002] With the development of big data and cloud computing technologies, container technology has emerged. Container technology is a way to achieve operating system virtualization. By using containers, application code, configuration, and dependencies can be easily packaged and turned into easy-to-use building blocks. Container images are an important part of container technology, allowing applications to be easily deployed and run in different environments.

[0003] Currently, it is popular to use buildx (image building component) provided by docker (open source container platform). Call binfmt_misc (register and use custom binary format interpreter) support tool to start qemu (Quick Emulator, virtualization software, emulates multiple hardware platforms and runs different operating systems in them) of the corresponding platform for compilation. Conventional docker image production requires the server of the corresponding platform to compile. If the image is compatible with many platforms, the platform types and quantity of the server are required to be high, resulting in unnecessary waste of resources. Summary of the invention

[0004] Based on this, it is necessary to provide a method, apparatus, computer device, computer-readable storage medium and computer program product for constructing a platform image that does not necessarily have to be compatible with multiple platforms in order to address the above technical problems.

[0005] In a first aspect, the present application provides a method for building a platform image, which is applied to a Docker server, including:

[0006] Obtain the target platforms corresponding to the platform images to be built, and obtain the software installation packages corresponding to each target platform, as well as the base images of each target platform;

[0007] For each target platform, obtain the corresponding image builder, and decompress each software installation package to the first target directory in the image builder corresponding to each target platform;

[0008] Based on the soft link information of the image root directory of the base image of each target platform, each first target directory is processed to obtain a second target directory corresponding to each target platform;

[0009] The content of the second target directory is written into the image root directory of the base image of the corresponding target platform, so as to obtain the platform images corresponding to each target platform.

[0010] In one embodiment, each image builder carries multiple types of decompression tools; decompressing each software installation package to a first target directory in the image builder corresponding to each target platform includes:

[0011] For each image builder, obtain the installation package type of each software installation package, and obtain a decompression tool of a target type that matches the installation package type from multiple types of decompression tools carried by the image builder;

[0012] Use the target type's decompression tool to decompress each software installation package to the first target directory in each image builder.

[0013] In one of the embodiments, the multiple types of decompression tools carried in the image builder include: a Debian package decompression tool and an RPM package decompression tool;

[0014] From the various types of decompression tools provided by the image builder, obtain the decompression tool of the target type that matches the installation package type, including:

[0015] When the installation package type is Debian package type, use Debian package decompression tool as the target type decompression tool;

[0016] When the installation package type is the RPM software package type, the RPM software package decompression tool is used as the target type decompression tool.

[0017] In an exemplary embodiment, for each target platform, before obtaining the corresponding image builder, the following is further included:

[0018] Get the number of platform types of the target platform;

[0019] Create as many image builders in parallel as the number of platform types.

[0020] In one embodiment, based on the soft link information of the image root directory of the base image of each target platform, each first target directory is processed to obtain a second target directory corresponding to each target platform, including:

[0021] Obtain the first directory naming information contained in the first target directory and the soft link information contained in the image root directory of the base image of each target platform;

[0022] When the first directory naming information is consistent with the target soft link information, the second directory naming information corresponding to the soft link information is obtained, and the first directory naming information contained in the first target directory is updated to the second directory naming information; the target soft link information is any one of the soft link information contained in the image root directory of the base image of each target platform.

[0023] In one embodiment, after obtaining the platform images corresponding to the target platforms, the method further includes:

[0024] Upload each platform image to the image repository;

[0025] The method also includes:

[0026] Get the image list corresponding to each platform image;

[0027] Generate a mirror list based on each mirror list, and upload the mirror list to the mirror warehouse.

[0028] In a second aspect, the present application also provides a platform image construction device, which is applied to a Docker server, including:

[0029] The acquisition module is used to obtain the target platforms corresponding to the platform images to be built, and obtain the software installation packages corresponding to each target platform, as well as the basic images of each target platform;

[0030] A decompression module, used to obtain the corresponding image builder for each target platform, and decompress each software installation package to the first target directory in the image builder corresponding to each target platform;

[0031] A second target directory generation module is used to process each first target directory based on the soft link information of the image root directory of the basic image of each target platform to obtain a second target directory corresponding to each target platform;

[0032] The platform image building module is used to write the content of the second target directory into the image root directory of the basic image corresponding to the target platform, so as to obtain the platform images corresponding to each target platform.

[0033] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0034] Obtain the target platforms corresponding to the platform images to be built, and obtain the software installation packages corresponding to each target platform, as well as the base images of each target platform;

[0035] For each target platform, obtain the corresponding image builder, and decompress each software installation package to the first target directory in the image builder corresponding to each target platform;

[0036] Based on the soft link information of the image root directory of the base image of each target platform, each first target directory is processed to obtain a second target directory corresponding to each target platform;

[0037] The content of the second target directory is written into the image root directory of the base image of the corresponding target platform, so as to obtain the platform images corresponding to each target platform.

[0038] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:

[0039] Obtain the target platforms corresponding to the platform images to be built, and obtain the software installation packages corresponding to each target platform, as well as the base images of each target platform;

[0040] For each target platform, obtain the corresponding image builder, and decompress each software installation package to the first target directory in the image builder corresponding to each target platform;

[0041] Based on the soft link information of the image root directory of the base image of each target platform, each first target directory is processed to obtain a second target directory corresponding to each target platform;

[0042] The content of the second target directory is written into the image root directory of the base image of the corresponding target platform, so as to obtain the platform images corresponding to each target platform.

[0043] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:

[0044] Obtain the target platforms corresponding to the platform images to be built, and obtain the software installation packages corresponding to each target platform, as well as the base images of each target platform;

[0045] For each target platform, obtain the corresponding image builder, and decompress each software installation package to the first target directory in the image builder corresponding to each target platform;

[0046] Based on the soft link information of the image root directory of the base image of each target platform, each first target directory is processed to obtain a second target directory corresponding to each target platform;

[0047] The content of the second target directory is written into the image root directory of the base image of the corresponding target platform, so as to obtain the platform images corresponding to each target platform.

[0048] The above-mentioned platform image construction method, device, computer equipment, storage medium and computer program product respectively obtain the target platform corresponding to the platform image to be constructed, the software installation package and image builder corresponding to the target platform, and the software installation package of the target platform. The software installation package is unzipped to the first target directory corresponding to each target platform, and the soft link information of the image root directory of the base image of each target platform is processed to obtain the second target directory, and the content of the second target directory is written into the image root directory of each base image, and finally the platform image corresponding to each target platform is obtained. By using multiple image builders as carriers for loading each platform image at the same time, the platform image is constructed on the image builder, and a one-to-one correspondence is achieved. Therefore, the platform image only needs to match one platform without being compatible with multiple platforms, which reduces the requirements for the type and number of platforms of the server and saves resource costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0050] Figure 1 An application environment diagram of a method for building a platform image in one embodiment;

[0051] Figure 2 A schematic diagram of a process for constructing a platform image in one embodiment;

[0052] Figure 3 A schematic diagram of a process for generating a second target directory in one embodiment;

[0053] Figure 4 It is a flowchart of a method for constructing a platform image in another embodiment;

[0054] Figure 5 It is a structural block diagram of a device for building a platform image in one embodiment;

[0055] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0056] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0057] The platform image construction method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the docker server 102 installs and runs a physical or virtual server of the docker engine. The docker engine is an open source containerization platform that can package applications and their dependencies into containers for deployment and operation in different environments. The docker server 102 obtains the target platform corresponding to the construction platform image from the terminal 101, and at the same time obtains the software installation package and the basic image corresponding to these target platforms (also disclosed as the image builder elsewhere in this application), downloads the corresponding image builder for each target platform, and unzips the software installation package into the first target directory of each corresponding image construction, and obtains the second target directory based on the soft link information of the image root directory of the basic image of each target platform; writes the content of the second target directory into the image root directory of the basic image, and finally obtains the platform image corresponding to each target platform, so that the terminal 101 can call the platform image in the docker server 102 for business processing. Among them, the terminal 101 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices, and the Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car devices, etc. The portable wearable device may be a smart watch, a smart bracelet, a head-mounted device, etc. The docker server 102 may be implemented as an independent server or a server cluster consisting of multiple servers.

[0058] In an exemplary embodiment, Figure 2 As shown, a method for building a platform image is provided, and the method is applied to Figure 1 The docker server 102 in the example is used as an example to illustrate, including the following steps S201 to S204. Among them:

[0059] Step S201, obtaining target platforms corresponding to the platform images to be built, and obtaining software installation packages corresponding to the target platforms, and basic images of the target platforms.

[0060] Among them, the platform image (disclosed elsewhere in this application as a builder image) can be understood as a snapshot of a pre-configured operating system and software environment, which can be used to quickly deploy and replicate the same platform environment; it contains all the necessary components that make up the platform, such as the operating system, applications, library files, configuration files, etc. This snapshot needs to be placed on a movable cloud platform, where the cloud platform refers to the target platform. The software installation package can be understood as the building materials necessary to build this cloud platform. The base image is the basis for building other images. It is a minimized operating system image, which usually only contains the core components of the operating system and some basic tools for building and expanding platform images.

[0061] Optionally, the Docker server pre-acquires the target platform corresponding to the platform image to be built, and at the same time obtains the software installation package required to build this target platform, and downloads the basic image of each target platform to make advance preparations for the subsequent construction of the platform image.

[0062] Step S202: For each target platform, obtain a corresponding image builder, and decompress each software installation package to a first target directory in the image builder corresponding to each target platform.

[0063] Among them, the target platform can be understood as the platform information in the platform image to be built, that is, the corresponding target platform, and the corresponding image builder needs to be selected for this platform information; the image builder, that is, the builder container, can be understood as a container that loads the target platform installation package, and the platform image is also built here, because the platform is directly installed on the container, so it does not need to be compatible with the server's buildx plug-in. The first target directory, that is, the / target directory, is not a fixed directory in the docker server, but a specific output directory generated during the image building process to save the output content.

[0064] For example, a corresponding image builder is constructed for each target platform, providing a place for image construction, and decompressing the software installation package for each target platform and storing it in the first target directory, laying a foundation for the subsequent construction of the platform image.

[0065] Step S203: Based on the soft link information of the image root directory of the basic image of each target platform, each first target directory is processed to obtain a second target directory corresponding to each target platform.

[0066] The system root directory is the starting point of the entire file system and is also the parent directory of other directories. The relevant files can be accessed through the soft link information in the system root directory. The second target directory can be understood as the final output directory obtained after processing the first target directory.

[0067] Step S204, writing the content of the second target directory into the image root directory of the base image corresponding to the target platform, and obtaining the platform images corresponding to each target platform.

[0068] The image root directory is a virtual directory in the platform image and does not correspond to the actual file system of the host. When the platform is running, the image root directory will be mapped to the file system of the host, so that the container can access the files and directories of the host. The image root directory is also the starting point of all file systems in the platform image.

[0069] For example, the image layer of the image builder is exported, and the image layer contains all the contents of the second target directory, and this image layer is merged into the base image to obtain the platform image. It can also be understood as copying all the contents under the second target directory to the root directory of the base image to realize the construction of the platform image.

[0070] In the above-mentioned platform image construction method, the target platform corresponding to the platform image to be constructed, the software installation package and image builder corresponding to the target platform, and the software installation package of the target platform are obtained respectively. The software installation package is unzipped to the first target directory corresponding to each target platform, and the soft link information of the image root directory of the base image of the target platform is processed to obtain the second target directory, and the content of the second target directory is copied to the image root directory of each base image, and finally the platform image corresponding to each target platform is obtained. By using multiple image builders with completely consistent architectures as carriers for loading each platform image at the same time, the platform image is constructed on the image builder, and a one-to-one correspondence is achieved. Therefore, the platform image only needs to match one platform without being compatible with multiple platforms, which reduces the requirements for the type and number of platforms on the server and saves resource costs.

[0071] In one of the embodiments, each image builder carries multiple types of decompression tools; each software installation package is decompressed to the first target directory in the image builder corresponding to each target platform, including: for each image builder, obtaining the installation package type of each software installation package, and obtaining a decompression tool of a target type that matches the installation package type from the multiple types of decompression tools carried in the image builder; and decompressing each software installation package to the first target directory in each image builder through the decompression tool of the target type.

[0072] The source of the software installation package can be the official software source or the company software compiled by itself, but no matter which one it is, it needs to support the architecture of the target platform. When downloading the software for installation, if there are any dependent packages, they also need to be provided. The scope of this dependent package is determined based on the software package installed by the base image of each target platform.

[0073] Optionally, determine the type of the software installation package. Different types of software installation packages require different decompression tools for decompression. Select the corresponding decompression tool according to the type of the software installation package, and decompress the software installation package into the first target directory of each image builder.

[0074] In this embodiment, the Docker server first identifies the type of the software installation package, and selects a decompression tool that matches the type of the software installation package for decompression, which can increase the decompression speed and thus speed up the platform image building speed.

[0075] In one embodiment, the multiple types of decompression tools carried by the image builder include: a Debian package decompression tool and an RPM package decompression tool; obtaining a target type of decompression tool that matches the installation package type from the multiple types of decompression tools carried by the image builder includes:

[0076] When the installation package type is Debian package type, use Debian package decompression tool as the target type decompression tool;

[0077] When the installation package type is the RPM software package type, the RPM software package decompression tool is used as the target type decompression tool.

[0078] Among them, the Debian package decompression tool, namely dpkg-deb, and the RPM package decompression tool, namely rpm2cpio, are command line tools for decompressing and extracting files from the installation package. The Debian package decompression tool is for the Debian package, namely .deb file, and the RPM package decompression tool is for the RPM package, namely .rpm file.

[0079] In this embodiment, by judging the type of the software package and selecting an appropriate decompression tool for decompression, the building speed of the target platform is accelerated, thereby speeding up the construction of the platform image.

[0080] In one of the embodiments, for each target platform, before obtaining the corresponding image builder, the process further includes: obtaining the number of platform types of the target platform; and creating image builders in parallel whose number is the same as the number of platform types.

[0081] The target platform type refers to the type of target hardware or operating system platform on which the built software or application will run. It is very important to choose a platform type that is suitable for the target platform, because differences in hardware and operating systems between different platforms may cause the behavior and performance of the software installation package to differ on different platforms.

[0082] In this embodiment, by determining the platform type of each target platform, the same number of image builders are created in parallel according to the number of platform types, thereby ensuring the normal operation of the software installation packages corresponding to each target platform in the image builder after decompression. At the same time, the parallel creation of the corresponding image builders also achieves the technical effect of parallel creation of multi-platform images.

[0083] In an exemplary embodiment, Figure 3 As shown, based on the soft link information of the image root directory of the basic image of each target platform, each first target directory is processed to obtain the second target directory corresponding to each target platform, including steps S301 to S302.

[0084] Step S301, obtaining first directory naming information contained in the first target directory and soft link information contained in the image root directory of the basic image of each target platform.

[0085] The first directory naming information is used to indicate the file directory information generated after the software installation packages corresponding to each target platform are decompressed into the first target directory. The image root directory of the base image of the target platform also contains directory information of various files, and the directory file information contains soft link information, which can be clicked to jump to the file linked by the soft link.

[0086] Step S302, when the first directory naming information is consistent with the target soft link information, obtain the second directory naming information corresponding to the soft link information, and update the first directory naming information contained in the first target directory to the second directory naming information; the target soft link information is any one of the soft link information contained in the image root directory of the base image of each target platform.

[0087] The first directory naming information can be any directory naming information in the first target directory, and the target soft link information can also be any soft link information in the image root directory of the base image of each target platform. The directory naming information second target directory can be understood as the target directory after the first directory naming information in the first target directory is modified to obtain the second directory naming information.

[0088] Optionally, when any directory naming information in the first target directory is the same as any soft link information in the image root directory of the base image of each target platform, this directory naming information needs to be modified to distinguish it from the same soft link information in the image root directory of the base image of each target platform to avoid the loss of system-specific files and the inability to start the image builder.

[0089] In this embodiment, by comparing the first directory naming information in the first target directory with the target soft link information in the image root directory of the base image of each target platform, if the first directory naming information and the target soft link information are consistent, the first directory naming information is modified to obtain the second directory naming information, which can achieve the technical effect of avoiding system file loss and image builder startup failure.

[0090] In one embodiment, after obtaining the platform images corresponding to the target platforms, the method further includes: uploading the platform images to the image warehouse;

[0091] The method further comprises:

[0092] Obtain the image manifests corresponding to each platform image; generate an image manifest list based on each image manifest, and upload the image manifest list to the image warehouse.

[0093] Among them, the image warehouse exists in the docker server, which is used to store the platform images constructed by the above embodiments. The image list can be understood as the unique identification code of each platform image. The image lists between different platform images are different. The image list list can be used to find the required platform image through the image list. There can be multiple image lists but different names. There is only one image list list and it includes all image lists.

[0094] In this embodiment, after the docker server completes the construction of the platform image, it will upload the successfully built platform image to an image repository for easy access, further integrate the platform images, attach an identity identification code (i.e., image list) to each platform image, and then integrate all image lists to form an image list list. This image list is also uploaded to the image repository at the same time. Subsequently, the required platform image can be quickly found according to the list, which speeds up the calling of the platform image.

[0095] In an exemplary embodiment, Figure 4 As shown, a detailed step of a method for building a platform image includes:

[0096] 1. The docker server downloads and builds the image builder. The platform architecture of the builder image depends on the docker server, and there is no specific hard requirement, such as the general amd64 platform dock server; the builder image needs to have dpkg-deb (Debian software package (.deb file)), rpm2cpio (RPM software package (.rpm file)) and other related tools installed.

[0097] 2. Download the software installation package of the target platform. The source of the software installation package can be the official software source or the company software compiled by itself. However, it needs to support the architecture of the target platform. For example, the installation package of openssh service that supports A, B and C. If there are dependent packages, they must also be provided, and the scope of the dependent packages depends on the software packages installed in the base image of the target platform.

[0098] 3. Unzip the installation package to the first / target directory. Use different tools to decompress different types of installation packages. Currently, the mainstream types are Debian packages and RPM packages, which are decompressed using dpkg-deb and rpm2cpio tools respectively.

[0099] 4. Compare the directory name in the first / target directory with the soft link name in the image root directory of the base image of each target platform. If the names are the same, modify the directory name in the first / target directory to obtain the second / target directory. Since there is a soft link in the root directory of the base image, the copy function of docker file will create a directory with the same name as the soft link in the target image and overwrite the original soft link of the target image, resulting in the loss of some system files and the crash of container startup.

[0100] 5. Download the base image of the target platform, and use the copy function of docker file to copy the contents of the second / target directory of the builder container to the root directory ( / ) of the base image. The principle of this method is to export the image layer of the builder container (the layer contains all the contents under the second / target directory), and then merge it into the base image to achieve image integration.

[0101] 6. Upload the built platform images to the image warehouse.

[0102] 7. Make a manifest list and upload it to the image repository. A manifest is a file that contains basic information about the image, such as architecture, size, etc. A manifest list is a list of image lists used to store image information for multiple different os / arch images. We can create a manifest list to point to one or more images of different platform architectures (e.g., an ubuntu20-amd64 and an ubuntu20-arm64 image), and then provide the user with a unique image name (e.g., ubuntu20).

[0103] Compared with the prior art, this application has the following advantages:

[0104] 1. Starting the same number of image builders in parallel according to the number of platform types of the target platform can avoid the failure of the software installation package to run normally after decompression due to incompatible platform types, and at the same time achieve the technical effect of building multi-platform images in parallel.

[0105] 2. When the first directory naming information of the first target directory is consistent with the target soft link information, the first directory naming information is modified to the second directory naming information which is different from the target soft link information, and the above traversal and modification are performed on all the contents in the first target directory to prevent the soft link information from being overwritten when the base image is subsequently built, causing the image builder to crash when it starts.

[0106] 3. The process of building each platform image is carried out in the corresponding image builder, which does not need to be compatible with the buildx plug-in in the docker server. At the same time, the platform image and the image builder form a corresponding relationship, which does not need to be compatible with multiple platforms, reducing resource costs.

[0107] 4. Finally, a mirror list consisting of mirror lists is formed, which can be quickly searched through this list. At the same time, cross-platform building of platform images and cross-platform calling of platform images are also realized.

[0108] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0109] Based on the same inventive concept, the embodiment of the present application also provides a platform image construction device for implementing the platform image construction method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the embodiments of the one or more platform image construction devices provided below can refer to the limitations of the platform image construction method above, and will not be repeated here.

[0110] In an exemplary embodiment, Figure 5 As shown, a platform image construction device is provided, including: an acquisition module 501, a decompression module 502, a second target directory generation module 503 and a platform image construction module 504, wherein:

[0111] The acquisition module 501 is used to acquire the target platforms corresponding to the platform images to be built, and acquire the software installation packages corresponding to the target platforms, as well as the basic images of the target platforms.

[0112] The decompression module 502 is used to obtain the corresponding image builder for each target platform, and decompress each software installation package to the first target directory in the image builder corresponding to each target platform.

[0113] The second target directory generating module 503 is used to process each first target directory based on the soft link information of the image root directory of the basic image of each target platform to obtain a second target directory corresponding to each target platform.

[0114] The platform image building module 504 is used to write the content of the second target directory into the image root directory of the basic image corresponding to the target platform, so as to obtain the platform images corresponding to each target platform.

[0115] In one embodiment, each image builder carries multiple types of decompression tools, and the decompression module 502 is specifically used to obtain the installation package type of each software installation package for each image builder, and obtain a decompression tool of a target type that matches the installation package type from the multiple types of decompression tools carried in the image builder; and decompress each software installation package to the first target directory in each image builder through the decompression tool of the target type.

[0116] In an exemplary embodiment, the multiple types of decompression tools carried in the image builder include: a Debian package decompression tool and an RPM package decompression tool. The decompression module 502 is specifically used to use the Debian package decompression tool as the target type of decompression tool when the installation package type is a Debian package type; and use the RPM package decompression tool as the target type of decompression tool when the installation package type is an RPM package type.

[0117] In one of the embodiments, before entering the decompression module 502, it is specifically used to obtain the number of platform types of the target platform; and to create image builders in parallel with the same number of platform types.

[0118] In one embodiment, the second target directory generation module 503 is specifically used to obtain the first directory naming information contained in the first target directory, and the soft link information contained in the image root directory of the basic image of each target platform; when the first directory naming information is consistent with the target soft link information, the second directory naming information corresponding to the soft link information is obtained, and the first directory naming information contained in the first target directory is updated to the second directory naming information; the target soft link information is any one of the soft link information contained in the image root directory of the basic image of each target platform.

[0119] In one of the embodiments, the device is also specifically used to upload each platform image to an image warehouse; obtain an image list corresponding to each platform image; generate an image list list based on each image list, and upload the image list list to the image warehouse.

[0120] Each module in the above-mentioned platform image construction device can be implemented in whole or in part by software, hardware and their combination. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0121] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 6 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store corresponding target platform data, target platform software installation package data, target platform basic image data, image builder target directory data and system root directory data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for building a platform image is implemented.

[0122] Those skilled in the art will understand that Figure 6The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application 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.

[0123] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the method for constructing a platform image of the above embodiment is implemented.

[0124] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method for constructing a platform image of the above embodiment is implemented.

[0125] In one embodiment, a computer program product is provided, including a computer program, which implements the platform image construction method of the above embodiment when executed by a processor.

[0126] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used 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 must comply with relevant regulations.

[0127] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0128] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0129] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A method for constructing a platform image, characterized in that: Applied to a docker server, the method includes: Obtain the target platforms corresponding to the platform images to be built, and obtain the software installation packages corresponding to the target platforms, as well as the base images of the target platforms; For each of the target platforms, obtain a corresponding image builder, and decompress each of the software installation packages to a first target directory in the image builder corresponding to each of the target platforms; Obtaining first directory naming information contained in the first target directory and soft link information contained in the image root directory of the base image of each of the target platforms; In the case where the first directory naming information is consistent with the target soft link information, obtaining the second directory naming information corresponding to the soft link information, updating the first directory naming information contained in the first target directory to the second directory naming information, and obtaining the second target directory corresponding to each of the target platforms; the target soft link information is any one of the soft link information contained in the image root directory of the base image of each of the target platforms; The content of the second target directory is written into the image root directory of the base image corresponding to the target platform, so as to obtain the platform images corresponding to the target platforms respectively.

2. The method according to claim 1, characterized in that Each of the image builders carries multiple types of decompression tools; the decompression of each of the software installation packages to the first target directory in the image builder corresponding to each of the target platforms includes: For each of the image builders, obtaining the installation package type of each of the software installation packages, and obtaining a decompression tool of a target type that matches the installation package type from multiple types of decompression tools carried in the image builders; Each of the software installation packages is decompressed into the first target directory in each of the image builders using a decompression tool of the target type.

3. The method according to claim 2, characterized in that The various types of decompression tools carried in the image builder include: Debian software package decompression tool and RPM software package decompression tool; The step of obtaining a decompression tool of a target type that matches the installation package type from the multiple types of decompression tools carried by the image builder includes: When the installation package type is a Debian software package type, using the Debian software package decompression tool as the decompression tool of the target type; In the case that the installation package type is an RPM software package type, the RPM software package decompression tool is used as the decompression tool of the target type.

4. The method according to claim 2, characterized in that: Before obtaining the corresponding image builder for each target platform, the method further includes: Obtain the number of platform types of the target platform; Create the same number of image builders in parallel as the number of platform types.

5. The method according to claim 1, characterized in that After obtaining the platform images corresponding to the target platforms respectively, the method further includes: Upload each platform image to the image warehouse; The method further comprises: Obtain an image list corresponding to each platform image; Generate a mirror list according to each mirror list, and upload the mirror list to the mirror warehouse.

6. A device for constructing a platform image, characterized in that: Applied to a docker server, the device comprises: An acquisition module is used to acquire the target platforms corresponding to the platform images to be built, and to acquire the software installation packages corresponding to the target platforms, as well as the basic images of the target platforms; A decompression module, used for obtaining a corresponding image builder for each target platform, and decompressing each software installation package to a first target directory in the image builder corresponding to each target platform; A second target directory generation module is used to obtain the first directory naming information contained in the first target directory and the soft link information contained in the image root directory of the basic image of each target platform; when the first directory naming information is consistent with the target soft link information, obtain the second directory naming information corresponding to the soft link information, update the first directory naming information contained in the first target directory to the second directory naming information, and obtain the second target directory corresponding to each target platform; the target soft link information is any one of the soft link information contained in the image root directory of the basic image of each target platform; The platform image building module is used to write the content of the second target directory into the image root directory of the basic image of the corresponding target platform to obtain the platform images corresponding to each of the target platforms.

7. The device according to claim 6, characterized in that Each of the image builders carries multiple types of decompression tools; the decompression module is further used to: For each of the image builders, obtaining the installation package type of each of the software installation packages, and obtaining a decompression tool of a target type that matches the installation package type from multiple types of decompression tools carried in the image builders; Each of the software installation packages is decompressed into the first target directory in each of the image builders using a decompression tool of the target type.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.

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

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Software installation method and device, storage medium and electronic equipment

    CN111522560A

  • JavaWeb application deployment method, device and equipment and storage medium

    CN112506615A