CN116302361A - Mirror image construction method and device, processor and electronic equipment - Google Patents

Mirror image construction method and device, processor and electronic equipment Download PDF

Info

Publication number
CN116302361A
CN116302361A CN202310345300.2A CN202310345300A CN116302361A CN 116302361 A CN116302361 A CN 116302361A CN 202310345300 A CN202310345300 A CN 202310345300A CN 116302361 A CN116302361 A CN 116302361A
Authority
CN
China
Prior art keywords
construction
image
file
operating system
image construction
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
Application number
CN202310345300.2A
Other languages
Chinese (zh)
Inventor
陈中渊
闫明阳
张杭俊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202310345300.2A priority Critical patent/CN116302361A/en
Publication of CN116302361A publication Critical patent/CN116302361A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45562Creating, deleting, cloning virtual machine instances
    • YGENERAL 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
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE 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/00Energy 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)
  • Computer Security & Cryptography (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a mirror image construction method, a mirror image construction device, a processor and electronic equipment. Relates to the field of mirroring. The method comprises the following steps: calling the mirror images stored in the preset version library to construct a text file; reading basic mirror image information in the mirror image construction text file; constructing a temporary operation container according to the basic mirror image information and a target command, wherein the target command is used for determining a hardware architecture and an operating system corresponding to the temporary operation container; operating the temporary operation container, and acquiring a hardware architecture and an operating system corresponding to the temporary operation container, which are output by the temporary operation container after the temporary operation container executes the target command; and sending the mirror image construction text file to a target construction machine. The invention solves the technical problems of complicated image construction steps and low image construction efficiency caused by the fact that a specific version library corresponding to a hardware architecture and an operating system is required to be called to take an image construction text file when an image is constructed on a construction machine in the related art.

Description

Mirror image construction method and device, processor and electronic equipment
Technical Field
The present invention relates to the field of mirroring, and in particular, to a method, an apparatus, a processor, and an electronic device for mirror construction.
Background
The existing cross-architecture mirroring method generally comprises the steps of manually classifying the mirror images of different architectures into different git version libraries and configuring different construction machines corresponding to different architectures and operating systems, and can be known that in the related art, when the mirror images are constructed on the construction machines, the text files for constructing the mirror images need to be called from the specific version libraries corresponding to the hardware architecture and the operating systems, so that the technical problems of complicated mirror image construction steps and low mirror image construction efficiency are caused.
In view of the above problems, no effective solution has been proposed at present.
Disclosure of Invention
The embodiment of the invention provides a mirror image construction method, a device, a processor and electronic equipment, which at least solve the technical problems of complicated mirror image construction steps and low mirror image construction efficiency caused by the fact that a text file for constructing a mirror image needs to be called from a specific version library corresponding to a hardware architecture and an operating system when the mirror image is constructed on a construction machine in the related art.
According to an aspect of an embodiment of the present invention, there is provided a mirror image construction method, including: calling the mirror images stored in the preset version library to construct a text file; reading basic mirror image information in the mirror image construction text file; constructing a temporary operation container according to the basic mirror image information and a target command, wherein the target command is used for determining a hardware architecture and an operating system corresponding to the temporary operation container; operating the temporary operation container, and acquiring a hardware architecture and an operating system corresponding to the temporary operation container, which are output by the temporary operation container after the temporary operation container executes the target command; and sending the image construction text file to a target construction machine, wherein a hardware architecture corresponding to the target construction machine and a hardware architecture corresponding to an operating system and the temporary operation container are consistent with the operating system, and the target construction machine is used for calling the image construction file corresponding to the image construction text file from the preset version library and constructing an image according to the image construction file.
Optionally, the constructing a temporary operation container according to the base mirror information and the target command includes: determining a consistency result of whether the hardware architecture corresponding to the local hardware architecture and the local operating system and the basic mirror image information is consistent with the operating system or not; and under the condition that the consistency result is that the local hardware architecture is inconsistent with the hardware architecture corresponding to the local operating system and the basic image information and the operating system, constructing the temporary operation container according to the basic image information and the target command.
Optionally, after determining the consistency result of whether the local hardware architecture and the hardware architecture corresponding to the local operating system and the base image information are consistent with the operating system, the method further includes: when the consistency result is that the local hardware architecture is consistent with the hardware architecture corresponding to the local operating system and the basic image information and the operating system, an image construction file corresponding to the image construction text file is called from the preset version library; and constructing the mirror image according to the mirror image construction file.
Optionally, before the retrieving the image construction file corresponding to the image construction text file from the predetermined version library, the method further includes: determining an image construction neglected file according to the image construction text file and the preset version library, wherein the image construction neglected file represents a file which does not need to be called from the preset version library in the image construction process; and determining the image construction file according to the image construction text file and the image construction neglected file.
Optionally, the determining the image construction ignore file according to the image construction text file and the predetermined version library includes: determining dependent items included in the mirror image construction text file; and determining the image construction neglected file according to the dependency term and the preset version library.
Optionally, the constructing the mirror image according to the mirror image constructing file includes: and under the condition that a plurality of mirror image construction files are provided, constructing a plurality of mirror images in parallel according to the plurality of mirror image construction files.
Optionally, after the sending the mirror image build text file to the target build machine, the method further includes: and receiving a construction result sent by the target construction machine, wherein the construction result represents a construction result of the construction mirror image of the target construction machine.
According to an aspect of an embodiment of the present invention, there is provided a mirror image constructing apparatus including: the calling module is used for calling the mirror images stored in the preset version library to construct a text file; the reading module is used for reading the basic mirror image information in the mirror image construction text file; the construction module is used for constructing a temporary operation container according to the basic mirror image information and a target command, wherein the target command is used for determining a hardware architecture and an operating system corresponding to the temporary operation container; the acquisition module is used for operating the temporary operation container and acquiring a hardware architecture and an operating system corresponding to the temporary operation container which are output after the temporary operation container executes the target command; the sending module is used for sending the image construction text file to a target construction machine, wherein a hardware architecture corresponding to the target construction machine and a hardware architecture corresponding to the operating system and the temporary operation container are consistent with the operating system, and the target construction machine is used for calling the image construction file corresponding to the image construction text file from the preset version library and constructing an image according to the image construction file.
According to an aspect of an embodiment of the present invention, there is provided a processor, configured to execute a program, where the program executes any one of the above-mentioned image construction methods.
According to an aspect of an embodiment of the present invention, there is provided an electronic device including one or more processors and a memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement any one of the above-described image construction methods.
In the embodiment of the invention, a mirror image construction text file stored in a preset version library is called, basic mirror image information in the mirror image construction text file is read, a temporary operation container is constructed according to the basic mirror image information and a target command, the temporary operation container is operated, a hardware architecture and an operating system corresponding to the temporary operation container, which are output after the temporary operation container executes the target command, are obtained, the mirror image construction text file is sent to a target construction machine, wherein the hardware architecture and the operating system corresponding to the target construction machine are consistent with the hardware architecture and the operating system corresponding to the temporary operation container, so that the target construction machine calls the mirror image construction file corresponding to the mirror image construction text file from the preset version library, and the mirror image is constructed according to the mirror image construction file. The image construction text file corresponding to the hardware architecture and the operating system is directly sent to the target construction machine, and the target construction machine can directly call the image construction file according to the image construction text file so as to achieve the effect of quickly and conveniently constructing the image, thereby solving the technical problems of complicated image construction steps and low image construction efficiency caused by the fact that the image construction text file needs to be called from a specific version library corresponding to the hardware architecture and the operating system when the image is constructed on the construction machine in the related technology.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application, illustrate and explain the application and are not to be construed as limiting the application. In the drawings:
FIG. 1 is a flow chart of a mirror image construction method provided according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a mirror build system provided by an alternative embodiment of the present invention;
FIG. 3 is a flow chart of a mirror image construction provided by an alternative embodiment of the present invention;
FIG. 4 is a block diagram of a mirror image construction apparatus provided according to an embodiment of the present application;
fig. 5 is a schematic diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that, related information (including, but not limited to, user equipment information, user personal information, etc.) and data (including, but not limited to, data for presentation, analyzed data, etc.) related to the present disclosure are information and data authorized by a user or sufficiently authorized by each party.
First, partial terms or terminology appearing in describing embodiments of the present application are applicable to the following explanation:
docker, pull mirror image, build mirror image, push mirror image tool.
The construction machine comprises: the Docker software is installed and mirrored machines can be built.
Mirror image: mirroring is one of the core concepts in Docker, which is a lightweight, executable, stand-alone software package that includes all of the content required to run an application, including code, runtime environments, system tools, library files, and so forth. The mirror image can be seen as a read-only template, which is the basis for creating the Docker container.
Base mirror image: refers to the most basic image used in the Docker container, which contains a minimal operating system, as well as some basic components and tools that can run other software.
Basic mirror information: the instruction information for constructing the base image is contained in the Dockerfile file, and comprises the name, version, source, image size and the like of the base image.
Dockerf file: the Dockerfile file is a text file used to define the Docker mirror construction process. It contains a series of instructions and configurations including base image information, file copy information, etc. to tell the Docker engine how to construct a Docker image.
Git version library: the repository tool storing code is also understood to be a Git version store that is a distributed version control system for managing source code. It allows developers to collaboratively develop the same project among a plurality of computers and record modification history of each developer, thereby improving efficiency of code collaboration and management.
The dependency term: in a Dockerfile file, dependencies generally refer to libraries, frameworks, tools, and other software packages that an application depends on. The building process of an application is described in the Dockerfile file by a series of instructions, including the dependencies required to install and configure the application.
Dockerignore: dockerignore is a configuration file that specifies which files or directories need not be included in the image when constructing a Docker image. Similarly to the gitigore, the Dockerignore file is also a plain text file, each line specifying a path of files or directories that need to be ignored.
Node_modules the development tool nodejs widely used in front-end stores dependent folders with a very large number of small files.
The invention will be described with reference to preferred implementation steps, and fig. 1 is a flowchart of a mirror image construction method according to an embodiment of the present application, as shown in fig. 1.
Firstly, it should be noted that the application scenario of the method provided by the present application is a system composed of a plurality of building machines and a git version library, where the git version library includes a plurality of mirrored building text files corresponding to different hardware architectures and hardware systems. The execution main body of the image construction method provided by the embodiment of the application is one construction machine in a plurality of construction machines, which can be called an entry construction machine, and the image construction operation can be executed by only calling the image construction text file in the git version library by the one entry construction machine, and then sending the image construction text file to the construction machine corresponding to the hardware architecture and the operating system by judging the hardware architecture and the operating system.
The following describes a mirror image construction method provided in an embodiment of the present application, where the method includes the following steps:
s101, calling a mirror image stored in a preset version library to construct a text file;
In step S101 provided in the present application, a mirror image construction text file stored in a predetermined version library is called, where the predetermined version library is a git version library, and may include a plurality of mirror image construction text files corresponding to a hardware system with different hardware architectures, where the mirror image construction text file may be a Dockerfile file. By the method provided by the application, only one version library is required to be managed in a unified way, and different version libraries are not required to be distinguished according to different architectures, so that the mirror image construction process is convenient.
Step S102, basic mirror image information in a mirror image construction text file is read;
step S103, constructing a temporary operation container according to the basic mirror image information and a target command, wherein the target command is used for determining a hardware architecture and an operating system corresponding to the temporary operation container;
in steps S102-S103 provided in the present application, the base image information in the image construction text file is read to construct a temporary operation container according to the base image information and the target command, where the main purpose of constructing the temporary operation container is to create an operable container instance on the basis of the base image, so as to operate some test, debug or other temporary tasks therein, i.e. a temporary container constructed based on the target command, so as to execute the target command without constructing a new image, and the temporary container will be deleted by itself after the target command is executed, without occupying memory, thereby achieving the effect of saving resources. By temporarily running the container, some modifications and debugging can also be made on the basis of the base image in order to better understand and handle problems in the container environment.
The operating system may be, for example, windows, or a linux system, and the hardware architecture may be an architecture such as an x86 processor architecture.
Step S104, operating the temporary operation container, and acquiring a hardware architecture and an operating system corresponding to the temporary operation container which are output after the temporary operation container executes the target command;
in step S104 provided in the present application, by running the temporary running container, the hardware architecture and the operating system corresponding to the temporary running container that are output after the temporary running container executes the target command may be obtained. By the method, the hardware architecture and the operating system can be automatically identified, and a complex and error-prone manual configuration mode is not needed.
Step S105, sending the image construction text file to a target construction machine, wherein the hardware architecture corresponding to the target construction machine is consistent with the hardware architecture corresponding to the operating system and the temporary operation container and the operating system, and the target construction machine is used for calling the image construction file corresponding to the image construction text file from a preset version library and constructing an image according to the image construction file.
In step S105 provided in the present application, the image construction text file is sent to the target construction machine whose corresponding hardware architecture and operating system are consistent with those of the temporary operation container, and the image construction file corresponding to the image construction text file can be called from the predetermined version library, and the image is constructed according to the image construction file. And the target building machine is not required to call a specific version library, so that the time for building the mirror image is saved, and the efficiency for building the mirror image is improved.
Through the steps, the image construction text file stored in the preset version library is called, basic image information in the image construction text file is read, a temporary operation container is constructed according to the basic image information and the target command, the temporary operation container is operated, a hardware architecture and an operating system corresponding to the temporary operation container, which are output after the temporary operation container executes the target command, are obtained, the image construction text file is sent to the target construction machine, wherein the hardware architecture and the hardware architecture corresponding to the operating system and the temporary operation container corresponding to the target construction machine are consistent with the operating system, so that the target construction machine calls the image construction file corresponding to the image construction text file from the preset version library, and the image is constructed according to the image construction file. The image construction text file corresponding to the hardware architecture and the operating system is directly sent to the target construction machine, and the target construction machine can directly call the image construction file according to the image construction text file so as to achieve the effect of quickly and conveniently constructing the image, thereby solving the technical problems of complicated image construction steps and low image construction efficiency caused by the fact that the image construction text file needs to be called from a specific version library corresponding to the hardware architecture and the operating system when the image is constructed on the construction machine in the related technology.
As an alternative embodiment, constructing a temporary run container according to the base image information and the target command includes: determining a consistency result of whether the hardware architecture corresponding to the local hardware architecture and the local operating system and the basic mirror image information is consistent with the operating system or not; and under the condition that the consistency result is that the hardware architecture corresponding to the local hardware architecture, the local operating system and the basic mirror image information is inconsistent with the operating system, constructing a temporary operation container according to the basic mirror image information and the target command.
In this embodiment, according to the base image information, only whether the hardware architecture corresponding to the local hardware architecture and the local operating system and the base image information are consistent with the operating system or not can be determined, that is, only whether the hardware architecture corresponding to the local hardware architecture and the local operating system and the base image information are consistent with the operating system or not can be determined, and in the case that the hardware architecture corresponding to the local hardware architecture and the local operating system and the hardware architecture corresponding to the base image information are inconsistent with the operating system, the hardware architecture corresponding to the base image information and the operating system are determined so as to send the image construction text file to the corresponding constructor, in this case, the hardware architecture corresponding to the base image information and the operating system can be determined by determining the hardware architecture corresponding to the temporary operation container and the operating system. Therefore, the temporary operation container can be constructed according to the basic image information and the target command, so that the purposes of determining the temporary operation container, the hardware architecture corresponding to the basic image information and the operating system are achieved.
As an optional embodiment, after determining whether the hardware architecture corresponding to the local hardware architecture and the local operating system and the base image information are consistent with the operating system, the method further includes: under the condition that the consistency result is that the local hardware architecture is consistent with the hardware architecture corresponding to the local operating system and the basic image information and the operating system, the image construction file corresponding to the image construction text file is called from a preset version library; and constructing the mirror image according to the mirror image construction file.
In this embodiment, according to the base image information, only whether the hardware architecture corresponding to the local hardware architecture and the local operating system and the base image information are consistent with the operating system or not can be determined, that is, only whether the hardware architecture corresponding to the local hardware architecture and the base image information is consistent with the operating system or not can be determined, and when the consistency result is that the hardware architecture corresponding to the local hardware architecture and the base image information is consistent with the operating system, the retrieved image construction text file is the file that can be used by the current construction machine, therefore, the image construction file corresponding to the image construction text file can be directly retrieved from the predetermined version library, and the image is constructed according to the image construction file.
As an alternative embodiment, before retrieving the image construction file corresponding to the image construction text file from the predetermined version library, the method further includes: determining an image construction neglected file according to the image construction text file and a preset version library, wherein the image construction neglected file represents a file which does not need to be called from the preset version library in the image construction process; and determining the image construction file according to the image construction text file and the image construction neglected file.
In this embodiment, the image construction neglected file may be, for example, a docerignore file, in this process, a text file and a predetermined version library may be quickly generated according to the image construction, and when the image construction file is determined, only the file to be used is included in the file, so that not only the image construction file is accelerated, but also the image construction process is accelerated.
As an alternative embodiment, determining the image construction ignore file from the image construction text file and the predetermined version library includes: determining dependent items included in the mirror image construction text file; and determining the mirror image construction neglected file according to the dependent item and the preset version library.
In this embodiment, the determination process of the image construction ignore file is described, which can be obtained from the dependency item included in the image construction text file and the predetermined version library. By the embodiment, the dependency items in the Dockerfile can be automatically identified, the directory is simplified to be built, redundant copies are avoided, and the mirror image building speed is increased.
As an alternative embodiment, building a mirror image from a mirror image build file includes: and under the condition that a plurality of mirror image construction files are provided, constructing a plurality of mirror images in parallel according to the plurality of mirror image construction files.
In this embodiment, when the number of image building files is multiple, it means that the number of image building text files is also multiple, corresponding basic image information can be read from the multiple image building text files, and when the hardware architecture corresponding to the multiple basic image information is consistent with the operating system and the local hardware architecture and the local operating system, the multiple image building files can be called according to the multiple image building text files to build multiple images in parallel. Under the condition that the hardware architecture and the operating system corresponding to the plurality of basic image information are inconsistent with the local hardware architecture and the local operating system, the hardware architecture and the operating system corresponding to the plurality of temporary operation containers are obtained through the plurality of basic image information, and under the condition that the hardware architecture and the operating system corresponding to the plurality of temporary operation containers are identical, the hardware architecture and the operating system corresponding to the plurality of temporary operation containers are sent to a target building machine, so that the target building machine can build text files according to the plurality of images, and a plurality of image building files are called to build the plurality of images in parallel. The construction opportunity starts multithreading parallel construction, cpu and network resources are used to the greatest extent, the construction speed is increased, and the overall speed reduction caused by the blocking of the construction of a single mirror image is avoided.
As an alternative embodiment, after sending the mirror build text file to the target build machine, the method further comprises: and receiving a construction result sent by the target construction machine, wherein the construction result represents a construction result of the mirror image constructed by the target construction machine.
In this embodiment, the construction result of the target construction machine is fed back to the entry construction machine, so that the entry construction machine can know the state of the mirror image constructed by all construction machines in the whole system, and the coordination and unified management are facilitated.
Based on the foregoing embodiments and optional embodiments, an optional implementation is provided, and is specifically described below.
In the related art, the cross-architecture mirroring method generally classifies mirrors of different architectures to different git version libraries manually, and then configures different building machines corresponding to different architectures and operating systems, so that the problems of complex version management, complex configuration, more manual intervention, easy error, incapability of automatically identifying the architectures and the operating systems, slow building due to dependence on manual configuration and incapability of automatically removing redundant files in a catalog, slow building due to the fact that one machine only participates in building by one thread, and complex flow and the like are caused by the fact that the content of a plurality of version libraries is slowly built and is required to be pulled for merging simultaneously.
In view of this, an alternative embodiment of the present invention provides a mirror image construction method, which can solve the above-mentioned problems, and an alternative embodiment of the present invention is described below.
Fig. 2 is a schematic diagram of a mirror image construction system provided in an alternative embodiment of the present invention, as shown in fig. 2, where the system is a system composed of a plurality of construction machines and a git version library, and the git version library includes a plurality of mirror image construction text files corresponding to different hardware architectures and hardware systems. The execution main body of the image construction method provided by the embodiment of the application is one construction machine in a plurality of construction machines, which is called an entry construction machine, and the image construction operation can be executed only by calling the image construction text file in the git version library by the one entry construction machine and then sending the image construction text file to the construction machine corresponding to the hardware architecture and the operating system by judging the hardware architecture and the operating system.
FIG. 3 is a flow chart of image construction provided in an alternative embodiment of the present invention, as shown in FIG. 3, an entry builder sends an image construction text file to a builder corresponding to a hardware architecture and an operating system, the builder can determine whether the hardware architecture of the image construction text file and the builder is consistent with the operating system, and if so, determine an image construction ignore file from a version library according to the image construction text file, and determine an image construction file to construct an image according to the image construction file. In the case of including a plurality of image construction files, a plurality of images are constructed in parallel. And feeding back the construction result to the entrance construction machine after the construction is completed. The method comprises the following specific steps:
S1, the entry builder pulls all Dockerfile files from a git version library;
s2, reading basic mirror image information recorded in the Dockerf file one by one;
s3, constructing a temporary operation container by using a Docker tool according to the basic mirror image information, examining the architecture and the operating system of the temporary operation container, and recording the temporary operation container.
It should be noted that mirror image construction is best practice to construct on a construction machine that has the same architecture and operating system as itself. The invention groups the images to be built according to the recorded architecture and operating system, and dispatches the building machines of other architectures and operating systems to wait for building through ssh protocol, and the building machines of the following classifications are provided according to different combinations of the architectures and the operating systems:
windows operating system, x86 architecture, etc.;
a linux operating system, x86 architecture, etc.
S4, transmitting the Dockerfile to a constructor of a corresponding architecture and operating system;
s5, each received construction opportunity of the Dockerfile checks the Dockerfile allocated to the Dockerfile, and checks whether the architecture and the operating system corresponding to the basic mirror image information are consistent with the architecture and the operating system of the Dockerfile;
and S6, under the condition of consistency, checking the dependence contained in the Dockerfile, and dynamically generating the Dockerignore file to accurately construct the catalogue so as to avoid redundant copying.
It should be noted that, when building, the Docker will send all files of the working directory to the build mirror process by default, but the Docker will only refer to part of the dependencies therein, where the redundant part does not need to be sent to the daemon, which may result in excessively long building time. In particular, a large number of small files like node_modules are encountered, which can take up to 1 hour. The Dockerignore file can exclude unnecessary files, so that the Docker can more accurately send the files to the mirror image construction process, and the construction speed is increased.
And S7, under the condition that the scheduled construction machine receives a plurality of Dockerfile files, starting multi-thread parallel construction, using CPU and network resources to the maximum extent, increasing the construction speed, and avoiding overall speed reduction caused by single mirror image construction blocking.
By the alternative embodiments, at least the following advantages can be achieved:
(1) Only one version library is required to be managed in a unified way, and different version libraries are not required to be distinguished according to different architectures;
(2) The framework and the operating system of the mirror image are automatically identified, and a complex and error-prone manual configuration mode is not needed;
(3) Multiple building machines can be scheduled to build in parallel, so that the building speed is increased;
(4) Multithreading can be scheduled on a single building machine to build, so that system resources are utilized to the greatest extent;
(5) Dependency in Dockerfile can be automatically identified, the directory is simplified to be built, redundant copies are avoided, and the building speed is increased.
It should be noted that, for simplicity of description, the foregoing method embodiments are all described as a series of acts, but it should be understood by those skilled in the art that the present invention is not limited by the order of acts described, as some steps may be performed in other orders or concurrently in accordance with the present invention. Further, those skilled in the art will also appreciate that the embodiments described in the specification are all preferred embodiments, and that the acts and modules referred to are not necessarily required for the present invention.
From the description of the above embodiments, it will be clear to a person skilled in the art that the method according to the above embodiments may be implemented by means of software plus the necessary general hardware platform, but of course also by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) comprising several instructions for causing a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the method of the various embodiments of the present invention.
According to an embodiment of the present invention, there is further provided an apparatus for implementing the above-mentioned image construction method, and fig. 4 is a block diagram of a structure of the image construction apparatus provided according to an embodiment of the present application, as shown in fig. 4, where the apparatus includes: the device is described in detail below as a calling module 401, a reading module 402, a constructing module 403, an obtaining module 404 and a sending module 405.
A retrieving module 401, configured to retrieve a mirror image stored in a predetermined version library to construct a text file; the reading module 402 is connected to the retrieving module 401, and is configured to read the basic image information in the image construction text file; the building module 403 is connected to the reading module 402, and is configured to build a temporary operation container according to the base image information and a target command, where the target command is used to determine a hardware architecture and an operating system corresponding to the temporary operation container; the obtaining module 404 is connected to the building module 403, and is configured to run the temporary running container, and obtain a hardware architecture and an operating system corresponding to the temporary running container that are output by the temporary running container after the temporary running container executes the target command; and the sending module 405 is connected to the obtaining module 404, and is configured to send the image construction text file to a target construction machine, where a hardware architecture corresponding to the target construction machine and a hardware architecture corresponding to the operating system and the temporary operation container are consistent with each other, and the target construction machine is configured to retrieve an image construction file corresponding to the image construction text file from the predetermined version library, and construct an image according to the image construction file.
Here, the foregoing invoking module 401, reading module 402, constructing module 403, acquiring module 404 and sending module 405 correspond to steps S101 to S105 in implementing the image constructing method, and the multiple modules are the same as the examples and application scenarios implemented by the corresponding steps, but are not limited to those disclosed in the foregoing embodiments.
According to the image construction device provided by the embodiment of the application, the image construction text file stored in the preset version library is called, basic image information in the image construction text file is read, a temporary operation container is constructed according to the basic image information and a target command, the temporary operation container is operated, a hardware architecture and an operating system corresponding to the temporary operation container which are output after the temporary operation container executes the target command are obtained, the image construction text file is sent to a target construction machine, wherein a hardware architecture and an operating system corresponding to the target construction machine are consistent with the hardware architecture and the operating system corresponding to the temporary operation container, so that the target construction machine calls the image construction file corresponding to the image construction text file from the preset version library, and the image is constructed according to the image construction file. The image construction text file corresponding to the hardware architecture and the operating system is directly sent to the target construction machine, and the target construction machine can directly call the image construction file according to the image construction text file so as to achieve the effect of quickly and conveniently constructing the image, thereby solving the technical problems of complicated image construction steps and low image construction efficiency caused by the fact that the image construction text file needs to be called from a specific version library corresponding to the hardware architecture and the operating system when the image is constructed on the construction machine in the related technology.
The image constructing device comprises a processor and a memory, wherein the modules are stored in the memory as program units, and the processor executes the program units stored in the memory to realize corresponding functions.
The processor includes a kernel, and the kernel fetches the corresponding program unit from the memory. The kernel can be provided with one or more than one kernel, and the technical problems of complicated image construction steps and low image construction efficiency caused by the fact that image construction text files are required to be called from a specific version library corresponding to a hardware architecture and an operating system when an image is constructed on a construction machine in the related art are solved by adjusting kernel parameters.
The memory may include volatile memory, random Access Memory (RAM), and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM), among other forms in computer readable media, the memory including at least one memory chip.
The embodiment of the invention provides a computer readable storage medium, on which a program is stored, which when executed by a processor, implements a mirror image construction method.
The embodiment of the invention provides a processor, which is used for running a program, wherein the program runs to execute a mirror image construction method.
Fig. 5 is a schematic diagram of an electronic device according to an embodiment of the present invention, and as shown in fig. 5, the embodiment of the present invention provides an electronic device, where the device includes a processor, a memory, and a program stored in the memory and executable on the processor, and the processor implements the following steps when executing the program: calling the mirror images stored in the preset version library to construct a text file; reading basic mirror image information in a mirror image construction text file; constructing a temporary operation container according to the basic mirror image information and a target command, wherein the target command is used for determining a hardware architecture and an operating system corresponding to the temporary operation container; operating the temporary operation container, and acquiring a hardware architecture and an operating system corresponding to the temporary operation container which are output after the temporary operation container executes the target command; and sending the image construction text file to a target construction machine, wherein the hardware architecture corresponding to the target construction machine and the hardware architecture corresponding to the operating system and the temporary operation container are consistent with the operating system, and the target construction machine is used for calling the image construction file corresponding to the image construction text file from a preset version library and constructing an image according to the image construction file.
Optionally, constructing a temporary operation container according to the basic mirror information and the target command, including: determining a consistency result of whether the hardware architecture corresponding to the local hardware architecture and the local operating system and the basic mirror image information is consistent with the operating system or not; and under the condition that the consistency result is that the hardware architecture corresponding to the local hardware architecture, the local operating system and the basic mirror image information is inconsistent with the operating system, constructing a temporary operation container according to the basic mirror image information and the target command.
Optionally, after determining whether the hardware architecture corresponding to the local hardware architecture and the local operating system and the base image information are consistent with the operating system, the method further includes: under the condition that the consistency result is that the local hardware architecture is consistent with the hardware architecture corresponding to the local operating system and the basic image information and the operating system, the image construction file corresponding to the image construction text file is called from a preset version library; and constructing the mirror image according to the mirror image construction file.
Optionally, before retrieving the image construction file corresponding to the image construction text file from the predetermined version library, the method further includes: determining an image construction neglected file according to the image construction text file and a preset version library, wherein the image construction neglected file represents a file which does not need to be called from the preset version library in the image construction process; and determining the image construction file according to the image construction text file and the image construction neglected file.
Optionally, determining the image construction ignore file according to the image construction text file and the predetermined version library includes: determining dependent items included in the mirror image construction text file; and determining the mirror image construction neglected file according to the dependent item and the preset version library.
Optionally, building the mirror image from the mirror image building file includes: and under the condition that a plurality of mirror image construction files are provided, constructing a plurality of mirror images in parallel according to the plurality of mirror image construction files.
Optionally, after sending the image build text file to the target build machine, further comprising: and receiving a construction result sent by the target construction machine, wherein the construction result represents a construction result of the mirror image constructed by the target construction machine.
The device herein may be a server, PC, PAD, cell phone, etc.
The present application also provides a computer program product adapted to perform, when executed on a data processing device, a program initialized with the method steps of: calling the mirror images stored in the preset version library to construct a text file; reading basic mirror image information in a mirror image construction text file; constructing a temporary operation container according to the basic mirror image information and a target command, wherein the target command is used for determining a hardware architecture and an operating system corresponding to the temporary operation container; operating the temporary operation container, and acquiring a hardware architecture and an operating system corresponding to the temporary operation container which are output after the temporary operation container executes the target command; and sending the image construction text file to a target construction machine, wherein the hardware architecture corresponding to the target construction machine and the hardware architecture corresponding to the operating system and the temporary operation container are consistent with the operating system, and the target construction machine is used for calling the image construction file corresponding to the image construction text file from a preset version library and constructing an image according to the image construction file.
Optionally, constructing a temporary operation container according to the basic mirror information and the target command, including: determining a consistency result of whether the hardware architecture corresponding to the local hardware architecture and the local operating system and the basic mirror image information is consistent with the operating system or not; and under the condition that the consistency result is that the hardware architecture corresponding to the local hardware architecture, the local operating system and the basic mirror image information is inconsistent with the operating system, constructing a temporary operation container according to the basic mirror image information and the target command.
Optionally, after determining whether the hardware architecture corresponding to the local hardware architecture and the local operating system and the base image information are consistent with the operating system, the method further includes: under the condition that the consistency result is that the local hardware architecture is consistent with the hardware architecture corresponding to the local operating system and the basic image information and the operating system, the image construction file corresponding to the image construction text file is called from a preset version library; and constructing the mirror image according to the mirror image construction file.
Optionally, before retrieving the image construction file corresponding to the image construction text file from the predetermined version library, the method further includes: determining an image construction neglected file according to the image construction text file and a preset version library, wherein the image construction neglected file represents a file which does not need to be called from the preset version library in the image construction process; and determining the image construction file according to the image construction text file and the image construction neglected file.
Optionally, determining the image construction ignore file according to the image construction text file and the predetermined version library includes: determining dependent items included in the mirror image construction text file; and determining the mirror image construction neglected file according to the dependent item and the preset version library.
Optionally, building the mirror image from the mirror image building file includes: and under the condition that a plurality of mirror image construction files are provided, constructing a plurality of mirror images in parallel according to the plurality of mirror image construction files.
Optionally, after sending the image build text file to the target build machine, further comprising: and receiving a construction result sent by the target construction machine, wherein the construction result represents a construction result of the mirror image constructed by the target construction machine.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, etc., such as Read Only Memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises an element.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The foregoing is merely exemplary of the present application and is not intended to limit the present application. Various modifications and changes may be made to the present application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. which are within the spirit and principles of the present application are intended to be included within the scope of the claims of the present application.

Claims (10)

1. A mirror image construction method, comprising:
calling the mirror images stored in the preset version library to construct a text file;
reading basic mirror image information in the mirror image construction text file;
constructing a temporary operation container according to the basic mirror image information and a target command, wherein the target command is used for determining a hardware architecture and an operating system corresponding to the temporary operation container;
operating the temporary operation container, and acquiring a hardware architecture and an operating system corresponding to the temporary operation container, which are output by the temporary operation container after the temporary operation container executes the target command;
and sending the image construction text file to a target construction machine, wherein a hardware architecture corresponding to the target construction machine and a hardware architecture corresponding to an operating system and the temporary operation container are consistent with the operating system, and the target construction machine is used for calling the image construction file corresponding to the image construction text file from the preset version library and constructing an image according to the image construction file.
2. The method of claim 1, wherein constructing a temporary run container from the base image information and the target command comprises:
Determining a consistency result of whether the hardware architecture corresponding to the local hardware architecture and the local operating system and the basic mirror image information is consistent with the operating system or not;
and under the condition that the consistency result is that the local hardware architecture is inconsistent with the hardware architecture corresponding to the local operating system and the basic image information and the operating system, constructing the temporary operation container according to the basic image information and the target command.
3. The method according to claim 2, further comprising, after determining whether the hardware architecture corresponding to the local operating system and the base image information is consistent with the operating system, the step of:
when the consistency result is that the local hardware architecture is consistent with the hardware architecture corresponding to the local operating system and the basic image information and the operating system, an image construction file corresponding to the image construction text file is called from the preset version library;
and constructing the mirror image according to the mirror image construction file.
4. The method of claim 3, wherein before retrieving the image build file corresponding to the image build text file from the predetermined version library, further comprising:
Determining an image construction neglected file according to the image construction text file and the preset version library, wherein the image construction neglected file represents a file which does not need to be called from the preset version library in the image construction process;
and determining the image construction file according to the image construction text file and the image construction neglected file.
5. The method of claim 4, wherein said determining a mirror build ignore file from said mirror build text file and said predetermined version library comprises:
determining dependent items included in the mirror image construction text file;
and determining the image construction neglected file according to the dependency term and the preset version library.
6. A method according to claim 3, wherein said building a mirror image from said mirror image build file comprises:
and under the condition that a plurality of mirror image construction files are provided, constructing a plurality of mirror images in parallel according to the plurality of mirror image construction files.
7. The method of any one of claims 1 to 6, wherein after the sending the mirror build text file to a target build machine, further comprising:
And receiving a construction result sent by the target construction machine, wherein the construction result represents a construction result of the construction mirror image of the target construction machine.
8. A mirror image construction apparatus, comprising:
the calling module is used for calling the mirror images stored in the preset version library to construct a text file;
the reading module is used for reading the basic mirror image information in the mirror image construction text file;
the construction module is used for constructing a temporary operation container according to the basic mirror image information and a target command, wherein the target command is used for determining a hardware architecture and an operating system corresponding to the temporary operation container;
the acquisition module is used for operating the temporary operation container and acquiring a hardware architecture and an operating system corresponding to the temporary operation container which are output after the temporary operation container executes the target command;
the sending module is used for sending the image construction text file to a target construction machine, wherein a hardware architecture corresponding to the target construction machine and a hardware architecture corresponding to the operating system and the temporary operation container are consistent with the operating system, and the target construction machine is used for calling the image construction file corresponding to the image construction text file from the preset version library and constructing an image according to the image construction file.
9. A processor for running a program, wherein the program when run performs the image construction method of any one of claims 1 to 7.
10. An electronic device comprising one or more processors and a memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the image construction method of any of claims 1-7.
CN202310345300.2A 2023-03-31 2023-03-31 Mirror image construction method and device, processor and electronic equipment Pending CN116302361A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310345300.2A CN116302361A (en) 2023-03-31 2023-03-31 Mirror image construction method and device, processor and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310345300.2A CN116302361A (en) 2023-03-31 2023-03-31 Mirror image construction method and device, processor and electronic equipment

