CN117555563A - Method and device for constructing platform mirror image, computer equipment and storage medium - Google Patents
Method and device for constructing platform mirror image, computer equipment and storage medium Download PDFInfo
- Publication number
- CN117555563A CN117555563A CN202311603203.5A CN202311603203A CN117555563A CN 117555563 A CN117555563 A CN 117555563A CN 202311603203 A CN202311603203 A CN 202311603203A CN 117555563 A CN117555563 A CN 117555563A
- Authority
- CN
- China
- Prior art keywords
- target
- platform
- mirror image
- directory
- mirror
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 49
- 238000012545 processing Methods 0.000 claims abstract description 19
- 230000006837 decompression Effects 0.000 claims description 66
- 238000004590 computer program Methods 0.000 claims description 24
- 238000009434 installation Methods 0.000 claims description 24
- 238000010276 construction Methods 0.000 claims description 16
- 239000000306 component Substances 0.000 description 6
- 238000010586 diagram Methods 0.000 description 6
- 238000005516 engineering process Methods 0.000 description 4
- 238000004891 communication Methods 0.000 description 3
- 230000001419 dependent effect Effects 0.000 description 3
- 230000000694 effects Effects 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000008569 process Effects 0.000 description 3
- 239000000969 carrier Substances 0.000 description 2
- 230000008859 change Effects 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- OKTJSMMVPCPJKN-UHFFFAOYSA-N Carbon Chemical compound [C] OKTJSMMVPCPJKN-UHFFFAOYSA-N 0.000 description 1
- 230000006399 behavior Effects 0.000 description 1
- 239000004566 building material Substances 0.000 description 1
- 239000008358 core component Substances 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 229910021389 graphene Inorganic materials 0.000 description 1
- 230000010354 integration Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000002360 preparation method Methods 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/61—Installation
- G06F8/63—Image based installation; Cloning; Build to order
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
- G06F9/45558—Hypervisor-specific management and integration aspects
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The application provides a method, a device, computer equipment and a storage medium for constructing a platform image. The method comprises the following steps: the dock server respectively acquires a target platform corresponding to the platform image to be built, a software installation package corresponding to the target platform, an image builder and a software installation package of the target platform. Decompressing the software installation package to a first target directory corresponding to each target platform, processing the first target directory to obtain a second target directory aiming at soft link information in the mirror image root directory of the basic mirror image of each target platform, writing the content of the second target directory into the mirror image root directory of each basic mirror image, and finally obtaining the platform mirror image corresponding to each target platform. The method can realize that one platform mirror image corresponds to one platform, does not need to be compatible with a plurality of platforms, reduces the requirements on the types and the quantity of the server platforms, and saves the resource cost.
Description
Technical Field
The present application relates to the field of container technologies, and in particular, to a method, an apparatus, a computer device, a storage medium, and a computer program product for constructing a platform image.
Background
With the development of big data and cloud computing technology, container technology has emerged, which is a way to implement operating system virtualization, and by using containers, the code, configuration and dependency of an application program can be easily packaged, and become a building block that is easy to use. Container mirroring is an important component in container technology, allowing applications to be easily deployed and run in different environments.
Currently popular uses the buildx (mirror build component) provided by a docker (open-source containerized platform). Invoking binfmt_misc (registering and using a custom binary format interpreter) support tool to start qemu (Quick emulators) of a corresponding platform, virtualizing software, simulating a plurality of hardware platforms and running different operating systems in the hardware platforms for compiling, making a conventional dock mirror image, and compiling a server of the corresponding platform, wherein if the mirror image needs to be compatible with more platforms, the requirements on the types and the quantity of the platforms of the server are higher, so that unnecessary resource waste is caused.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a construction method, apparatus, computer device, computer readable storage medium, and computer program product that enable platform mirroring that is not necessarily compatible with multiple platforms.
In a first aspect, the present application provides a method for constructing a platform image, which is applied to a docker server, including:
acquiring target platforms corresponding to the images of the platforms to be built respectively, and acquiring software installation packages corresponding to the target platforms and basic images of the target platforms;
aiming at each target platform, acquiring a corresponding mirror image constructor, and decompressing each software installation package to a first target catalog in the mirror image constructor corresponding to each target platform;
processing each first target directory based on soft link information of the mirror image root directory of the basic mirror image of each target platform to obtain a second target directory corresponding to each target platform;
and writing the content of the second target directory into a mirror root directory of the basic mirror of the corresponding target platform to obtain the platform mirror corresponding to each target platform.
In one embodiment, each mirror image builder carries multiple types of decompression tools therein; decompressing each software installation package to a first target catalog in a mirror image constructor corresponding to each target platform, wherein the method comprises the following steps:
aiming at each mirror image constructor, acquiring the installation package type of each software installation package, and acquiring a target type decompression tool matched with the installation package type from a plurality of types of decompression tools carried in the mirror image constructor;
and decompressing each software installation package to a first target catalog in each mirror image constructor through a decompression tool of the target type.
In one embodiment, the multiple types of decompression tools carried in the mirror builder include: a Debian software package decompression tool and an RPM software package decompression tool;
obtaining a target type decompression tool matched with the type of the installation package from a plurality of types of decompression tools carried in the mirror image constructor, wherein the method comprises the following steps:
under the condition that the installation package type is a Debian software package type, taking a Debian software package decompression tool as a decompression tool of a target type;
in the case that the installation package type is the RPM software package type, taking the RPM software package decompression tool as a decompression tool of a target type.
In an exemplary embodiment, before obtaining the corresponding mirror image builder for each target platform, the method further includes:
acquiring the number of platform types of the target platform;
the same number of mirror image constructors as the number of platform types are created in parallel.
In one embodiment, processing each first target directory based on soft link information of a mirror root directory of a base mirror of each target platform to obtain a second target directory corresponding to each target platform includes:
acquiring first directory naming information contained in a first target directory and soft link information contained in a mirror image root directory of a basic mirror image of each target platform;
under the condition that the first directory naming information is consistent with the target soft link information, acquiring second directory naming information corresponding to the soft link information, and updating the first directory naming information contained in the first target directory into the second directory naming information; the target soft link information is any one of soft link information contained in the mirror root directory of the basic mirror of each target platform.
In one embodiment, after obtaining the platform images corresponding to the target platforms respectively, the method further includes:
uploading the mirror images of the platforms to a mirror image warehouse;
the method further comprises the steps of:
obtaining a mirror image list corresponding to each platform mirror image;
and generating a mirror image list according to each mirror image list, and uploading the mirror image list to a mirror image warehouse.
In a second aspect, the present application further provides a device for constructing a platform image, which is applied to a docker server, and includes:
the acquisition module is used for acquiring target platforms corresponding to the images of the platforms to be constructed respectively, and acquiring software installation packages corresponding to the target platforms and basic images of the target platforms;
the decompression module is used for acquiring corresponding mirror image constructors aiming at each target platform and decompressing each software installation package to a first target catalog in the mirror image constructors corresponding to each target platform;
the second target catalog generation module is used for processing each first target catalog based on the soft link information of the mirror image root catalog of the basic mirror image of each target platform to obtain a second target catalog corresponding to each target platform;
the platform image construction module is used for writing 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 the target platforms respectively.
In a third aspect, the present application also provides a computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:
acquiring target platforms corresponding to the images of the platforms to be built respectively, and acquiring software installation packages corresponding to the target platforms and basic images of the target platforms;
aiming at each target platform, acquiring a corresponding mirror image constructor, and decompressing each software installation package to a first target catalog in the mirror image constructor corresponding to each target platform;
processing each first target directory based on soft link information of the mirror image root directory of the basic mirror image of each target platform to obtain a second target directory corresponding to each target platform;
and writing the content of the second target directory into a mirror root directory of the basic mirror of the corresponding target platform to obtain the platform mirror corresponding to each target platform.
In a fourth aspect, the present application also provides a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
acquiring target platforms corresponding to the images of the platforms to be built respectively, and acquiring software installation packages corresponding to the target platforms and basic images of the target platforms;
aiming at each target platform, acquiring a corresponding mirror image constructor, and decompressing each software installation package to a first target catalog in the mirror image constructor corresponding to each target platform;
processing each first target directory based on soft link information of the mirror image root directory of the basic mirror image of each target platform to obtain a second target directory corresponding to each target platform;
and writing the content of the second target directory into a mirror root directory of the basic mirror of the corresponding target platform to obtain the platform mirror corresponding to each target platform.
In a fifth aspect, the present application also provides a computer program product comprising a computer program which, when executed by a processor, performs the steps of:
acquiring target platforms corresponding to the images of the platforms to be built respectively, and acquiring software installation packages corresponding to the target platforms and basic images of the target platforms;
aiming at each target platform, acquiring a corresponding mirror image constructor, and decompressing each software installation package to a first target catalog in the mirror image constructor corresponding to each target platform;
processing each first target directory based on soft link information of the mirror image root directory of the basic mirror image of each target platform to obtain a second target directory corresponding to each target platform;
and writing the content of the second target directory into a mirror root directory of the basic mirror of the corresponding target platform to obtain the platform mirror corresponding to each target platform.
The method, the device, the computer equipment, the storage medium and the computer program product for constructing the platform mirror image respectively acquire a target platform corresponding to the platform mirror image to be constructed, a software installation package corresponding to the target platform, a mirror image constructor and a software installation package of the target platform. Decompressing the software installation package to a first target directory corresponding to each target platform, processing the first target directory to obtain a second target directory aiming at soft link information of the mirror image root directory of the basic mirror image of each target platform pair, writing the content of the second target directory into the mirror image root directory of each basic mirror image, and finally obtaining the platform mirror image corresponding to each target platform. By using a plurality of mirror image constructors as carriers for loading the mirror images of the platforms, the construction of the mirror images of the platforms is carried out on the mirror image constructors, so that one-to-one correspondence is realized, and therefore, the mirror images of the platforms are matched with one platform only without being compatible with a plurality of platforms, the requirements on the types and the quantity of the platforms of the server are reduced, and the resource cost is saved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the related art, the drawings that are required to be used in the embodiments or the related technical descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to the drawings without inventive effort for a person having ordinary skill in the art.
FIG. 1 is an application environment diagram of a method of building a platform image in one embodiment;
FIG. 2 is a flow diagram of a method of building a platform image in one embodiment;
FIG. 3 is a flow diagram of second target directory generation in one embodiment;
FIG. 4 is a flow chart of a method of constructing a platform image according to another embodiment;
FIG. 5 is a block diagram of an apparatus for building a platform image in one embodiment;
fig. 6 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
The method for constructing the platform mirror image, provided by the embodiment of the application, can be applied to an application environment shown in fig. 1. Wherein the docker server 102 installs and runs a physical or virtual server of the docker engine. The docker engine is an open-source containerized platform that can package applications and their dependent items into containers for deployment and operation in different environments. The dock server 102 obtains target platforms corresponding to the image of the build platform from the terminal 101, obtains software installation packages and basic images (disclosed as image builders in other places of the application) corresponding to the target platforms at the same time, downloads respective corresponding image constructors for the target platforms, decompresses the software installation packages into first target catalogues constructed by the respective corresponding images, and obtains second target catalogues based on soft link information of image root catalogues of the basic images of the target platforms; and writing the content of the second target directory into the mirror root directory of the basic mirror, and finally obtaining a platform mirror corresponding to each target platform, so that the terminal 101 can call the platform mirror in the dock server 102 to perform service processing. The terminal 101 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, internet of things devices and portable wearable devices, and the internet of things devices may be smart speakers, smart televisions, smart air conditioners, smart vehicle devices, and the like. The portable wearable device may be a smart watch, smart bracelet, headset, or the like. The docker server 102 may be implemented as a stand-alone server or as a cluster of servers.
In an exemplary embodiment, as shown in fig. 2, a method for constructing a platform image is provided, and an example of application of the method to the docker server 102 in fig. 1 is described, which includes the following steps S201 to S204. Wherein:
step S201, obtaining target platforms corresponding to the to-be-built platform images respectively, and obtaining software installation packages corresponding to the target platforms and basic images of the target platforms.
Wherein, a platform image (disclosed as a builder image elsewhere in the present application) can be understood as a snapshot of a preconfigured operating system and software environment, which can be used to rapidly deploy and replicate the same platform environment; including all necessary components that make up the platform, such as the operating system, application programs, library files, configuration files, etc. The snapshot needs to be placed on a movable cloud platform, which is referred to as the target platform. A software installation package is understood to be the building material necessary to build the cloud platform, and a base image is the basis for building other images, and is a minimized operating system image, and typically only contains the core components of the operating system and some basic tools for building and expanding the platform image.
Optionally, the dock server acquires a target platform corresponding to the platform image to be built in advance, acquires a software installation package necessary for building the target platform, and downloads the basic image of each target platform to make preparation work in advance for subsequent building of the platform image.
Step S202, for each target platform, a corresponding mirror image constructor is obtained, and each software installation package is decompressed to a first target catalog in the mirror image constructor corresponding to each target platform.
The target platform can be understood as platform information in the platform image to be constructed, namely a corresponding target platform, and a corresponding image constructor needs to be selected aiming at the platform information; the image builder, i.e., builder container, is understood to be a container that loads the target platform installation package, while the build of the platform image is also performed herein, as the platform is installed directly on the container and therefore does not have to be compatible with the build x plug-in of the server. The first target directory, i.e., the/target directory, is not a fixed directory within the docker server, but rather is a specific output directory that is generated during the mirror construction process to save output content.
For example, respectively constructing corresponding mirror image constructors for the target platforms, providing a place where mirror image construction occurs, decompressing software installation packages for constructing each target platform, and storing the decompressed software installation packages in a first target directory to lay a foundation for continuing to construct the mirror images of the platforms.
Step S203, based on the soft link information of the mirror image root directory of the basic mirror image of each target platform, processing each first target directory to obtain a second target directory corresponding to each target platform.
The system root directory is the starting point of the whole file system, and is also the father directory of other directories, and related files can be accessed through soft link information in the system root directory. The second target directory may be understood as a final output directory obtained after processing the first target directory.
And step S204, writing the content of the second target directory into the mirror image root directory of the basic mirror image of the corresponding target platform to obtain the platform mirror images respectively corresponding to the target platforms.
The mirror root directory is a virtual directory in the mirror image of the platform and does not correspond to an actual file system of the host, and when the platform runs, the mirror root directory is mapped into the file system of the host, so that the container can access files and directories of the host. The mirror root directory is also the starting point for all file systems in the platform mirror.
Illustratively, the image layer of the image builder is exported, the image layer contains all of the contents of the second target directory, and this image layer is merged into the base image, resulting in the platform image. It can also be understood that the construction of the platform image is realized by copying all the contents under the second target directory to the root directory of the base image.
In the method for constructing the platform image, a target platform corresponding to the platform image to be constructed, a software installation package corresponding to the target platform, an image constructor and a software installation package of the target platform are respectively obtained. Decompressing the software installation package to a first target directory corresponding to each target platform, processing the first target directory to obtain a second target directory aiming at soft link information of the mirror image root directory of the basic mirror image of the target platform, copying the content of the second target directory to the mirror image root directory of each basic mirror image, and finally obtaining the platform mirror image corresponding to each target platform. By using a plurality of mirror image constructors with completely consistent architecture as carriers for loading the mirror images of the platforms, the construction of the mirror images of the platforms is carried out on the mirror image constructors, so that one-to-one correspondence is realized, and therefore, the mirror images of the platforms are only matched with one platform without being compatible with a plurality of platforms, the requirements on the types and the quantity of the platforms of the server are reduced, and the resource cost is saved.
In one embodiment, each mirror image builder carries multiple types of decompression tools therein; decompressing each software installation package to a first target catalog in a mirror image constructor corresponding to each target platform, wherein the method comprises the following steps: aiming at each mirror image constructor, acquiring the installation package type of each software installation package, and acquiring a target type decompression tool matched with the installation package type from a plurality of types of decompression tools carried in the mirror image constructor; and decompressing each software installation package to a first target catalog in each mirror image constructor through a decompression tool of the target type.
The source of the software installation package can be an official software source or company software which can be compiled by the user, but the software installation package is downloaded and provided if a dependent package exists at the same time, and the range of the dependent package is determined based on the software package installed by the basic mirror image of each target platform.
Optionally, determining the type of the software installation package, wherein different types of software installation packages need to be decompressed by adopting different decompression tools, selecting a corresponding decompression tool according to the type of the software installation package, and decompressing the software installation package into the first target catalogue of each mirror image constructor.
In this embodiment, the docker server firstly screens the type of the software installation package, and selects a decompression tool matched with the software installation package according to the type of the software installation package to decompress, so that the decompression speed can be increased, and the speed of constructing the platform mirror image is further increased.
In one embodiment, among other things, the multiple types of decompression tools carried in the mirror builder include: a Debian software package decompression tool and an RPM software package decompression tool; obtaining a target type decompression tool matched with the type of the installation package from a plurality of types of decompression tools carried in the mirror image constructor, wherein the method comprises the following steps:
under the condition that the installation package type is a Debian software package type, taking a Debian software package decompression tool as a decompression tool of a target type;
in the case that the installation package type is the RPM software package type, taking the RPM software package decompression tool as a decompression tool of a target type.
The Debian software package decompression tool, namely dpkg-deb, and the RPM software package decompression tool, namely RPM2cpio, are command line tools for decompressing and extracting files in an installation package, wherein the Debian software package decompression tool aims at a Debian software package, namely a deb file, and the RPM software package decompression tool aims at an RPM software package, namely a RPM file.
In this embodiment, the decompression tool adapted is selected to decompress by judging the type of the software package, so as to accelerate the construction speed of the target platform, and further accelerate the construction speed of the platform mirror image.
In one embodiment, before obtaining the corresponding mirror image builder for each target platform, the method further includes: acquiring the number of platform types of the target platform; the same number of mirror image constructors as the number of platform types are created in parallel.
The type of the target platform refers to the type of target hardware or operating system platform on which the built software or application program is to run, and it is very important to select a platform type suitable for the target platform, because the difference between hardware and operating system of different platforms may cause the behavior and performance of the software installation package on different platforms to be different.
In this embodiment, by determining the platform types of each target platform, the mirror image constructors with the same number are created in parallel according to the number of the platform types, so as to ensure the normal operation of the software installation packages corresponding to each target platform in the mirror image constructors after decompression, and simultaneously, the parallel creation of the corresponding mirror image constructors also achieves the technical effect of parallel creation of multiple platform mirror images.
In an exemplary embodiment, as shown in fig. 3, processing each first target directory based on soft link information of a mirror root directory of a base mirror of each target platform to obtain a second target directory corresponding to each target platform includes steps S301 to S302. Wherein:
step S301, obtaining first directory naming information included in the first target directory and soft link information included in the mirror root directory of the base mirror of each target platform.
The first directory naming information is used for representing file directory information generated after the software installation packages corresponding to the target platforms are decompressed under the first target directory. The mirror image root directory of the basic mirror image of the target platform also contains directory information of various files, the directory file information contains soft link information, and clicking can jump to the file linked by the soft link.
Step S302, under the condition that the first directory naming information is consistent with the target soft link information, 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 be the second directory naming information; the target soft link information is any one of soft link information contained in the mirror root directory of the basic mirror of each target platform.
The first directory naming information may be any directory naming information in the first target directory, and the target soft link information may be any soft link information in the mirror root directory of the base mirror of each target platform. Directory naming information the second target directory may be understood as the target directory after modification of the first directory naming information in the first target directory to obtain the second directory naming information.
Optionally, when any directory naming information in the first target directory and any soft link information in the mirror root directory of the base mirror image of each target platform are the same, the directory naming information needs to be modified to be distinguished from the same soft link information in the mirror root directory of the base mirror image of each target platform, so that the system inherent file is prevented from being lost, and the mirror constructor cannot be started.
In this embodiment, by comparing the first directory naming information in the first target directory with the target soft link information in the mirror root directory of the base mirror image of each target platform, if the first directory naming information is consistent with the target soft link information, the first directory naming information is modified to obtain the second directory naming information, so as to achieve the technical effect of avoiding the system file loss and the mirror image builder startup failure
In one embodiment, after obtaining the platform images corresponding to the target platforms respectively, the method further includes: uploading the mirror images of the platforms to a mirror image warehouse;
the method further comprises the steps of:
obtaining a mirror image list corresponding to each platform mirror image; and generating a mirror image list according to each mirror image list, and uploading the mirror image list to a mirror image warehouse.
The mirror image warehouse is stored in the docker server and is used for storing all the platform mirror images constructed by the embodiment, the mirror image list can be understood as a unique identity identification code of each platform mirror image, mirror image lists among different platform mirror images are different, the mirror image list can be used for searching the required platform mirror images through the mirror image list, the mirror image list can be multiple but different in name, and only one mirror image list comprises all the mirror image lists.
In this embodiment, after finishing the construction of the platform images, the dock server uploads the successfully constructed platform images to the image warehouse convenient for taking, further integrates the platform images, attaches an identification code (i.e., an image list) to each platform image, and integrates all the image lists to form an image list, and the image list is uploaded to the image warehouse at the same time, so that the required platform images can be quickly found out according to the list, thereby accelerating the speed of calling the platform images.
In an exemplary embodiment, as shown in fig. 4, a detailed step of a method for constructing a platform image includes:
and downloading and constructing a mirror image builder by a docker server. The platform architecture of the builder mirror depends on a docker server, and has no specific hard requirements, such as a docker server of a universal amd64 platform; the builder image needs to be provided with relevant tools such as dpkg-deb (Debian software package (. Deb file)), RPM2cpio (RPM software package (. RPM file)), and the like.
2. And downloading a software installation package of the target platform. The source of the software installation package can be an official software source or self-compiled company software. But requires an architecture that supports the target platform. Such as an installation package supporting opensh services for a, B, and C. If a dependency package exists, the dependency package is also provided, and the scope of the dependency package is determined according to the software package installed in the base image of the target platform.
3. The installation package is decompressed to the first/target directory. The different tools are used to decompress the installation packages according to the different types. Currently the dominant types are the Debian and RPM packages, with decompression operations using dpkg-deb and RPM2cpio tools, respectively.
4. And comparing the directory name in the first/target directory with the soft link names in the mirror root directory of the basic mirror of each target platform, and modifying the directory name in the first/target directory if the names are consistent to obtain a second/target directory. Because of the soft link in the root directory of the base image, the copy function of the file of the docker can create a directory with the same name as the soft link in the target image, and cover the original soft link of the target image, so that some system files are lost, and the container is started to crash.
5. And downloading the base image of the target platform, and copying the second/target directory content of the builder container into a base image root directory (/) by using a copy function of the file of the dock. The principle of the method is that the mirror image layer of the builder container (the layer contains all contents under the second/target directory) is exported and then merged into the basic mirror image, so that the integration of the mirror images is realized.
6. And uploading each constructed platform image to an image warehouse.
7. And making a manifest list and uploading the list to a mirror warehouse. The image list (manifest) is a file in which basic information of an image, such as architecture, size, and the like, is contained. And the manifest list is a list of mirror images for storing mirror image information of a plurality of different os/ars. We can create a manifest list to point to images of one or more different platform architectures (e.g., an image of ubuntu20-amd64 and a image of ubuntu20-arm 64) and then provide a unique image name to the user (e.g., ubuntu 20).
Compared with the prior art, the application has the following advantages:
1. according to the number of the platform types of the target platform, the mirror image constructors with the same number are started in parallel, so that the problem that the software installation package cannot normally run after being decompressed due to the fact that the platform types are not consistent can be avoided, and meanwhile, the technical effect of constructing multiple platform mirror images in parallel is achieved.
2. Under the condition that the first directory naming information of the first target directory is consistent with the target soft link information, modifying the first directory naming information into second directory naming information different from the target soft link information, performing the above traversal and modification on all contents in the first target directory, and preventing soft link information from being covered to cause the mirror image constructor to start up and crash when a basic mirror image is constructed subsequently.
3. The process of constructing the mirror image of each platform is carried out in the corresponding mirror image constructor, so that plug-in buildx in the docker server is not required to be compatible, meanwhile, the corresponding relationship between the mirror image of the platform and the mirror image constructor is formed, a plurality of platforms are not required to be compatible, and the resource cost is reduced.
4. And finally, forming a mirror image list composed of mirror image lists, and quickly searching through the list, and realizing cross-platform construction platform mirror images and cross-platform calling platform mirror images.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a platform mirror image construction device for realizing the above-mentioned platform mirror image construction method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in the embodiment of the device for constructing one or more platform images provided below may be referred to the limitation of the method for constructing a platform image hereinabove, and will not be described herein.
In an exemplary embodiment, as shown in fig. 5, there is provided a platform image constructing apparatus, including: an acquisition module 501, a decompression module 502, a second target directory generation module 503, and a platform image construction module 504, wherein:
the obtaining module 501 is configured to obtain target platforms corresponding to the images of the platforms to be built, and obtain software installation packages corresponding to the target platforms, and base images of the target platforms.
The decompression module 502 is configured to obtain, for each target platform, a corresponding image builder, and decompress each software installation package to a first target directory in the image builder corresponding to each target platform.
And the second target directory generating module 503 is configured to process each first target directory based on the soft link information of the mirror root directory of the base mirror of each target platform, to obtain a second target directory corresponding to each target platform.
The platform image construction module 504 is configured to write the content of the second target directory into an image root directory of the base image of the corresponding target platform, so as to obtain the platform images corresponding to the target platforms respectively.
In one embodiment, each mirror image builder carries multiple types of decompression tools, and the decompression module 502 is specifically configured to obtain, for each mirror image builder, an installation package type of each software installation package, and obtain, from the multiple types of decompression tools carried in the mirror image builder, a decompression tool of a target type that is matched with the installation package type; and decompressing each software installation package to a first target catalog in each mirror image constructor through a decompression tool of the target type.
In one exemplary embodiment, the multiple types of decompression tools carried in the mirror builder include: the decompression module 502 is specifically further configured to use the debrian software package decompression tool as a target type decompression tool when the installation package type is a debrian software package type; in the case that the installation package type is the RPM software package type, taking the RPM software package decompression tool as a decompression tool of a target type.
In one embodiment, the number of platform types of the target platform is specifically obtained before entering the decompression module 502; the same number of mirror image constructors as the number of platform types are created in parallel.
In one embodiment, the second target directory generating module 503 is specifically configured to obtain first directory naming information included in the first target directory, and soft link information included in a mirror root directory of the base mirror of each target platform; under the condition that the first directory naming information is consistent with the target soft link information, acquiring second directory naming information corresponding to the soft link information, and updating the first directory naming information contained in the first target directory into the second directory naming information; the target soft link information is any one of soft link information contained in the mirror root directory of the basic mirror of each target platform.
In one embodiment, the device is further specifically configured to upload each platform image to an image repository; obtaining a mirror image list corresponding to each platform mirror image; and generating a mirror image list according to each mirror image list, and uploading the mirror image list to a mirror image warehouse.
The modules in the above-described platform image constructing apparatus may be implemented in whole or in part by software, hardware, or a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one exemplary embodiment, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 6. The computer device includes a processor, a memory, an Input/Output interface (I/O) and a communication interface. 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. Wherein the processor of the computer device is configured 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, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is used for storing corresponding target platform data, target platform software installation package data, target platform basic mirror image data, mirror 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 the external device. The communication interface of the computer device is used for communicating with an external terminal through a network connection. The computer program, when executed by a processor, implements a method of constructing a platform image.
It will be appreciated by those skilled in the art that the structure shown in fig. 6 is merely a block diagram of some of the structures associated with the present application and is not limiting of the computer device to which the present application may be applied, and that a particular computer device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
In an exemplary embodiment, a computer device is provided, including a memory and a processor, where the memory stores a computer program, and the processor implements the method for building a platform image of the above embodiment when the computer program is executed.
In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, which when executed by a processor implements the method of constructing a platform image of the above embodiments.
In an embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the method of constructing a platform image of the above-described embodiments.
It should be noted that, the user information (including, but not limited to, user equipment information, user personal information, etc.) and the data (including, but not limited to, data for analysis, stored data, presented data, etc.) referred to in the present application are information and data authorized by the user or sufficiently authorized by each party, and the collection, use, and processing of the related data are required to meet the related regulations.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in the various embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the various embodiments provided herein may include at least one of relational databases and non-relational databases. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processors referred to in the embodiments provided herein may be general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic units, quantum computing-based data processing logic units, etc., without being limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples only represent a few embodiments of the present application, which are described in more detail and are not to be construed as limiting the scope of the present application. It should be noted that it would be apparent to those skilled in the art that various modifications and improvements could be made without departing from the spirit of the present application, which would be within the scope of the present application. Accordingly, the scope of protection of the present application shall be subject to the appended claims.
Claims (10)
1. A method for constructing a platform image, applied to a docker server, the method comprising:
acquiring target platforms corresponding to the platform images to be built respectively, and acquiring software installation packages corresponding to the target platforms and basic images of the target platforms;
for each target platform, acquiring a corresponding mirror image constructor, and decompressing each software installation package to a first target directory in the mirror image constructor corresponding to each target platform;
processing each first target directory based on soft link information of a mirror image root directory of a basic mirror image of each target platform to obtain a second target directory corresponding to each target platform;
and writing the content of the second target directory into a mirror image root directory of the basic mirror image of the corresponding target platform to obtain platform mirror images respectively corresponding to the target platforms.
2. The method of claim 1, wherein each of said mirror image builders carries therein a plurality of types of decompression tools; decompressing each software installation package to a first target directory in a mirror image constructor corresponding to each target platform, wherein the decompressing comprises the following steps:
for each mirror image constructor, acquiring the type of an installation package of each software installation package, and acquiring a target type decompression tool matched with the type of the installation package from a plurality of types of decompression tools carried in the mirror image constructor;
and decompressing each software installation package to a first target catalog in each mirror image constructor through a decompression tool of the target type.
3. The method of claim 2, wherein the plurality of types of decompression tools carried in the mirror builder comprise: a Debian software package decompression tool and an RPM software package decompression tool;
the obtaining a target type decompression tool matched with the installation package type from a plurality of types of decompression tools carried in the mirror image constructor comprises the following steps:
taking the Debian software package decompression tool as the decompression tool of the target type under the condition that the installation package type is the Debian software package type;
and taking the RPM software package decompression tool as the decompression tool of the target type under the condition that the installation package type is the RPM software package type.
4. The method of claim 2, wherein before obtaining the corresponding mirror builder for each of the target platforms, further comprising:
acquiring the number of platform types of the target platform;
the same number of mirror image constructors as the number of platform types are created in parallel.
5. The method according to claim 1, wherein the processing the first target directories based on the soft link information of the mirror root directory of the base mirror of each target platform to obtain the second target directory corresponding to each target platform includes:
acquiring first directory naming information contained in the first target directory and soft link information contained in a mirror image root directory of a basic mirror image of each target platform;
acquiring second directory naming information corresponding to the soft link information under the condition that the first directory naming information is consistent with the target soft link information, and updating the first directory naming information contained in the first target directory into the second directory naming information; the target soft link information is any one of soft link information contained in a mirror root directory of a basic mirror of each target platform.
6. The method of claim 1, wherein after obtaining the platform images corresponding to the target platforms, further comprises:
uploading each platform mirror image to the mirror image warehouse;
the method further comprises the steps of:
obtaining a mirror image list corresponding to each platform mirror image;
and generating a mirror image list according to each mirror image list, and uploading the mirror image list to the mirror image warehouse.
7. A device for constructing a platform image, applied to a docker server, comprising:
the system comprises an acquisition module, a storage module and a storage module, wherein the acquisition module is used for acquiring target platforms corresponding to the platform images to be built respectively, and acquiring software installation packages corresponding to the target platforms and basic images of the target platforms;
the decompression module is used for acquiring corresponding mirror image constructors for each target platform and decompressing each software installation package to a first target catalog in the mirror image constructors corresponding to each target platform;
the second target catalog generation module is used for processing the first target catalogs to obtain second target catalogs corresponding to the target platforms according to the soft link information of the mirror root catalogs of the basic mirror of the target platforms;
and the platform image construction module is used for writing the content of the second target directory into an image root directory of the basic image of the corresponding target platform to obtain the platform images respectively corresponding to the target platforms.
8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 6 when the computer program is executed.
9. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311603203.5A CN117555563A (en) | 2023-11-28 | 2023-11-28 | Method and device for constructing platform mirror image, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311603203.5A CN117555563A (en) | 2023-11-28 | 2023-11-28 | Method and device for constructing platform mirror image, computer equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117555563A true CN117555563A (en) | 2024-02-13 |
Family
ID=89823041
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311603203.5A Pending CN117555563A (en) | 2023-11-28 | 2023-11-28 | Method and device for constructing platform mirror image, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117555563A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117950646A (en) * | 2024-03-26 | 2024-04-30 | 苏州元脑智能科技有限公司 | Software development method, device, computer equipment, storage medium and program product |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111522560A (en) * | 2020-04-21 | 2020-08-11 | 北京三快在线科技有限公司 | Software installation method and device, storage medium and electronic equipment |
CN112506615A (en) * | 2020-12-11 | 2021-03-16 | 浪潮电子信息产业股份有限公司 | JavaWeb application deployment method, device, equipment and storage medium |
-
2023
- 2023-11-28 CN CN202311603203.5A patent/CN117555563A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111522560A (en) * | 2020-04-21 | 2020-08-11 | 北京三快在线科技有限公司 | Software installation method and device, storage medium and electronic equipment |
CN112506615A (en) * | 2020-12-11 | 2021-03-16 | 浪潮电子信息产业股份有限公司 | JavaWeb application deployment method, device, equipment and storage medium |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117950646A (en) * | 2024-03-26 | 2024-04-30 | 苏州元脑智能科技有限公司 | Software development method, device, computer equipment, storage medium and program product |
CN117950646B (en) * | 2024-03-26 | 2024-06-07 | 苏州元脑智能科技有限公司 | Software development method, device, computer equipment, storage medium and program product |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111492347B (en) | System and method for updating a container | |
US10140461B2 (en) | Reducing resource consumption associated with storage and operation of containers | |
CN111930473B (en) | Method and apparatus for deploying image recognition service on container cloud | |
CN111897623B (en) | Cluster management method, device, equipment and storage medium | |
CN112256286A (en) | Application running method and device and computer storage medium | |
CN117555563A (en) | Method and device for constructing platform mirror image, computer equipment and storage medium | |
CN104750492A (en) | Startup control method and device for mobile device on basis of embedded operating system | |
CN112965761B (en) | Data processing method, system, electronic equipment and storage medium | |
CN101490645A (en) | Method and apparatus for virtualization of appliances | |
CN104731622A (en) | Application program loading method and device and mobile terminal | |
US8516480B1 (en) | Enabling offline work in a virtual data center | |
CN113296891B (en) | Platform-based multi-scene knowledge graph processing method and device | |
CN112612489B (en) | Method and device for constructing upgrade package of software and electronic equipment | |
JP2009544085A (en) | How to use global variables for PEI modules in EFI based firmware | |
CN115774701B (en) | Data sharing method and device, electronic equipment and storage medium | |
CN116466953B (en) | Modularized front-end development method, device, computer equipment and storage medium | |
CN110502251B (en) | Application installation method and device | |
CN113986858B (en) | Linux compatible android system shared file operation method and device | |
US20230401080A1 (en) | Reducing deployment time for container clones in computing environments | |
US9262304B2 (en) | Methods and systems for testing interactions between mobile applications | |
CN115525300A (en) | Incremental mirror image packaging method and system in container cloud scene | |
US20220138146A1 (en) | Merging composite images into a new filesystem namespace | |
CN114995834A (en) | Artificial intelligence application deployment environment construction method and device | |
US20180225112A1 (en) | Seamless extension porting | |
CN114237638A (en) | Operating system installation method and device, computer equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |