WO2019051919A1 - 一种构建镜像的方法和装置 - Google Patents

一种构建镜像的方法和装置 Download PDF

Info

Publication number
WO2019051919A1
WO2019051919A1 PCT/CN2017/106896 CN2017106896W WO2019051919A1 WO 2019051919 A1 WO2019051919 A1 WO 2019051919A1 CN 2017106896 W CN2017106896 W CN 2017106896W WO 2019051919 A1 WO2019051919 A1 WO 2019051919A1
Authority
WO
WIPO (PCT)
Prior art keywords
variable information
target application
target
input
template file
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.)
Ceased
Application number
PCT/CN2017/106896
Other languages
English (en)
French (fr)
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.)
Wangsu Science and Technology Co Ltd
Original Assignee
Wangsu Science and Technology Co Ltd
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 Wangsu Science and Technology Co Ltd filed Critical Wangsu Science and Technology Co Ltd
Priority to US16/316,443 priority Critical patent/US20210373870A1/en
Priority to EP17924930.5A priority patent/EP3522005A4/en
Publication of WO2019051919A1 publication Critical patent/WO2019051919A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • G06F8/63Image based installation; Cloning; Build to order
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/73Program documentation

Definitions

  • Embodiments of the present invention relate to the field of container technologies, and in particular, to a method and an apparatus for constructing a mirror image.
  • container technology is used as a carrier for various application operations, thereby realizing application scenarios such as operation and maintenance automation, development and operation integration (DevOps), and micro service architecture.
  • application scenarios such as operation and maintenance automation, development and operation integration (DevOps), and micro service architecture.
  • container image construction technology is an essential part.
  • the embodiment of the invention provides a method and a device for constructing a mirror image, which are used to automatically construct a mirror image, and reduce the learning cost of the development or operation and maintenance personnel.
  • An embodiment of the present invention provides a method for constructing an image, which includes: acquiring a template file corresponding to an application type to which the target application belongs; the template file includes platform environment configuration information and at least one variable information; and acquiring the at least one variable information a parameter to be input that matches the target application; according to the platform environment configuration information, the at least one variable information, and the at least one variable information pair
  • the image to be input that matches the target application is executed, and the build image command is executed to obtain a mirror for running the target application.
  • the executing the mirroring command is performed according to the platform environment configuration information, the at least one variable information, and the at least one variable information corresponding to the target application, and the executing the mirroring command is used to run the
  • the image of the target application includes: determining, according to the template file corresponding to the application type to which the target application belongs, a target location of each variable information in the template file; and corresponding to each target information Applying the matched parameters to be input to the target location, and generating a mirroring build script according to the filled template file; executing a build image command according to the mirror build script to obtain a mirror for running the target application.
  • the obtaining, by the at least one variable information, the parameter to be input that is matched with the target application includes: displaying the at least one variable information in a webpage or an attribute file of the target application; Detecting that there is data input in the property file of the web page or the target application, acquiring at least one pair of key value pairs composed of each variable information and input data corresponding to each variable information; each pair of key values includes The keyword is a variable information, and the value is a parameter to be input that matches the target application corresponding to the variable information.
  • the template file further includes a preset structure corresponding to the at least one variable information; and the parameter to be input that matches the target application corresponding to each variable information is filled to the target Before the location, the method further includes: parsing the acquired at least one pair of key values into a structure to be matched; and the structure to be matched is consistent with the format of the preset structure.
  • the determining a target location of each variable information in the template file, and filling, to the target location, a parameter to be input that matches the target application corresponding to each variable information, and according to The template file generated by the populated template file includes: matching each variable information in the structure to be matched with each variable information in the preset structure; if the structure to be matched is determined The variable information is consistent with the variable information in the preset structure, and the position corresponding to the variable information in the preset structure is determined as the target position; and the variable information at the target position is deleted. And matching the variable information corresponding to the target structure in the to-be-matched structure The input parameters are filled to the target location to obtain a mirrored build script.
  • the executing the mirroring command is performed according to the platform environment configuration information, the at least one variable information, and the at least one variable information corresponding to the target application, and the executing the mirroring command is used to run the Before the mirroring of the target application, the method further includes: determining, according to the parameter to be input that matches the target application, the name of the image used to run the target application.
  • An embodiment of the present invention provides an apparatus for constructing a mirror, which includes: an obtaining unit, configured to acquire a template file corresponding to an application type to which the target application belongs; and acquire, to be matched with the target application, the at least one variable information Inputting a parameter; the template file includes platform environment configuration information and at least one variable information; a mirroring building unit, configured to correspond to the platform environment configuration information, the at least one variable information, and the at least one variable information The target application matches the parameters to be input, and the Build Mirror command is executed to obtain a mirror for running the target application.
  • the image construction unit is configured to: determine, according to a template file corresponding to the application type to which the target application belongs, a target location of each variable information in the template file; Corresponding input parameters to be matched with the target application are filled to the target location, and a mirroring build script is generated according to the filled template file; and the mirroring command is executed according to the mirroring script to obtain the target application for running Mirror.
  • the obtaining unit is configured to display the at least one variable information in a webpage or a property file of the target application; if the webpage or the target application's property file is detected to exist Data input, obtaining at least one pair of key value pairs composed of each variable information and input data corresponding to each variable information; each pair of key value pairs includes a variable information, and the value corresponds to the variable information
  • the target application matches the parameters to be input.
  • the template file further includes a preset structure corresponding to the at least one variable information
  • the device further includes: a parsing unit, configured to: parse the acquired at least one pair of key value pairs to be matched a structure; the structure to be matched is consistent with the format of the preset structure.
  • the image construction unit is further configured to: match each variable information in the to-be-matched structure with each variable information in the preset structure; if the to-be-matched structure is determined Body The variable information in the preset structure is consistent with the variable information in the preset structure, and the position corresponding to the variable information in the preset structure is determined as the target position; the variable at the target position is The information is deleted, and the to-be-entered parameters corresponding to the target application corresponding to the variable information in the to-be-matched structure are filled to the target location to obtain a mirroring construction script.
  • the mirroring unit is further configured to: determine, according to the parameter to be input that matches the target application, the name of the image used to run the target application.
  • the template file corresponding to the application type to which the target application belongs is obtained; the template file includes configuration information of the platform environment and at least one variable information; and the to-be-entered parameters corresponding to the target application corresponding to the at least one variable information are acquired; The environment configuration information, the at least one variable information, and the at least one variable information corresponding to the target application, the execution of the mirroring command to obtain a mirror for running the target application.
  • the development or operation and maintenance personnel only need to know the at least one variable information corresponding to the target application to match the input parameter, so that the image of the running target application type can be automatically constructed, and the development or operation and maintenance personnel can reduce the need to learn the mirror construction technology. Learning costs.
  • FIG. 1 is a schematic flowchart of a method for constructing an image according to an embodiment of the present disclosure
  • FIG. 2 is a schematic structural diagram of a directory including an attribute file according to an embodiment of the present invention.
  • FIG. 3 is a schematic flowchart of another method for constructing an image according to an embodiment of the present invention.
  • FIG. 4 is a schematic structural diagram of an apparatus for constructing a mirror image according to an embodiment of the present invention.
  • the image construction method of the embodiment of the present invention is applicable to all scenarios for constructing a mirror by using a mirroring build script, and the main types of mirrors involved include, but are not limited to, Docker container class mirroring. Template files used to build different images are different because of the different images of different types of applications.
  • the embodiment of the present invention obtains the parameter to be input corresponding to the variable information by selecting a template file corresponding to the application type to which the pre-defined target application belongs, and performs the construction.
  • a mirroring command that simplifies the process of building a mirror.
  • FIG. 1 is a schematic flowchart diagram of a method for constructing a mirror image according to an embodiment of the present invention. As shown in FIG. 1 , the method for constructing a mirror image provided by an embodiment of the present invention includes the following steps:
  • Step 101 Obtain a template file corresponding to an application type to which the target application belongs; the template file includes platform environment configuration information and at least one variable information;
  • Step 102 Acquire a parameter to be input that matches at least one variable information and that matches the target application.
  • Step 103 Perform a build image command to obtain a mirror for running the target application according to the configuration information of the platform environment, the at least one variable information, and the parameter to be input that matches the target application corresponding to the at least one variable information.
  • the template file corresponding to the application type to which the target application belongs is obtained; the template file includes configuration information of the platform environment and at least one variable information; and the to-be-entered parameters corresponding to the target application corresponding to the at least one variable information are acquired; The environment configuration information, the at least one variable information, and the at least one variable information corresponding to the target application, the execution of the mirroring command to obtain a mirror for running the target application.
  • the development or operation and maintenance personnel only need to know the parameter to be input that matches the target application corresponding to the at least one variable information, so that the image of the running target application type can be automatically constructed, and the development or operation and maintenance personnel need not learn the mirror construction technology. Can reduce learning costs.
  • an alternative implementation is to develop a generic template file that can be used to build images for running various types of applications.
  • the various types of applications can be, but are not limited to, the following types: Java application type, PHP application type, Go/C/C++ application type.
  • Another alternative implementation is Multiple template files with application type generics, that is, template files for each type of application for building images that run this type of application; for example, for Java application types, prepare a template for Java applications Template file.
  • each template file includes platform environment configuration information for running a target application type and at least one variable information.
  • the target application is Java application 1, belonging to the Java application type
  • the application belonging to the same application type as Java application 1 is also Java application 2 and Java application 3, which are built for running Java application 1, Java application 2, and Java.
  • the platform environment configuration information is a platform-related configuration item, such as a platform compatibility requirement and a platform specific requirement.
  • each platform environment configuration information of the application that is consistent with the application type to which the target application belongs is the same. That is to say, the application environment information of the Java application 1, the Java application 2, and the Java application 3 is the same, and does not need to be separately set, so it can be preset in the template file, and the platform environment configuration is not required when constructing the image of the target application. Information is exposed to development or operations personnel, which simplifies the process of building mirrors and reduces the workload of development or operations personnel.
  • the Go language is taken as an example.
  • An example of a template file including variable information is provided below.
  • the content in the braces ⁇ . ⁇ is at least one variable information, such as a base image (BaseImage), a user name (UserName), and a Linux basic command (LinuxBaseCmd).
  • BaseImage a base image
  • UserName a user name
  • Linux basic command a Linux basic command
  • each of the parameters to be input of the application that is consistent with the application type to which the target application belongs is different. For example, when constructing an image for running Java application 1, it is necessary to obtain a parameter to be input that is matched by Java application 1; when constructing an image for running Java application 2, it is necessary to obtain a parameter to be input that is matched by Java application 2. .
  • the image for running the target application at least one variable information in the template file needs to be exposed to the development or operation personnel, and the development or operation personnel input the parameter to be input corresponding to the target application corresponding to each variable information.
  • the present invention provides an implementation manner of acquiring at least one variable information corresponding to the target application, and displaying at least one variable information in a web page or a target application's attribute file; monitoring the web page or target If there is data input in the attribute file of the application, at least one pair of key value pairs composed of each variable information and input data corresponding to each variable information is obtained; each pair of key value pairs includes a variable information, and the value is The parameter to be input that matches the target application corresponding to the variable information.
  • the attribute file includes but is not limited to a JSON file, an XML file, a YAML file, and the like. If the at least one variable information is displayed in the attribute file, and the JSON file is taken as an example, the JSON file can be found in the directory structure of the file display.
  • FIG. 2 exemplarily shows the directory including the attribute file provided by the embodiment of the present invention. Schematic. As shown in FIG. 2, the subdirectory info is found in the subdirectory of the parent directory wplus-console in the directory structure, and then the JSON file appInfo.json of the directory info is found, and the JSON file includes at least one variable information.
  • variable information in a web page or properties file is provided below.
  • each row includes a variable information, such as the first row includes variable information: a base image (BaseImage), and the second row includes variable information: a namespace (Namespace).
  • BaseImage variable information: a base image
  • Namespace namespace
  • the development or operation and maintenance personnel fill in the parameter to be input corresponding to the target application corresponding to the at least one variable information in the web page or the attribute file, and then obtain the variable information as a key, and the target corresponding to the variable information Apply the matched key-value pair whose value is to be entered.
  • each row includes a pair of key value pairs, for example, in the first row,
  • the keyword is the variable information: BaseImage
  • the value is: the parameter to be input that matches the target application is registry.wae.haplat.net/base/java:7
  • the keyword is variable information: Namespace
  • Its value is: the parameter to be input that matches the target application is wplus.
  • at least one variable information is exposed to the development or operation and maintenance personnel, and the development or operation and maintenance personnel only needs to input at least one variable information corresponding to the target application to be matched. In this way, the development or operation and maintenance personnel do not need to write configuration information related to the platform, and do not need to pay attention to different platform compatibility configuration problems, thereby implementing a simple and efficient automated image construction process.
  • a mirror image construction script needs to be created first.
  • the process of creating a mirroring build script does not need to be understood by the development and operation personnel, and can be automatically constructed according to the configuration information of the platform environment, at least one variable information, and at least one parameter corresponding to the target application corresponding to the target application. Run the image of the target application.
  • the following describes how to automatically create a mirroring build script and build a mirroring process in the embodiment of the present invention.
  • Running the image of the target application includes: determining a target location of each variable information in the template file according to the template file corresponding to the application type to which the target application belongs; filling the parameter to be input corresponding to the target application corresponding to each variable information Go to the target location and generate a mirror build script based on the populated template file; execute the build image command from the mirror build script to get the image to run the target application.
  • the template file in Example 1 includes at least one command including variable information, such as FROM ⁇ .BaseImage ⁇ , and the command is: based on a base image to build a target application for running. Mirroring.
  • First determine the position of the variable information BaseImage in the template file as the target position; after that, obtain the parameter to be input corresponding to the variable information BaseImage in the example 3 registry.wae.haplat.net/base/java:7, and the The input parameters are populated to the target location corresponding to the variable information BaseImage in the template file in Example 1, and the mirror build script is obtained.
  • variable information such as FROM ⁇ .BaseImage ⁇
  • the command is: based on a base image to build a target application for running.
  • Mirroring First, determine the position of the variable information BaseImage in the template file as the target position; after that, obtain the parameter to be input corresponding to the variable information BaseImage in the example 3 registry.wae.haplat.net/base/java:7, and the The input parameters are populated to the target location
  • the template file further includes a preset structure corresponding to the at least one variable information.
  • the method further includes: And parsing the obtained at least one pair of key values into a structure to be matched; wherein the structure to be matched is consistent with the format of the preset structure. For example, when the user inputs at least one parameter corresponding to the variable information in the AppInfo.json file, at least one key value pair obtained from the AppInfo.json file can be parsed into a structure to be matched by the json.Unmarshal function. body.
  • the structure to be matched is parsed by a template processing method to generate a build image script, wherein the template processing mode can be implemented by a template processing function of a text/template package or an http/template package.
  • An embodiment of the present invention provides an implementation manner of determining a target location of each variable information in the template file, and filling a parameter to be input that matches the target application corresponding to each variable information to a target location to obtain a mirror construction script: Matching each variable information in the structure to be matched with each variable information in the preset structure; if it is determined that the variable information in the structure to be matched is in the preset structure If the variable information is consistent, the position corresponding to the variable information in the preset structure is determined as the target position; the variable information of the target position is deleted, and the variable information in the structure to be matched is determined. Corresponding input parameters to be matched with the target application are filled to the target location to obtain a mirror construction script.
  • the image construction script is not limited to the Dockerfile file, and may be any image construction file.
  • An example of the image construction script obtained according to the key value pair and the template file in Example 3 is provided below.
  • the mirror build command is executed, and a one-click automatic build mirror can be implemented.
  • the method before the executing the mirroring command to obtain the image for running the target application, the method further includes: determining, according to the parameter to be input that matches the target application, a name of the image used to run the target application.
  • An optional implementation manner is: determining the image name according to any one of the parameters to be input that matches the target application. For example, the image name naming is determined by the parameter to be input corresponding to the following variable information:
  • the variable information docker-registry-url is the mirroring center address, generally refers to the domain name.
  • the corresponding parameter to be input is registry.wae.haplat.net
  • the variable information namespace is a namespace, for example, its corresponding waiting
  • the input parameter is wplus
  • the variable information app-name is the application name, for example, the corresponding parameter to be input is wplus-console
  • the variable information version is the application version number, for example, the corresponding parameter to be input is 1.4.1-1
  • the name of the image in this example is: registry.wae.haplat.net/wplus/wplus-console:1.4.1-1./.
  • the image After the image is generated, the image can be pushed to the mirrored warehouse for subsequent verification and application deployment.
  • the commands you need to use are as follows:
  • Push image docker push registry.wae.haplat.net/wplus/wplus-console: 1.4.1-1.
  • an embodiment of the present invention provides an example.
  • FIG. 3 is a schematic flowchart showing a method for upgrading a version file according to an embodiment of the present invention. As shown in FIG. 3, a method for upgrading a version file according to an embodiment of the present invention includes the following steps:
  • Step 301 Obtain a template file corresponding to an application type to which the target application belongs; the template file includes platform environment configuration information and at least one variable information;
  • Step 302 Display at least one variable information in a webpage or a property file of the target application
  • Step 303 If there is data input in the attribute file of the web page or the target application, at least one pair of key value pairs composed of each variable information and input data corresponding to each variable information is acquired; each pair of key values includes The keyword is a variable information, and the value is a parameter to be input that matches the target application corresponding to the variable information;
  • Step 304 Parsing the acquired at least one pair of key values into a structure to be matched; the template file includes a preset structure corresponding to the at least one variable information, and the format of the structure to be matched is consistent with the format of the preset structure ;
  • Step 305 Match, for each variable information in the structure to be matched, the variable information in the structure to be matched with each variable information in the preset structure;
  • Step 306 Determine, from the preset structure, variable information that is consistent with the variable information in the structure to be matched;
  • Step 307 Determine, as the target location, a location corresponding to the variable information that is determined in the preset structure and that is consistent with the variable information in the structure to be matched.
  • Step 308 Deleting the variable information at the target location, and filling the to-be-entered parameters corresponding to the target application corresponding to the variable information in the structure to be matched to the target location, to obtain a mirroring construction script;
  • Step 309 Perform a build image command according to the image build script to obtain a mirror for running the target application.
  • the template file corresponding to the application type to which the target application belongs is obtained; the template file includes configuration information of the platform environment and at least one variable information; and at least one variable information corresponding to the target application is obtained. Matching parameters to be input; performing a build image command to obtain a mirror for running the target application according to the platform environment configuration information, the at least one variable information, and the at least one variable information corresponding to the target application corresponding to the target application.
  • the development or operation and maintenance personnel only need to know at least one variable information corresponding to the target application to match the parameters to be input, In order to automatically build a mirror of the running target application type, development or operation and maintenance personnel can reduce the learning cost without learning the mirror construction technology.
  • FIG. 4 is a schematic structural diagram of an apparatus for constructing a mirror image according to an embodiment of the present invention.
  • the apparatus 400 for constructing a mirror image may be used in the foregoing method.
  • the means for constructing the image may implement the steps performed by the means for constructing the image in any one or more of the corresponding methods shown in Figure 1 above.
  • the apparatus 400 for constructing a mirror may include an obtaining unit 401, a mirroring building unit 403, and optionally, a parsing unit 402.
  • the obtaining unit 401 is configured to obtain a template file corresponding to the application type to which the target application belongs, and obtain a parameter to be input that matches the target application corresponding to the at least one variable information, where the template file includes platform environment configuration information and at least one Variable information
  • a mirroring construction unit 403 configured to execute a build image command according to the platform environment configuration information, the at least one variable information, and the at least one variable information corresponding to the target application A mirror image of the target application.
  • the development or operation and maintenance personnel only need to know the parameter to be input corresponding to the target application corresponding to the at least one variable information, and input the parameter to be input matched with the target application into the template file, so that the automatic construction operation can be realized.
  • Mirroring of target application types, development or operation and maintenance personnel do not need to learn mirroring construction technology, which can reduce learning costs.
  • the image construction unit 403 is configured to: determine, according to a template file corresponding to the application type to which the target application belongs, a target location of each variable information in the template file; The to-be-entered parameters corresponding to the target application are filled to the target location, and a mirroring build script is generated according to the filled template file; and the mirroring command is executed according to the mirroring script to obtain the target The image of the application.
  • the obtaining unit 401 is configured to: display the at least one variable information in a webpage or an attribute file of the target application; if the webpage or the target application's property file is detected If there is data input, each variable information and the input corresponding to each variable information are obtained. At least one pair of key values composed of data; each pair of key value pairs includes a variable information, and the value is a parameter to be input that matches the target application corresponding to the variable information.
  • the template file further includes a preset structure corresponding to the at least one variable information
  • the device further includes a parsing unit 402, configured to: parse the acquired at least one pair of key values into a Matching the structure; the to-be-matched structure is in the same format as the preset structure; the mirroring construction unit 403 is configured to: display each variable information in the to-be-matched structure with the preset structure Each variable information in the body is matched; if it is determined that the variable information in the structure to be matched is consistent with the variable information in the preset structure, the variable information in the preset structure is corresponding Positioning is determined as the target location; deleting the variable information at the target location, and filling the to-be-entered parameters corresponding to the target application corresponding to the variable information in the to-be-matched structure to the target location , get the mirror build script.
  • the image construction unit 403 is further configured to: determine, according to the parameter to be input that matches the target application, the name of the image used to run the target application.
  • the division of the module in the embodiment of the present invention is schematic, and is only a logical function division, and the actual implementation may have another division manner.
  • the functional modules in the embodiments of the present invention may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.
  • the above integrated modules can be implemented in the form of hardware or in the form of software functional modules.
  • a computer program product includes one or more computer instructions.
  • the computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable device.
  • Computer The instructions may be stored in a computer readable storage medium or transferred from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions may be wired from a website site, computer, server or data center (eg, the same Axis cables, fiber optics, digital subscriber line (DSL), or wireless (eg, infrared, wireless, microwave, etc.) are transmitted to another website site, computer, server, or data center.
  • the computer readable storage medium can be any available media that can be accessed by a computer or a data storage device such as a server, data center, or the like that includes one or more available media.
  • Useful media can be magnetic media (eg, floppy disk, hard disk, magnetic tape), optical media (eg, DVD), or semiconductor media (eg, Solid State Disk (SSD)).
  • embodiments of the invention may be provided as a method, system, or computer program product.
  • embodiments of the invention may be in the form of an entirely hardware embodiment, an entirely software embodiment, or a combination of software and hardware.
  • embodiments of the invention 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, etc.) including computer usable program code.
  • Embodiments of the invention are described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or FIG.
  • These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine for the execution of instructions for execution by a processor of a computer or other programmable data processing device.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Library & Information Science (AREA)
  • Stored Programmes (AREA)
  • Processing Or Creating Images (AREA)

Abstract

一种构建镜像的方法和用于构建镜像的装置(400),用于实现自动构建镜像,减少开发或运维人员的学习成本。获取目标应用所属的应用类型对应的模板文件;模板文件包括平台环境的配置信息和至少一个变量信息(101);获取至少一个变量信息对应的与目标应用匹配的待输入参数(102);根据平台环境配置信息、至少一个变量信息和至少一个变量信息对应的与目标应用匹配的待输入参数,执行构建镜像命令得到用于运行目标应用的镜像(103)。如此,开发或运维人员只需要知道至少一个变量信息对应的与目标应用匹配的待输入参数,就可以实现自动构建运行目标应用类型的镜像,开发或运维人员无需学习镜像构建技术,可以减少学习成本。

Description

一种构建镜像的方法和装置 技术领域
本发明实施例涉及容器技术领域,尤其涉及一种构建镜像的方法和装置。
背景技术
在当前云计算架构中,特别是PaaS平台架构,通过容器技术作为各类应用运行的载体,从而实现运维自动化、开发运维一体化(DevOps)、微服务架构等应用场景。在这些应用场景中,容器镜像构建技术是必不可少的一个环节。
现有技术中的容器镜像构建过程,需要开发或运维人员根据实际需要设计运行某一类应用程序的镜像,所以开发或运维人员必须在构建之前先学习容器镜像构建技术。由于用于运行不同的应用程序的镜像不同,不同镜像的构建过程也不同,而且在应用组件迁移到PaaS平台的过程中还涉及到与平台兼容性配置的问题,开发或运维人员不一定可以构建一个比较精简、有效且可以正常运行的镜像。
因此,亟需一种构建镜像的方法,实现自动构建镜像,减少开发或运维人员的学习成本。
发明内容
本发明实施例提供一种构建镜像的方法和装置,用以实现自动构建镜像,减少开发或运维人员的学习成本。
本发明实施例提供一种构建镜像的方法,包括:获取目标应用所属的应用类型对应的模板文件;所述模板文件包括平台环境配置信息和至少一个变量信息;获取所述至少一个变量信息对应的与所述目标应用匹配的待输入参数;根据所述平台环境配置信息、所述至少一个变量信息和所述至少一个变量信息对 应的与所述目标应用匹配的待输入参数,执行构建镜像命令得到用于运行所述目标应用的镜像。
可选的,所述根据所述平台环境配置信息、所述至少一个变量信息和所述至少一个变量信息对应的与所述目标应用匹配的待输入参数,执行构建镜像命令得到用于运行所述目标应用的镜像,包括:根据所述目标应用所属的应用类型对应的模板文件,确定出每个变量信息在所述模板文件中的目标位置;将所述每个变量信息对应的与所述目标应用匹配的待输入参数填充至所述目标位置,并根据填充后的模板文件生成镜像构建脚本;根据所述镜像构建脚本执行构建镜像命令,得到用于运行所述目标应用的镜像。
可选的,所述获取所述至少一个变量信息对应的与所述目标应用匹配的待输入参数,包括:将所述至少一个变量信息显示在Web页面或所述目标应用的属性文件中;若监测到所述Web页面或所述目标应用的属性文件中存在数据输入,则获取每个变量信息和每个变量信息对应的输入的数据组成的至少一对键值对;每对键值对包括的关键字为变量信息,值为该变量信息对应的与所述目标应用匹配的待输入参数。
可选的,所述模板文件中还包括所述至少一个变量信息对应的预设结构体;所述将所述每个变量信息对应的与所述目标应用匹配的待输入参数填充至所述目标位置之前,还包括:将获取的所述至少一对键值对解析成待匹配结构体;所述待匹配结构体与所述预设结构体的格式一致。
可选的,所述确定出每个变量信息在所述模板文件中的目标位置,将所述每个变量信息对应的与所述目标应用匹配的待输入参数填充至所述目标位置,并根据填充后的模板文件生成镜像构建脚本,包括:将所述待匹配结构体中的每个变量信息与所述预设结构体中的每个变量信息进行匹配;若确定所述待匹配结构体中的变量信息与所述预设结构体中的变量信息一致,则:将所述预设结构体中的变量信息对应的位置确定为所述目标位置;将所述目标位置处的变量信息删除,并将所述待匹配结构体中变量信息对应的与所述目标应用匹配的 待输入参数填充至所述目标位置,得到镜像构建脚本。
可选的,所述根据所述平台环境配置信息、所述至少一个变量信息和所述至少一个变量信息对应的与所述目标应用匹配的待输入参数,执行构建镜像命令得到用于运行所述目标应用的镜像之前,还包括:根据与所述目标应用匹配的待输入参数确定所述用于运行所述目标应用的镜像的名称。
本发明实施例提供一种用于构建镜像的装置,包括:获取单元,用于获取目标应用所属的应用类型对应的模板文件;获取所述至少一个变量信息对应的与所述目标应用匹配的待输入参数;所述模板文件包括平台环境配置信息和至少一个变量信息;镜像构建单元,用于根据所述平台环境配置信息、所述至少一个变量信息和所述至少一个变量信息对应的与所述目标应用匹配的待输入参数,执行构建镜像命令得到用于运行所述目标应用的镜像。
可选的,所述镜像构建单元,用于:根据所述目标应用所属的应用类型对应的模板文件,确定出每个变量信息在所述模板文件中的目标位置;将所述每个变量信息对应的与所述目标应用匹配的待输入参数填充至所述目标位置,并根据填充后的模板文件生成镜像构建脚本;根据所述镜像构建脚本执行构建镜像命令,得到用于运行所述目标应用的镜像。
可选的,所述获取单元,用于:将所述至少一个变量信息显示在Web页面或所述目标应用的属性文件中;若监测到所述Web页面或所述目标应用的属性文件中存在数据输入,则获取每个变量信息和每个变量信息对应的输入的数据组成的至少一对键值对;每对键值对包括的关键字为变量信息,值为该变量信息对应的与所述目标应用匹配的待输入参数。
可选的,所述模板文件中还包括所述至少一个变量信息对应的预设结构体;所述装置还包括解析单元,用于:将获取的所述至少一对键值对解析成待匹配结构体;所述待匹配结构体与所述预设结构体的格式一致。
可选的,所述镜像构建单元,还用于:将所述待匹配结构体中的每个变量信息与所述预设结构体中的每个变量信息进行匹配;若确定所述待匹配结构体 中的变量信息与所述预设结构体中的变量信息一致,则:将所述预设结构体中的变量信息对应的位置确定为所述目标位置;将所述所述目标位置处的变量信息删除,并将所述待匹配结构体中变量信息对应的与所述目标应用匹配的待输入参数填充至所述目标位置,得到镜像构建脚本。
可选的,所述镜像构建单元,还用于:根据与所述目标应用匹配的待输入参数确定所述用于运行所述目标应用的镜像的名称。
本发明实施例中,获取目标应用所属的应用类型对应的模板文件;模板文件包括平台环境的配置信息和至少一个变量信息;获取至少一个变量信息对应的与目标应用匹配的待输入参数;根据平台环境配置信息、至少一个变量信息和至少一个变量信息对应的与目标应用匹配的待输入参数,执行构建镜像命令得到用于运行目标应用的镜像。如此,开发或运维人员只需要知道至少一个变量信息对应的与目标应用匹配的待输入参数,就可以实现自动构建运行目标应用类型的镜像,开发或运维人员无需学习镜像构建技术,可以减少学习成本。
附图说明
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简要介绍。
图1为本发明实施例提供的一种构建镜像的方法流程示意图;
图2为本发明实施例提供的包括属性文件的目录结构示意图;
图3为本发明实施例提供的另一种构建镜像的方法流程示意图;
图4为本发明实施例提供的一种用于构建镜像的装置的结构示意图。
具体实施方式
为了使本发明的目的、技术方案及有益效果更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。
本发明实施例的镜像构建方法适用于所有通过镜像构建脚本构建镜像的场景,主要涉及的镜像类型包括但不限于Docker容器类镜像。由于不同类型的应用程序的镜像不同,用于构建不同的镜像的模板文件也不同。为了避免每次构建镜像都需要编写用于构建镜像的所有信息,本发明实施例通过选择一个预先制定的目标应用所属的应用类型对应的模板文件,获取变量信息对应的待输入参数,并执行构建镜像命令,实现简化构建镜像过程。
图1示例性示出了本发明实施例提供的一种构建镜像的方法流程示意图。如图1所示,本发明实施例提供的构建镜像方法包括以下步骤:
步骤101:获取目标应用所属的应用类型对应的模板文件;模板文件包括平台环境配置信息和至少一个变量信息;
步骤102:获取至少一个变量信息对应的与所述目标应用匹配的待输入参数;
步骤103:根据平台环境的配置信息、至少一个变量信息和至少一个变量信息对应的与所述目标应用匹配的待输入参数,执行构建镜像命令得到用于运行目标应用的镜像。
本发明实施例中,获取目标应用所属的应用类型对应的模板文件;模板文件包括平台环境的配置信息和至少一个变量信息;获取至少一个变量信息对应的与目标应用匹配的待输入参数;根据平台环境配置信息、至少一个变量信息和至少一个变量信息对应的与目标应用匹配的待输入参数,执行构建镜像命令得到用于运行目标应用的镜像。如此,开发或运维人员只需要知道至少一个变量信息对应的与所述目标应用匹配的待输入参数,就可以实现自动构建运行目标应用类型的镜像,开发或运维人员无需学习镜像构建技术,可以减少学习成本。
本发明实施例中,获取目标应用所属的应用类型对应的模板文件的实现方式有多种。一种可选的实现方式为,制定一个通用型的模板文件,可以用来构建用于运行各种类型应用的镜像,各种类型应用可以但不限于以下类型:Java应用类型、PHP应用类型、Go/C/C++应用类型。另一种可选的实现方式为,制 定多份具有应用类型通用型的模板文件,也就是说,为每种类型应用制备模板文件,用于构建运行该类型应用的镜像;比如,针对Java应用类型,制备一个适用于Java应用类型的模板文件。
本发明实施例中,每个模板文件中包括用于运行目标应用类型的平台环境配置信息和至少一个变量信息。举个例子,目标应用为Java应用1,属于Java应用类型,与Java应用1属于同一应用类型的应用还有Java应用2和Java应用3,在构建用于运行Java应用1、Java应用2和Java应用3的镜像时,可以使用同一个Java应用类型的模板文件。
上述实施例中,平台环境配置信息为平台相关的配置项,比如平台的兼容性要求、平台的特殊性要求等配置内容。可选的,每个与目标应用所属的应用类型一致的应用的平台环境配置信息相同。也就是说,Java应用1、Java应用2和Java应用3的平台环境配置信息相同,不需要进行分别设置,所以可以在模板文件中预先设置,在构建目标应用的镜像时不需要将平台环境配置信息暴露给开发或运维人员,从而可以简化构建镜像过程,减少开发或运维人员工作量。
本发明实施例中,模板文件中的使用的语言有多种,本发明实施例以Go语言为例,以下提供一个包括变量信息的模板文件的示例。
示例1:
FROM{{.BaseImage}}
MAINTAINER{{.UserName}}
RUN{{.LinuxBaseCmd}}
COPY package/*/{{.AppName}}/
COPY script/run.sh{{.CmdDir}}
RUN rpm-ivh/{{.AppName}}/*.rpm&&rm-r/{{.AppName}}/*.rpm
COPY config/*{{.ConfigDir}}
RUN rm-fr{{.LogDir}}
RUN ln-sf/wae/log{{.LogDir}}
WORKDIR{{.Workdir}}
CMD["{{.CmdDir}}run.sh"]
上述示例1中,大括号{{.}}中的内容为至少一个变量信息,比如基础镜像(BaseImage),用户名称(UserName)和Linux基本命令(LinuxBaseCmd)等。
基于步骤102,每个与目标应用所属的应用类型一致的应用的待输入参数不同。举个例子,比如在构建用于运行Java应用1的镜像时,需要获取Java应用1匹配的待输入参数;在构建用于运行Java应用2的镜像时,需要获取Java应用2匹配的待输入参数。在构建用于运行目标应用的镜像时,需要将模板文件中的至少一个变量信息暴露给开发或运维人员,开发或运维人员输入每个变量信息对应的与目标应用匹配的待输入参数。
本发明提供一种获取至少一个变量信息对应的与所述目标应用匹配的待输入参数的实现方式,将至少一个变量信息显示在Web页面或目标应用的属性文件中;在监测到Web页面或目标应用的属性文件中存在数据输入,则获取每个变量信息和每个变量信息对应的输入的数据组成的至少一对键值对;每对键值对包括的关键字为变量信息,值为该变量信息对应的与目标应用匹配的待输入参数。
可选的,属性文件包括但不限于JSON文件、XML文件、YAML文件等文件。若是将至少一个变量信息显示在属性文件中,以JSON文件为例,那么可以在文件展示的目录结构中查找到JSON文件,图2示例性示出了本发明实施例提供的包括属性文件的目录结构示意图。如图2所示,在目录结构中的父目录wplus-console的子目录中找到子目录info,再找到目录info的JSON文件appInfo.json,JSON文件中包括至少一个变量信息。
以下提供一个将变量信息展示在Web页面或属性文件中的示例。
示例2:
{
"BaseImage":,
"Namespace":,
"AppName":,
"Version":,
"UserName":,
"LogDir":,
"CmdDir":,
"ConfigDir":,
"Workdir":,
"LinuxBaseCmd":
}
上述示例2中,每一行包括一个变量信息,比如第一行包括变量信息:基础镜像(BaseImage),第二行包括变量信息:命名空间(Namespace)等。
基于示例2,开发或运维人员在Web页面或属性文件中填写至少一个变量信息对应的与目标应用匹配的待输入参数,之后,获取以变量信息为关键字,以该变量信息对应的与目标应用匹配的待输入参数为值的键值对。
基于示例2中展示的变量信息,以下提供至少一对键值对的示例。
示例3:
{
"BaseImage":"registry.wae.haplat.net/base/java:7",
"Namespace":"wplus",
"AppName":"wplus-console",
"Version":"1.4.1-1",
"UserName":"huwh",
"LogDir":"/usr/local/wsop/console/logs",
"CmdDir":"/usr/local/bin/",
"ConfigDir":"/usr/local/wsop/console/conf/",
"Workdir":"/usr/local/wsop/console/",
"LinuxBaseCmd":"yum install–y file"
}
上述示例2中,每一行的中包括一对键值对,举个例子,比如第一行中, 关键字为变量信息:BaseImage,其值为:与目标应用匹配的待输入参数为registry.wae.haplat.net/base/java:7;再比如第二行中,关键字为变量信息:Namespace,其值为:与目标应用匹配的待输入参数为wplus。本发明实施例中向开发或运维人员暴露至少一个变量信息,开发或运维人员只需要输入至少一个变量信息对应的与目标应用匹配的待输入参数。如此,开发或运维人员不需要编写与平台相关的配置信息,无需关注不同的平台兼容配置问题,从而实现简单高效的自动化构建镜像过程。
本发明实施例中,构建镜像需要先创建一个镜像构建脚本。创建镜像构建脚本的过程并不需要开发和运维人员了解,可以根据平台环境的配置信息、至少一个变量信息和至少一个变量信息对应的与所述目标应用匹配的待输入参数,自动构建用于运行目标应用的镜像。
下面对本发明实施例如何自动创建镜像构建脚本并构建镜像过程进行详细介绍。
基于步骤102,在获取到与目标应用匹配的待输入参数之后,根据平台环境配置信息、至少一个变量信息和至少一个变量信息对应的与目标应用匹配的待输入参数,执行构建镜像命令得到用于运行目标应用的镜像,包括:根据目标应用所属的应用类型对应的模板文件,确定出每个变量信息在模板文件中的目标位置;将每个变量信息对应的与目标应用匹配的待输入参数填充至目标位置,并根据填充后的模板文件生成镜像构建脚本;根据镜像构建脚本执行构建镜像命令,得到用于运行目标应用的镜像。
结合示例1、示例3举个例子,在示例1中的模板文件中包括至少一条包括变量信息的命令,比如FROM{{.BaseImage}},命令为:基于一个基础镜像构建用于运行目标应用的镜像。首先,确定出变量信息BaseImage在模板文件中的位置,作为目标位置;之后,获取示例3中变量信息BaseImage对应的待输入参数registry.wae.haplat.net/base/java:7,并将该待输入参数填充至示例1中的模板文件中变量信息BaseImage对应的目标位置,即可得到镜像构建脚本。如 此,可以简化构建镜像的过程,实现自动构建镜像。
本发明实施例中,所述模板文件中还包括所述至少一个变量信息对应的预设结构体;将每个变量信息对应的与目标应用匹配的待输入参数填充至目标位置之前,还包括:将获取的至少一对键值对解析成待匹配结构体;其中,待匹配结构体与预设结构体的格式一致。举个例子,当用户在AppInfo.json文件中输入至少一个变量信息对应的待输入参数时,即可通过json.Unmarshal函数将从AppInfo.json文件中获取的至少一个键值对解析成待匹配结构体。再将该待匹配结构体通过模板处理方式解析生成构建镜像脚本,其中模板处理方式可以通过text/template包或http/template包的模板处理功能实现。
本发明实施例提供一种确定出每个变量信息在所述模板文件中的目标位置,将每个变量信息对应的与目标应用匹配的待输入参数填充至目标位置得到镜像构建脚本的实施方式:将所述待匹配结构体中的每个变量信息与所述预设结构体中的每个变量信息进行匹配;若确定所述待匹配结构体中的变量信息与所述预设结构体中的变量信息一致,则:将所述预设结构体中的变量信息对应的位置确定为所述目标位置;将所述所述目标位置的变量信息删除,并将所述待匹配结构体中变量信息对应的与所述目标应用匹配的待输入参数填充至所述目标位置,得到镜像构建脚本。
本发明实施例中,镜像构建脚本不局限于Dockerfile文件,可以是任何镜像构建文件,以下提供一种根据示例3中的键值对和模板文件得到的镜像构建脚本的示例。
示例4:
FROM registry.wae.haplat.net/base/java:7
MAINTAINER huwh
RUN yum install-y file
COPY package/*/wplus-console/
COPY script/run.sh/usr/local/bin/
RUN rpm-ivh/wplus-console/*.rpm&&rm-r/wplus-console/*.rpm
COPY config/*/usr/local/wsop/console/conf/
RUN rm-fr/usr/local/wsop/console/logs
RUN ln-sf/wae/log/usr/local/wsop/console/logs
WORKDIR/usr/local/wsop/console/
CMD["/usr/local/bin/run.sh"]
根据示例4中的镜像构建脚本,执行镜像构建命令,可以实现一键式自动构建镜像。本发明实施例中,在执行构建镜像命令得到用于运行目标应用的镜像之前,还包括:根据与目标应用匹配的待输入参数确定用于运行目标应用的镜像的名称。一种可选的实施方式为,根据与目标应用匹配的待输入参数中的任多项确定镜像名称,举个例子,比如镜像名称命名由如下变量信息对应的待输入参数确定:
<docker-registry-url>/<namespace>/<app-name>:<version>;
其中,变量信息docker-registry-url为镜像中心地址,一般指的是域名,例如,其对应的待输入参数为registry.wae.haplat.net;变量信息namespace为命名空间,例如,其对应的待输入参数为wplus;变量信息app-name为应用名称,例如,其对应的待输入参数为wplus-console;变量信息version为应用版本号,例如,其对应的待输入参数为1.4.1-1;该例子中镜像的名称为:registry.wae.haplat.net/wplus/wplus-console:1.4.1-1./。
在生成镜像之后,即可将镜像推送到镜像仓库供后续验证及应用部署。所需使用到的命令如下:
查看镜像:docker images
推送镜像:docker push registry.wae.haplat.net/wplus/wplus-console:1.4.1-1。
为了更清楚的介绍上述方法流程,本发明实施例再提供一个示例。
图3示例性示出了本发明实施例提供的一种版本文件升级方法流程示意图,如图3所示,本发明实施例提供的一种版本文件升级方法,该方法包括以下步骤:
步骤301:获取目标应用所属的应用类型对应的模板文件;模板文件包括平台环境配置信息和至少一个变量信息;
步骤302:将至少一个变量信息显示在Web页面或目标应用的属性文件中;
步骤303:若监测到Web页面或目标应用的属性文件中存在数据输入,则获取每个变量信息和每个变量信息对应的输入的数据组成的至少一对键值对;每对键值对包括的关键字为变量信息,值为该变量信息对应的与目标应用匹配的待输入参数;
步骤304:将获取的至少一对键值对解析成待匹配结构体;所述模板文件中包括所述至少一个变量信息对应的预设结构体,待匹配结构体与预设结构体的格式一致;
步骤305:针对待匹配结构体中的每个变量信息,将待匹配结构体中的该变量信息与预设结构体中的每个变量信息进行匹配;
步骤306:从预设结构体中确定出与待匹配结构体中的该变量信息一致的变量信息;
步骤307:将预设结构体中确定出的与待匹配结构体中的该变量信息一致的变量信息对应的位置确定为目标位置;
步骤308:将目标位置处的变量信息删除,并将待匹配结构体中变量信息对应的与目标应用匹配的待输入参数填充至目标位置,得到镜像构建脚本;
步骤309:根据镜像构建脚本执行构建镜像命令,得到用于运行目标应用的镜像。
通过上述实施例可以看出,本发明实施例中,获取目标应用所属的应用类型对应的模板文件;模板文件包括平台环境的配置信息和至少一个变量信息;获取至少一个变量信息对应的与目标应用匹配的待输入参数;根据平台环境配置信息、至少一个变量信息和至少一个变量信息对应的与目标应用匹配的待输入参数,执行构建镜像命令得到用于运行目标应用的镜像。如此,开发或运维人员只需要知道至少一个变量信息对应的与目标应用匹配的待输入参数,就可 以实现自动构建运行目标应用类型的镜像,开发或运维人员无需学习镜像构建技术,可以减少学习成本。
基于以上实施例以及相同构思,图4为本发明实施例提供的一种用于构建镜像的装置结构示意图,如图4所示,该用于构建镜像的装置400可以对应上述方法中的用于构建镜像的装置。该用于构建镜像的装置可以实现如上图1中所示的任一项或任多项对应的方法中用于构建镜像的装置所执行的步骤。该用于构建镜像的装置400可以包括获取单元401、镜像构建单元403;可选的,还包括解析单元402。
获取单元401,用于获取目标应用所属的应用类型对应的模板文件;获取所述至少一个变量信息对应的与所述目标应用匹配的待输入参数;所述模板文件包括平台环境配置信息和至少一个变量信息;
镜像构建单元403,用于根据所述平台环境配置信息、所述至少一个变量信息和所述至少一个变量信息对应的与所述目标应用匹配的待输入参数,执行构建镜像命令得到用于运行所述目标应用的镜像。
本发明实施例中,开发或运维人员只需要知道至少一个变量信息对应的与目标应用匹配的待输入参数,将与目标应用匹配的待输入参数输入至模板文件中,就可以实现自动构建运行目标应用类型的镜像,开发或运维人员无需学习镜像构建技术,可以减少学习成本。
可选的,所述镜像构建单元403,用于:根据所述目标应用所属的应用类型对应的模板文件,确定出每个变量信息在所述模板文件中的目标位置;将所述每个变量信息对应的与所述目标应用匹配的待输入参数填充至所述目标位置,并根据填充后的模板文件生成镜像构建脚本;根据所述镜像构建脚本执行构建镜像命令,得到用于运行所述目标应用的镜像。
可选的,所述获取单元401,用于:将所述至少一个变量信息显示在Web页面或所述目标应用的属性文件中;若监测到所述Web页面或所述目标应用的属性文件中存在数据输入,则获取每个变量信息和每个变量信息对应的输入的 数据组成的至少一对键值对;每对键值对包括的关键字为变量信息,值为该变量信息对应的与所述目标应用匹配的待输入参数。
可选的,所述模板文件中还包括所述至少一个变量信息对应的预设结构体;所述装置还包括解析单元402,用于:将获取的所述至少一对键值对解析成待匹配结构体;所述待匹配结构体与所述预设结构体的格式一致;所述镜像构建单元403,用于:将所述待匹配结构体中的每个变量信息与所述预设结构体中的每个变量信息进行匹配;若确定所述待匹配结构体中的变量信息与所述预设结构体中的变量信息一致,则:将所述预设结构体中的变量信息对应的位置确定为所述目标位置;将所述所述目标位置处的变量信息删除,并将所述待匹配结构体中变量信息对应的与所述目标应用匹配的待输入参数填充至所述目标位置,得到镜像构建脚本。
可选的,所述镜像构建单元403,还用于:根据与所述目标应用匹配的待输入参数确定所述用于运行所述目标应用的镜像的名称。
该用于构建镜像的装置所涉及的与本发明实施例提供的技术方案相关的概念,解释和详细说明及其他步骤请参见前述方法或其他实施例中关于这些内容的描述,此处不做赘述。
需要说明的是,本发明实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。在本发明的实施例中的各功能模块可以集成在一个处理模块中,也可以是各个模块单独物理存在,也可以两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行计算机程序指令时,全部或部分地产生按照本发明实施例的流程或功能。计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。计算机指 令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk(SSD))等。
本领域内的技术人员应明白,本发明实施例可提供为方法、系统、或计算机程序产品。因此,本发明实施例可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明实施例可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本发明实施例是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理, 从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
显然,本领域的技术人员可以对本发明实施例进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明实施例的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。

Claims (12)

  1. 一种构建镜像的方法,其特征在于,包括:
    获取目标应用所属的应用类型对应的模板文件;所述模板文件包括平台环境配置信息和至少一个变量信息;
    获取所述至少一个变量信息对应的与所述目标应用匹配的待输入参数;
    根据所述平台环境配置信息、所述至少一个变量信息和所述至少一个变量信息对应的与所述目标应用匹配的待输入参数,执行构建镜像命令得到用于运行所述目标应用的镜像。
  2. 如权利要求1所述的方法,其特征在于,所述根据所述平台环境配置信息、所述至少一个变量信息和所述至少一个变量信息对应的与所述目标应用匹配的待输入参数,执行构建镜像命令得到用于运行所述目标应用的镜像,包括:
    根据所述目标应用所属的应用类型对应的模板文件,确定出每个变量信息在所述模板文件中的目标位置;
    将所述每个变量信息对应的与所述目标应用匹配的待输入参数填充至所述目标位置,并根据填充后的模板文件生成镜像构建脚本;
    根据所述镜像构建脚本执行构建镜像命令,得到用于运行所述目标应用的镜像。
  3. 如权利要求2所述的方法,其特征在于,所述获取所述至少一个变量信息对应的与所述目标应用匹配的待输入参数,包括:
    将所述至少一个变量信息显示在Web页面或所述目标应用的属性文件中;
    若监测到所述Web页面或所述目标应用的属性文件中存在数据输入,则获取每个变量信息和每个变量信息对应的输入的数据组成的至少一对键值对;每对键值对包括的关键字为变量信息,值为该变量信息对应的与所述目标应用匹配的待输入参数。
  4. 如权利要求3所述的方法,其特征在于,所述模板文件中还包括所述至少一个变量信息对应的预设结构体;所述将所述每个变量信息对应的与所述目 标应用匹配的待输入参数填充至所述目标位置之前,还包括:
    将获取的所述至少一对键值对解析成待匹配结构体;所述待匹配结构体与所述预设结构体的格式一致。
  5. 如权利要求4所述的方法,其特征在于,
    所述确定出每个变量信息在所述模板文件中的目标位置,将所述每个变量信息对应的与所述目标应用匹配的待输入参数填充至所述目标位置,并根据填充后的模板文件生成镜像构建脚本,包括:
    将所述待匹配结构体中的每个变量信息与所述预设结构体中的每个变量信息进行匹配;
    若确定所述待匹配结构体中的变量信息与所述预设结构体中的变量信息一致,则:
    将所述预设结构体中的变量信息对应的位置确定为所述目标位置;
    将所述目标位置处的变量信息删除,并将所述待匹配结构体中变量信息对应的与所述目标应用匹配的待输入参数填充至所述目标位置,得到镜像构建脚本。
  6. 如权利要求1-5任一项权利要求所述的方法,其特征在于,所述根据所述平台环境配置信息、所述至少一个变量信息和所述至少一个变量信息对应的与所述目标应用匹配的待输入参数,执行构建镜像命令得到用于运行所述目标应用的镜像之前,还包括:
    根据与所述目标应用匹配的待输入参数确定所述用于运行所述目标应用的镜像的名称。
  7. 一种用于构建镜像的装置,其特征在于,包括:
    获取单元,用于获取目标应用所属的应用类型对应的模板文件;获取所述至少一个变量信息对应的与所述目标应用匹配的待输入参数;所述模板文件包括平台环境配置信息和至少一个变量信息;
    镜像构建单元,用于根据所述平台环境配置信息、所述至少一个变量信息 和所述至少一个变量信息对应的与所述目标应用匹配的待输入参数,执行构建镜像命令得到用于运行所述目标应用的镜像。
  8. 如权利要求7所述的装置,其特征在于,所述镜像构建单元,用于:
    根据所述目标应用所属的应用类型对应的模板文件,确定出每个变量信息在所述模板文件中的目标位置;
    将所述每个变量信息对应的与所述目标应用匹配的待输入参数填充至所述目标位置,并根据填充后的模板文件生成镜像构建脚本;
    根据所述镜像构建脚本执行构建镜像命令,得到用于运行所述目标应用的镜像。
  9. 如权利要求8所述的装置,其特征在于,所述获取单元,用于:
    将所述至少一个变量信息显示在Web页面或所述目标应用的属性文件中;
    若监测到所述Web页面或所述目标应用的属性文件中存在数据输入,则获取每个变量信息和每个变量信息对应的输入的数据组成的至少一对键值对;每对键值对包括的关键字为变量信息,值为该变量信息对应的与所述目标应用匹配的待输入参数。
  10. 如权利要求9所述的装置,其特征在于,所述模板文件中还包括所述至少一个变量信息对应的预设结构体;所述装置还包括解析单元,用于:
    将获取的所述至少一对键值对解析成待匹配结构体;所述待匹配结构体与所述预设结构体的格式一致。
  11. 如权利要求10所述的装置,其特征在于,所述镜像构建单元,还用于:
    将所述待匹配结构体中的每个变量信息与所述预设结构体中的每个变量信息进行匹配;
    若确定所述待匹配结构体中的变量信息与所述预设结构体中的变量信息一致,则:
    将所述预设结构体中的变量信息对应的位置确定为所述目标位置;
    将所述所述目标位置处的变量信息删除,并将所述待匹配结构体中变量信 息对应的与所述目标应用匹配的待输入参数填充至所述目标位置,得到镜像构建脚本。
  12. 如权利要求7-11中任一项权利要求所述的装置,其特征在于,所述镜像构建单元,还用于:
    根据与所述目标应用匹配的待输入参数确定所述用于运行所述目标应用的镜像的名称。