Publications (1)

Publication Number Publication Date
CN116302361A true CN116302361A (en) 2023-06-23

Family

ID=86837865

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310345300.2A Pending CN116302361A (en) 2023-03-31 2023-03-31 Mirror image construction method and device, processor and electronic equipment

Country Status (1)

Country Link
CN (1) CN116302361A (en)

Similar Documents

Publication Publication Date Title
US11150916B2 (en) Execution of workflows in distributed systems
US10824404B2 (en) Methods and systems for uploading a program based on a target network platform
CN110955431B (en) Processing method and device of compiling environment
US8978020B2 (en) Generating reusable test components out of remote application programming interface
US20170269921A1 (en) Continuous and automatic application development and deployment
US20170083430A1 (en) Code coverage plugin
US10409567B2 (en) Trimming unused dependencies using package graph and module graph
US9542173B2 (en) Dependency handling for software extensions
Garbervetsky et al. Toward full elasticity in distributed static analysis: The case of callgraph analysis
CN113885849B (en) Application development method and device based on industrial internet platform and terminal equipment
WO2020019993A1 (en) Virtual machine container for applications
US20220237025A1 (en) Active build migration in continuous integration environments
CN112099880B (en) Method and system for reducing application program driven by scene
US11989539B2 (en) Continuous integration and deployment system time-based management
EP4036716B1 (en) Method and device for acquiring mirror image file
CN114791884A (en) Test environment construction method and device, storage medium and electronic equipment
US11720348B2 (en) Computing node allocation based on build process specifications in continuous integration environments
CN116302361A (en) Mirror image construction method and device, processor and electronic equipment
CN111273940B (en) Method and device for uploading program file to code warehouse
US11915007B2 (en) CI/CD pipeline to container conversion
US12093686B2 (en) Code maintenance system
US11960861B1 (en) System and method for code development tools existing within code container
US12072758B2 (en) Dynamic network debug service in a containerized computing cluster
Sello Zamperla Analytics Service: design and deployment of a microservice architecture with Kubernetes
CN117492727A (en) JAVA-based attribute copying method and device, storage medium and electronic equipment

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