PCT/CN2017/106896 2017-09-18 2017-10-19 一种构建镜像的方法和装置 Ceased WO2019051919A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
US16/316,443 US20210373870A1 (en) 2017-09-18 2017-10-19 Method and device for building images
EP17924930.5A EP3522005A4 (en) 2017-09-18 2017-10-19 METHOD AND DEVICE FOR CONSTRUCTING A MIRROR IMAGE

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710841510.5A CN107766052B (zh) 2017-09-18 2017-09-18 一种构建容器镜像的方法和装置
CN201710841510.5 2017-09-18

Publications (1)

Publication Number Publication Date
WO2019051919A1 true WO2019051919A1 (zh) 2019-03-21

Family

ID=61266059

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/106896 Ceased WO2019051919A1 (zh) 2017-09-18 2017-10-19 一种构建镜像的方法和装置

Country Status (4)

Country Link
US (1) US20210373870A1 (zh)
EP (1) EP3522005A4 (zh)
CN (1) CN107766052B (zh)
WO (1) WO2019051919A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112363806A (zh) * 2020-11-23 2021-02-12 北京信安世纪科技股份有限公司 一种集群管理方法、装置、电子设备及存储介质
CN116414383A (zh) * 2021-12-31 2023-07-11 第四范式(北京)技术有限公司 机器学习应用的构建方法、装置、设备及介质

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111124596A (zh) * 2018-11-01 2020-05-08 千寻位置网络有限公司 基于容器的发布管理方法及其系统
US20200244772A1 (en) * 2019-01-30 2020-07-30 Huawei Technologies Co., Ltd. Method and system for cloud application and service integration using pattern-based discovery
CN110058863A (zh) * 2019-03-16 2019-07-26 平安城市建设科技(深圳)有限公司 Docker容器的构建方法、装置、设备及存储介质
CN110187912B (zh) * 2019-05-16 2022-03-29 华为技术有限公司 一种节点选择方法和装置
CN113448597A (zh) * 2020-03-26 2021-09-28 顺丰科技有限公司 容器镜像的模板管理方法、装置、设备及存储介质
CN111930419B (zh) * 2020-07-30 2021-08-10 深圳市威富视界有限公司 基于深度学习模型的代码包生成方法和系统
CN112015376A (zh) * 2020-08-21 2020-12-01 广州欢网科技有限责任公司 一种生成Dockerfile的方法和装置
CN117762427A (zh) * 2022-09-19 2024-03-26 腾讯科技(深圳)有限公司 应用部署方法、装置和计算机可读存储介质
CN115686548A (zh) * 2022-11-17 2023-02-03 中电云数智科技有限公司 一种构建适应不同应用场景的云操作系统版本的方法
CN115840588A (zh) * 2023-02-14 2023-03-24 北京万里红科技有限公司 应用于debian系统的基于VSCode环境制作ISO镜像的方法
CN116560722B (zh) * 2023-07-12 2024-01-02 腾讯科技(深圳)有限公司 运维流程处理方法、装置、电子设备及存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101697135A (zh) * 2009-10-28 2010-04-21 北京东方网力科技有限公司 一种编译程序的方法及装置
CN101819530A (zh) * 2010-04-30 2010-09-01 山东中创软件工程股份有限公司 一种程序对象生成方法、装置及计算机
US20110314444A1 (en) * 2010-06-18 2011-12-22 Microsoft Corporation Compiler-Generated Invocation Stubs for Data Parallel Programming Model
CN103186376A (zh) * 2011-12-30 2013-07-03 百度在线网络技术(北京)有限公司 一种用于建立或更新软件开发环境的方法、装置和设备
CN106802807A (zh) * 2017-02-20 2017-06-06 深圳市冬泉谷信息技术有限公司 基于容器平台的应用交付方法、容器平台及应用交付系统
CN106874052A (zh) * 2017-02-24 2017-06-20 北京中电普华信息技术有限公司 一种应用程序的部署方法和装置

Family Cites Families (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CA2713247C (en) * 2009-08-31 2015-06-16 Accenture Global Services Gmbh Integration environment generator
US8739150B2 (en) * 2010-05-28 2014-05-27 Smartshift Gmbh Systems and methods for dynamically replacing code objects via conditional pattern templates
CN103294450B (zh) * 2012-02-22 2018-04-06 腾讯科技(深圳)有限公司 应用发布方法及系统
US8930899B2 (en) * 2012-08-18 2015-01-06 International Business Machines Corporation Artifact divider for large scale application builds
CN104580519B (zh) * 2015-01-29 2017-11-28 福建师范大学福清分校 一种快速部署openstack云计算平台的方法
US20160350081A1 (en) * 2015-05-27 2016-12-01 Runnable Inc. Automatic container definition
KR101831430B1 (ko) * 2015-10-27 2018-02-22 삼성에스디에스 주식회사 인프라의 설치와 구성을 자동화하는 장치 및 그 방법
CN105404506A (zh) * 2015-10-30 2016-03-16 广州云晫信息科技有限公司 一种云计算镜像文件的构建方法及系统
CN107533436B (zh) * 2015-11-29 2021-02-02 慧与发展有限责任合伙企业 硬件管理
CN106406978B (zh) * 2016-08-31 2020-11-10 宝信软件(武汉)有限公司 私有云虚拟机模板自动制作装置及方法
CN106406951B (zh) * 2016-09-20 2020-02-11 新华三信息技术有限公司 一种操作系统的安装方法和装置
CN106657248A (zh) * 2016-11-01 2017-05-10 山东大学 一种基于Docker容器的网络负载均衡系统及其搭建方法、工作方法
CN106790595B (zh) * 2016-12-29 2020-12-22 上海理想信息产业(集团)有限公司 一种Docker容器主动负载均衡装置及方法

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101697135A (zh) * 2009-10-28 2010-04-21 北京东方网力科技有限公司 一种编译程序的方法及装置
CN101819530A (zh) * 2010-04-30 2010-09-01 山东中创软件工程股份有限公司 一种程序对象生成方法、装置及计算机
US20110314444A1 (en) * 2010-06-18 2011-12-22 Microsoft Corporation Compiler-Generated Invocation Stubs for Data Parallel Programming Model
CN103186376A (zh) * 2011-12-30 2013-07-03 百度在线网络技术(北京)有限公司 一种用于建立或更新软件开发环境的方法、装置和设备
CN106802807A (zh) * 2017-02-20 2017-06-06 深圳市冬泉谷信息技术有限公司 基于容器平台的应用交付方法、容器平台及应用交付系统
CN106874052A (zh) * 2017-02-24 2017-06-20 北京中电普华信息技术有限公司 一种应用程序的部署方法和装置

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3522005A4 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112363806A (zh) * 2020-11-23 2021-02-12 北京信安世纪科技股份有限公司 一种集群管理方法、装置、电子设备及存储介质
CN112363806B (zh) * 2020-11-23 2023-09-22 北京信安世纪科技股份有限公司 一种集群管理方法、装置、电子设备及存储介质
CN116414383A (zh) * 2021-12-31 2023-07-11 第四范式(北京)技术有限公司 机器学习应用的构建方法、装置、设备及介质

Also Published As

Publication number Publication date
EP3522005A1 (en) 2019-08-07
US20210373870A1 (en) 2021-12-02
CN107766052B (zh) 2020-09-25
EP3522005A4 (en) 2019-12-18
CN107766052A (zh) 2018-03-06

Similar Documents

Publication Publication Date Title
CN107766052B (zh) 一种构建容器镜像的方法和装置
US10515005B1 (en) Systems and methods for testing source code
US10635406B2 (en) Determining the identity of software in software containers
JP7597865B2 (ja) 実行時コンテナ
US9021438B2 (en) Automatic framework for parallel testing on multiple testing environments
US10983774B2 (en) Extensions for deployment patterns
US9678740B2 (en) Migration mechanism
Familiar Microservices, IoT, and Azure
US20150365275A1 (en) Cloud environment configuration for cloud applications
US20210034357A1 (en) Software versioning for network connected devices
CN104423983A (zh) 用于开发、测试和部署应用的方法和装置
CN104461567A (zh) 软件包的发布方法及系统
US12204916B2 (en) Techniques for migrating services from a virtual bootstrap environment
US12314693B2 (en) Visual generation of software deployment pipelines using recommendations of development and operations blueprints
US20200174754A1 (en) Command tool development
US11604662B2 (en) System and method for accelerating modernization of user interfaces in a computing environment
US8806434B2 (en) Dynamically configuring an integrated development environment
Bhattacharjee et al. Cloudcamp: A model-driven generative approach for automating cloud application deployment and management
US20120192144A1 (en) Migrating unified modeling language models across unified modeling language profiles
US12481540B2 (en) Techniques for resource discovery while building data centers
Stoneman Docker on Windows: From 101 to production with Docker on Windows
US11231457B1 (en) Continuous integration for integrated circuit design
CN115629753A (zh) 前端项目的构建方法、装置、电子设备及存储介质
CN116069381A (zh) 资源包的处理方法、装置、电子设备、存储介质及产品
US20260072869A1 (en) Techniques for generating and utilizing cloud service images

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17924930

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2017924930

Country of ref document: EP

Effective date: 20190430

NENP Non-entry into the national phase

Ref country code: DE