Mirror image construction method and device, electronic equipment, storage medium and program product
By establishing a cache layer and shared network on the compilation server, the problem of increased Docker image build time is solved, and efficient and stable construction of Python project images is achieved.
Patent Information
- Application Number
- CN202510976212.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-15
- Publication Date
- 2025-10-28
AI Technical Summary
Existing technologies require downloading and unzipping Python Wheel files from a remote private repository when building images using Docker in Python projects, which increases image build time and fails to meet the agile build requirements of the business.
Add a preset cache layer to the compilation server. Through the shared network between the target compilation container node and the preset cache layer, the compilation image file is stored in the cache layer. When the image container node builds the image, it directly retrieves it from the cache layer, avoiding re-downloading.
It accelerates the image building process, improves the stability and timeliness of image building, and meets the business requirements for agile building.
Smart Images

Figure CN120849015A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to Internet technology, and in particular to a method for creating an image, an apparatus, an electronic device, a storage medium, and a program product. Background Technology
[0002] An image is a lightweight, executable software package used to run applications. In Python projects, images are commonly used to package and distribute Python applications and their dependencies. Currently, the most common way to create Python project images is using Docker.
[0003] In Python projects, building images using Docker typically involves the following steps: First, create a file named Dockerfile; second, define the base image, copy project files, install dependencies, and configure environment variables in the Dockerfile; finally, build the Docker image. However, the dependencies and environment variables defined in the second step need to be downloaded from a remote private repository, such as Python Wheel files. Python Wheel files are a standard built-in package format for distributing and installing Python projects. They contain all the files and metadata required for installation and are usually compressed using zip. After downloading, the files also need to be decompressed. This entire process increases image build time, severely delaying business progress and failing to meet the requirements of agile builds. Summary of the Invention
[0004] To address the technical problems in related technologies, embodiments of this disclosure provide a method, apparatus, electronic device, storage medium, and program product for image creation.
[0005] According to a first aspect of this disclosure, a method for building an image is provided, the method being applied to a compilation server, the compilation server including a preset cache layer, the method comprising: In response to a received project image request, create the target build container node for the project; A target sharing network is established between the target compilation container node and the preset cache layer. The target sharing network is used to share compilation image files between the target compilation container node and the preset cache layer, so that the target compilation container node stores the compilation image files in the preset cache layer. The compilation image files are obtained by the target compilation container node from the preset server during the image compilation process. The preset cache layer is mounted to the preset image container node so that when the preset image container node executes the image build command, it can obtain the compiled image file from the preset cache layer and build the target image based on the compiled image file.
[0006] As an optional embodiment, the step of creating the target build container node for the project in response to a received project image request includes: In response to the received project image request, a container resource management component is created by invoking a preset container creation plugin; Container parameters are configured by configuring the component template of the container resource management component. The container parameters include container volume definition and type, container specifications, and container volume mount point. The container is run based on the container parameters, and the running container is determined as the target compilation container node of the project.
[0007] As an optional embodiment, establishing a target shared network between the target build container node and the preset cache layer, wherein the target shared network is used to share build image files between the target build container node and the preset cache layer, includes: Create the target cache directory in the preset cache layer; Mount the container volume of the target compiled container node to the target cache directory; A target mount point is created for the target cache directory of the container volume on which the target compilation container node is mounted, so that the target compilation container node can access the target cache directory through the target mount point and persistently store the compilation image file in the target cache directory of the preset cache layer.
[0008] As an optional embodiment, mounting the container volume of the target compilation container node to the target cache directory includes: The target container volume of the target compilation container node is determined based on the container parameters of the target compilation container node. The target container volume is the container volume of the target compilation container node to be mounted to the target cache directory. Mount the target container volume to the target cache directory of the preset cache layer.
[0009] As an optional embodiment, determining the target container volume of the target compilation container node based on the container parameters of the target compilation container node, wherein the target container volume of the target compilation container node is the container volume of the target compilation container node to be mounted to the target cache directory, includes: Obtain the container volume definition and its type from the container parameters of the target compiled container node; The container volume definition and the container volume corresponding to its type are determined as the target container volume, which is the container volume of the target compiled container node to be mounted to the target cache directory.
[0010] As an optional embodiment, mounting the preset cache layer to a preset image container node, so that the preset image container node obtains the compiled image file from the preset cache layer when executing an image build command, and builds the target image based on the compiled image file, includes: Mount the target cache directory of the preset cache layer to the preset image container node; When the preset image container node executes the image build command, it obtains the compiled image file from the target cache directory of the preset cache layer through the preset image container node, and builds the target image of the project based on the compiled image file.
[0011] According to a second aspect of this disclosure, an image building apparatus is provided, the apparatus being applied to a compilation server, the compilation server including a preset cache layer, the apparatus comprising: The container creation module is used to create the target build container node for the project in response to a received project image request; The file sharing module is used to establish a target sharing network between the target compilation container node and the preset cache layer. The target sharing network is used for sharing compilation image files between the target compilation container node and the preset cache layer, so that the target compilation container node stores the compilation image files in the preset cache layer. The compilation image files are obtained by the target compilation container node from the preset server during the image compilation process. The image building module is used to mount the preset cache layer to the preset image container node, so that when the preset image container node executes the image building command, it can obtain the compiled image file from the preset cache layer and build the target image based on the compiled image file.
[0012] As an optional embodiment, the container creation module includes: The component creation unit is used to create a container resource management component by calling a preset container creation plugin in response to the received project image request. The container parameter configuration unit is used to configure container parameters by configuring the component template of the container resource management component. The container parameters include container volume definition and type, container specifications, and container volume mount point. A container runtime unit is used to run a container based on the container parameters, wherein the running container is determined to be the target compilation container node of the project.
[0013] As an optional embodiment, the file sharing module includes: A cache directory creation unit is used to create a target cache directory in the preset cache layer; The first directory mounting unit is used to mount the container volume of the target compilation container node to the target cache directory; The mount point creation unit is used to create a target mount point for the target cache directory of the container volume on which the target compilation container node is mounted, so that the target compilation container node can access the target cache directory through the target mount point and persistently store the compilation image file in the target cache directory of the preset cache layer.
[0014] As an optional embodiment, the first directory mounting unit is further configured to: The target container volume of the target compilation container node is determined based on the container parameters of the target compilation container node. The target container volume is the container volume of the target compilation container node to be mounted to the target cache directory. Mount the target container volume to the target cache directory of the preset cache layer.
[0015] As an optional embodiment, the first directory mounting unit determines the target container volume of the target compilation container node based on the container parameters of the target compilation container node, wherein the target container volume is the container volume of the target compilation container node to be mounted to the target cache directory, and further includes: Obtain the container volume definition and its type from the container parameters of the target compiled container node; The container volume definition and the container volume corresponding to its type are determined as the target container volume, which is the container volume of the target compiled container node to be mounted to the target cache directory.
[0016] As an optional embodiment, the image building module includes: The second directory mounting unit is used to mount the target cache directory of the preset cache layer to the preset image container node in response to the project image request; The file acquisition unit is used to acquire the compiled image file from the target cache directory of the preset cache layer through the preset image container node when the preset image container node executes the image build command, so as to build the target image of the project based on the compiled image file.
[0017] According to a third aspect of this disclosure, an electronic device is provided, comprising: Memory, used to store computer program products; A processor is configured to execute a computer program product stored in the memory, and when the computer program product is executed, to implement the method described in the first aspect above.
[0018] According to a fourth aspect of this disclosure, a computer-readable storage medium is provided that stores computer program instructions thereon, which, when executed by a processor, implement the method described in the first aspect above.
[0019] According to a fifth aspect of this disclosure, a computer program product is provided, including computer program instructions that, when executed by a processor, implement the method described in the first aspect above.
[0020] According to the technical solution of this disclosure, by adding a compilation container node, the compilation image file obtained from a preset server (e.g., a private server) during the compilation process is stored in the cache layer of the compilation server. When the image container node creates an image, it can directly obtain the compilation image file from the cache layer of the compilation server for image building, instead of downloading the compilation image file from the preset server (e.g., a private server) and installing it into the project (i.e., the Python project) installation directory every time. In this way, by using the cache layer to store the compilation image file, the image building process is accelerated, and the stability of the image building task is guaranteed. This ensures the timeliness and stability of the project (i.e., the Python project) image building, meeting the business requirements for agile image building.
[0021] The technical solutions of this disclosure will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0022] The accompanying drawings, which form part of this specification, illustrate embodiments of this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0023] This disclosure will become clearer with reference to the accompanying drawings and the following detailed description, wherein: Figure 1 A system architecture schematic diagram constructed as a mirror image of the related technologies in the embodiments of this disclosure; Figure 2 This is one of the flowcharts for an embodiment of the image construction method disclosed herein; Figure 3 This is a second flowchart of a mirror construction method according to an embodiment of the method disclosed herein; Figure 4 This is a flowchart of a mirror construction method according to an embodiment of the method disclosed herein; Figure 5 This is a schematic diagram illustrating the implementation principle of the preset cache layer in an embodiment of the method disclosed herein; Figure 6This is a schematic diagram of the system structure constructed according to an embodiment of the method of this disclosure; Figure 7 This is a structural block diagram of a mirror construction apparatus according to one embodiment of the apparatus disclosed herein; Figure 8 This is a structural block diagram of an electronic device provided in an embodiment of the present disclosure. Detailed Implementation
[0024] Figure 1 This refers to the image building process of Python projects on a host machine (or compilation server) in related technologies. In related technologies, such as... Figure 1 As shown, the host machine (or build server) operating system includes a Git container (GitLab Container Registry) for code management and a Docker-Cli container for creating (or building) images of Python projects. During each image build process, the Docker-Cli container needs to pull (or download) the Python Wheel file (or image library) from the private repository. After downloading the Python Wheel file (or image library), it needs to be decompressed and then installed into the Python project's installation directory to create the Python project image. This process involves a significant amount of time for the Docker-Cli container to pull (or download) the Python Wheel file from the private repository, and the download and decompression process further increases the image creation time. Therefore, this severely delays the business verification process and fails to meet the business requirements for agile building.
[0025] To address the technical problems in related technologies, this disclosure provides a method, apparatus, electronic device, storage medium, and program product for image creation. The technical solutions of this disclosure are described in detail below with reference to the accompanying drawings.
[0026] Figure 2 This is one of the flowcharts for an embodiment of the image construction method disclosed herein. Figure 2 As shown in the figure, an image building method according to an embodiment of this disclosure is applied to a compilation server, wherein the compilation server includes a preset cache layer, and the method may include the following steps: Step 201: In response to the received project image request, create the project's build container node (hereinafter referred to as: target build container node).
[0027] In this embodiment, the operating system of the compilation server can run a technology stack, such as the Kubernetes technology stack. Upon receiving an image request for any Python project, the target compilation container node can be created using Kubernetes. For example, in response to the received project image request, a container resource management component is created by calling a preset container creation plugin. Then, container parameters are configured by configuring the component template of the container resource management component. Container parameters include, but are not limited to, container volume definitions and types, container specifications, and container volume mount points. Based on these container parameters, the container is then run, and this run container is determined to be the project's compilation container node. The container resource management component is a logical group or configuration set whose core purpose is to manage various container resources required in a project. Therefore, the container resource management component needs to define multiple container runtime environments and configurations. Defining multiple container runtime environments and configurations is achieved through component templates (or Pod templates; corresponding to the component templates of the container resource management component). In this embodiment, the component template may include the specifications (image, command, environment variables, resource requests / limits, etc.) of the compiled container to be created, the definition and type of container volume (e.g., hostPath, emptyDir, PersistentVolumeClaim, etc.), and the volume mount point (specifying which volume to mount to which path within the container). These are used to define the container runtime environment and configure the container (i.e., complete the configuration of container parameters). These container parameters can be customized according to the needs of specific projects or tasks so that the container can achieve specific projects or tasks. Based on these container parameters, the configured container can run, i.e., the container configuration is completed. The configured container is determined as the target compiled container node of the project.
[0028] It should be noted that the build container node created for the project in the project image request is referred to here as the target build container node. For example, if the project image request is a request to create an image for Python project A, then the build container node created for Python project A in step 201 is referred to as the target build container node for Python project A.
[0029] Specifically, for example, the creation of the target compilation container node can be achieved through Kubernetes: First, a container resource management component can be created by calling the Jenkins Kubernetes plugin (the default container creation plugin), thereby dynamically defining the Pod template (i.e., the component template of the container resource management component). Specifically, a YAML file (i.e., YAML Ain't Markup Language, a readable data serialization standard widely used for configuration files and data exchange) is created, which contains the configuration information of the Pod template. This configuration information includes, but is not limited to, container parameters such as the container image, port, resource requests, and limits. Then, the kubectl command-line tool is used to apply the YAML file, that is, to create and run the container according to the container parameters configured therein, and then identify the container as the target build container node, thus completing the creation of the target build container node. The kubectl command-line tool is the command-line tool for Kubernetes clusters, used to communicate with the Kubernetes API to manage and operate the Kubernetes cluster, such as creating, retrieving, describing, and deleting Pod resources in the Kubernetes cluster, and running and creating containers.
[0030] The Jenkins K8S plugin is a plugin that allows Jenkins to interact with a Kubernetes cluster. In this embodiment, it is mainly used to deploy and manage Pods in a Kubernetes cluster. That is, the Jenkins K8S plugin allows Jenkins to start, stop and manage Pods in a Kubernetes cluster, supporting continuous integration and continuous deployment (CI / CD) processes.
[0031] Component templates are specifications used to create and manage containers, and can be implemented through definition files. These definition files may include, but are not limited to, the following: 1. apiVersion: This specifies the version of the Kubernetes API; 2. kind: Specifies the resource type, usually "Pod"; 3. Metadata: Contains the Pod's metadata, such as name, namespace, etc.
[0032] 4. `spec`: Contains a detailed definition of the Pod, such as the list of containers, resource limits, etc. Understandably, in the creation of Python project images, such as Figure 1As shown, because the Python project image is strongly bound to the Python project's runtime environment, it is possible to have only the image stage without a compilation stage, which prevents the Python Wheel file from being persisted. To solve this problem, in this embodiment of the disclosure, a new compilation node, namely the target compilation container node, is added to the compilation server. Thus, when the Python project image is created for the first time, the Python Wheel file can be retrieved from the private repository (hereinafter referred to as the default server) through the target compilation container node.
[0033] like Figure 6 The diagram shown is a schematic diagram of the system structure for image construction according to an embodiment of the method of this disclosure. Figure 1 Based on the structure diagram shown, this embodiment adds a target compilation container node, namely the Python container for compilation shown in the diagram, and... Figure 1 The difference between the illustrated embodiment and the actual embodiment is that in this embodiment, the Python Wheel file is obtained from a private repository (hereinafter referred to as the default server) through the target compilation container node (i.e., the Python container).
[0034] Step 202: Establish a shared network between the target compilation container node and the preset cache layer (hereinafter referred to as the target shared network).
[0035] The target shared network is used to share the compiled image file between the target compilation container node and the preset cache layer, so that the target compilation container node stores the compiled image file in the preset cache layer.
[0036] Among them, the compiled image file, such as the aforementioned Python Wheel file, is obtained by the target compiled container node from a preset server (such as a private repository) during the image compilation process.
[0037] In this embodiment, the target shared network between the target build container node and the preset cache layer is mainly used for file sharing between the target build container node and the preset cache layer, such as sharing build image files. That is, after the target build container node pulls the build image file from, for example, a private repository, it can store the build image file by accessing the cache directory of the preset cache layer through this target shared network. Specifically, this target shared network can be established by configuring a storage volume (e.g., a hostpath volume, a type of storage volume used in Kubernetes that can mount directories or files on worker nodes into Pods, allowing containers to access these directories or files) on the target build container node, mounting the storage volume to the directory of the preset cache layer on the build server, and setting the mount point of the preset cache layer's directory on the target build container node. This allows the target build container node to access the directory of the preset cache layer.
[0038] Step 203: Mount the preset cache layer to the preset image container node so that when the preset image container node executes the image build command, it can obtain the compiled image file from the preset cache layer and build the target image based on the compiled image file.
[0039] The target image is the image created for the project in the project image request. In this disclosure, it can be called the target image. Taking Python project A as an example, the image created for Python project A in step 203 is called the target image of Python project A.
[0040] Specifically, as mentioned above Figure 1 The operating system of the compilation server also runs an image container node for building the project image. In this embodiment, when a project image request is received, a preset cache layer can be mounted to the preset image container node. Thus, when the preset image container node builds the image, it can access the preset cache layer to obtain the compiled image file stored in the preset cache layer during the initial compilation of the target compilation container node, and use it to build the target image of the project.
[0041] In this way, by avoiding network communication between the image container node and, for example, a private repository, and directly obtaining the compiled image file from the pre-set cache layer of the compilation server, the image building process can be accelerated, and the problem of failure to obtain the compiled image file due to network issues can be avoided, thus ensuring the stability of the image building.
[0042] exist Figure 2 Based on the embodiments shown, this disclosure also provides embodiments such as Figure 3 The example shown. Figure 3 This is a second flowchart of an embodiment of the image construction method disclosed herein, as shown below. Figure 3 As shown, step 202 can be specifically implemented as follows: Step 2021: Create the target cache directory in the preset cache layer.
[0043] like Figure 5 The diagram shown illustrates the implementation principle of the preset cache layer in an embodiment of the method disclosed herein. (Reference) Figure 5 In this embodiment of the disclosure, the preset cache layer may be, for example, an OverlayFS stacked file system (a file system service for Linux, mainly used to implement the joint mounting of multiple file systems), which may include at least a read-only layer (e.g., LowerDir 1 and LowerDir 2 in the figure), a read-write layer (e.g., UpperDir in the figure) and a merge layer (e.g., MergedDir in the figure).
[0044] The LowerDir 1 or LowerDir 2 (read-only layer) and UpperDir (read-write layer) are different directories from the underlying file system, which can contain files and directories that need to be merged. The MergedDir layer is the mount point for files or directories. Under directories mounted in MergedDir, contents from both LowerDir 1 or LowerDir 2 and UpperDir (read-write layer) can be seen simultaneously. When directories or files with the same name exist in LowerDir 1 or LowerDir 2 and UpperDir (read-write layer), the files in LowerDir 1 or LowerDir 2 will be hidden, and users will only see directories or files in UpperDir (read-write layer). OverlayFS is used as a caching layer; it does not directly participate in disk space allocation, but simply merges and presents different directories or files from the underlying file system. For a specific example, suppose there are newly written files A and B, or a modified file C. These will all be updated in the read-write layer UpperDir. The merged layer MergedDir will also see the newly written files A and B, as well as the modified file C. The read-only layer LowerDir 1 is used to persist files, storing the newly written files A and B persistently. The read-only layer LowerDir 2 can serve as the base directory for storing the original files. Files that have changed in the read-write layer UpperDir, such as the newly written files A and B, and the modified file C, need to be updated in the read-only layer LowerDir 2 to ensure that the files there are consistent with those in the merged layer MergedDir.
[0045] In this embodiment of the disclosure, using the OverlayFS stacked file system as a cache layer is an optional embodiment. A corresponding cache directory is created in the preset cache layer, such as the target cache directory / host / job / share, to store the compiled image files from the target compilation container node. The OverlayFS stacked file system as the cache layer can merge the compiled image files from the target compilation container node during each compilation process, thereby persistently storing all the compiled image files in the target cache directory and displaying them in the MergedDir layer for users to view and read.
[0046] Thus, this embodiment uses the OverlayFS stacked file system as a caching layer and the UpperDir memory-based read / write layer to implement file (or directory) read and write operations. Therefore, it does not call the disk to update files or directories, which can reduce disk read / write pressure and improve the efficiency of subsequent image building.
[0047] Step 2022: Mount the container volume of the target compiled container node to the target cache directory.
[0048] In order for the compilation server to read the files of the target compilation container node, in this embodiment of the disclosure, the target container volume of the target compilation container node is determined according to the container parameters of the target compilation container node. The target container volume is the container volume of the target compilation container node to be mounted to the target cache directory, and the target container volume is mounted to the target cache directory of the preset cache layer. Further, the container volume definition and its type can be obtained from the container parameters of the target compilation container node; the container volume corresponding to the container volume definition and its type is determined as the target container volume, which is the container volume of the target compilation container node to be mounted to the target cache directory. For example, in this embodiment of the disclosure, a hostpath volume (e.g., the / root / .cache / pip directory) can be configured on the target compilation container node, and the hostpath volume can be mounted as the target container volume to the target cache directory. Assuming the target cache directory is / host / job / share, the hostpath volume is mounted to the / host / job / share directory. This allows the preset cache layer to obtain the compiled image file from the target container volume of the target compilation container node for storage.
[0049] Step 2023: Create a target mount point for the target cache directory of the container volume that mounts the target compilation container node, so that the target compilation container node can access the target cache directory through the target mount point and persistently store the compiled image file to the target cache directory of the preset cache layer.
[0050] After mounting the container volume of the target build container node to the target cache directory, the build image file pulled by the target build container node during the initial build is persistently stored in the target cache directory of the preset cache layer. To ensure that the target build container node can access all build image files (including existing and incremental build image files) in the target cache directory of the preset cache layer in the build server during subsequent new image build processes, a mount point corresponding to the target cache directory, i.e., the target mount point, can be created. In this embodiment, using the OverlayFS stacked file system as the cache layer, the target mount point is determined to be the MergedDir layer. Figure 5 As shown), it can be used as the mount point for the hostpath volume (e.g., the / root / .cache / pip directory). In this way, the target compilation container node in the subsequent new image building process can access all the compilation image files in the target cache directory / host / job / share of the preset cache layer in the compilation server.
[0051] In this embodiment, the target compilation container node executes a compilation and installation process such as `pip install`, which installs the compiled image file to its directory, for example, ` / root / .cache / pip`, and synchronizes it in real time to the target cache directory ` / host / job / share` in the preset cache layer of the compilation server. This speeds up image building efficiency, and because all compiled image files are included in the target cache directory of the preset cache layer, it avoids image building failures caused by erroneous compiled image files, thereby improving the stability of image building.
[0052] As an optional embodiment of this disclosure, in Figure 2 and Figure 3 Based on the illustrated embodiments, as Figure 4 As shown, step 203 can also be achieved through the following steps: Step 2031: In response to the project image request, mount the target cache directory of the preset cache layer to the preset image container node.
[0053] Step 2032: When the preset image container node executes the image build command, it obtains the compiled image file from the target cache directory of the preset cache layer through the preset image container node, and builds the target image of the project based on the compiled image file.
[0054] In this embodiment, the preset image container node performs the image creation (or building) process. First, it mounts the target cache directory (e.g., / host / job / share) of the preset cache layer in the compilation server to the / root / .cache / pip directory of the preset image container node. Then, it executes the Dockerfile command (referring to the instructions defined in the Dockerfile for building the Docker image). The preset image container node can directly obtain the compiled image file from the target cache directory (e.g., / host / job / share) for building the target image of the project.
[0055] In summary, this embodiment of the present disclosure adds a compilation container node to store the compilation image file obtained from a preset server (e.g., a private server) during the compilation process in the cache layer of the compilation server. When the image container node creates an image, it can directly obtain the compilation image file from the cache layer of the compilation server for image building, instead of downloading the compilation image file from the preset server (e.g., a private server) and installing it into the project (i.e., the Python project) installation directory every time. In this way, by using the cache layer to store the compilation image file, the image building process is accelerated, and the stability of the image building task is ensured, guaranteeing the timeliness and stability of the project (i.e., the Python project) image building, thus meeting the business requirements for agile image building.
[0056] Correspondingly, this disclosure also provides apparatus embodiments corresponding to the foregoing method embodiments. Figure 7 This is a structural block diagram of a mirror construction apparatus according to one embodiment of the present disclosure, as shown below. Figure 7 As shown in the figure, an image building apparatus according to an embodiment of this disclosure is applied to a compilation server, and the compilation server includes a preset cache layer. The apparatus may include: The container creation module 701 is used to create the target compilation container node of the project when a project image request is received. The file sharing module 702 is used to establish a target sharing network between the target compilation container node and the preset cache layer. The target sharing network is used for sharing compilation image files between the target compilation container node and the preset cache layer, so that the target compilation container node stores the compilation image files in the preset cache layer. The compilation image files are obtained by the target compilation container node from the preset server during the image compilation process. The image building module 703 is used to mount the preset cache layer to the preset image container node, so that when the preset image container node executes the image building command, it can obtain the compiled image file from the preset cache layer and build the target image based on the compiled image file.
[0057] exist Figure 7 Based on the illustrated embodiments, the following embodiments are further provided: As an optional embodiment, the container creation module includes: The container creation unit is used to respond to the received project image request by calling a preset container creation plugin to create a container resource management component, configure the container and container volume of the container by configuring the container resource management component template, and obtain the target compilation container node of the project.
[0058] As an optional embodiment, the file sharing module includes: A cache directory creation unit is used to create a target cache directory in the preset cache layer; The first directory mounting unit is used to mount the container volume of the target compilation container node to the target cache directory; The mount point creation unit is used to create a target mount point for the target cache directory of the container volume on which the target compilation container node is mounted, so that the target compilation container node can access the target cache directory through the target mount point and persistently store the compilation image file in the target cache directory of the preset cache layer.
[0059] As an optional embodiment, the first directory mounting unit is further configured to: The target container volume of the target compilation container node is determined based on the container parameters of the target compilation container node. The target container volume is the container volume of the target compilation container node to be mounted to the target cache directory. Mount the target container volume to the target cache directory of the preset cache layer.
[0060] As an optional embodiment, the first directory mounting unit determines the target container volume of the target compilation container node based on the container parameters of the target compilation container node, wherein the target container volume is the container volume of the target compilation container node to be mounted to the target cache directory, and further includes: Obtain the container volume definition and its type from the container parameters of the target compiled container node; The container volume definition and the container volume corresponding to its type are determined as the target container volume, which is the container volume of the target compiled container node to be mounted to the target cache directory.
[0061] As an optional embodiment, the image building module includes: The second directory mounting unit is used to mount the target cache directory of the preset cache layer to the preset image container node in response to the project image request; The file acquisition unit is used to acquire the compiled image file from the target cache directory of the preset cache layer through the preset image container node when the preset image container node executes the image build command, so as to build the target image of the project based on the compiled image file.
[0062] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this disclosure. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0063] Below, for reference Figure 8This describes an electronic device according to embodiments of the present disclosure. The electronic device may be either or both of a first device and a second device, or a standalone device independent of them, which may communicate with the first device and the second device to receive acquired input signals from them.
[0064] Figure 8 A block diagram of an electronic device according to an embodiment of the present disclosure is shown.
[0065] like Figure 8 As shown, the electronic device includes one or more processors and memory.
[0066] A processor can be a central processing unit (CPU) or other form of processing unit with data processing and / or instruction execution capabilities, and can control other components in an electronic device to perform desired functions.
[0067] The memory can store one or more computer program products, and the memory can include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program products can be stored on the computer-readable storage medium, and the processor can run the computer program products to implement the image construction methods of the various embodiments of this disclosure described above and / or other desired functions.
[0068] In one example, the electronic device may also include input devices and output devices, which are interconnected via a bus system and / or other forms of connection mechanism (not shown).
[0069] In addition, the input device may also include, for example, a keyboard, a mouse, etc.
[0070] This output device can output various information to the outside, including determined distance information, direction information, etc. The output device may include, for example, a display, a speaker, a printer, and a communication network and its connected remote output devices, etc.
[0071] Of course, for the sake of simplicity, Figure 8 Only some of the components of the electronic device relevant to this disclosure are shown, omitting components such as buses, input / output interfaces, etc. In addition, the electronic device may include any other suitable components depending on the specific application.
[0072] In addition to the methods and apparatus described above, embodiments of this disclosure may also be computer program products comprising computer program instructions that, when executed by a processor, cause the processor to perform the steps in the image building methods according to various embodiments of this disclosure as described in the foregoing portions of this specification.
[0073] The computer program product can be written in any combination of one or more programming languages to perform the operations of the embodiments of this disclosure. The programming languages include object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on a user's computing device, partially on a user's computing device, as a standalone software package, partially on a user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0074] Furthermore, embodiments of this disclosure may also be computer-readable storage media storing computer program instructions that, when executed by a processor, cause the processor to perform the steps in the image construction methods according to various embodiments of this disclosure as described in the foregoing portion of this specification.
[0075] The computer-readable storage medium may be any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof.
[0076] The basic principles of this disclosure have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in this disclosure are merely examples and not limitations, and should not be considered as essential features of each embodiment of this disclosure. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the scope of this disclosure to the necessity of employing the aforementioned specific details for implementation.
[0077] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For system embodiments, since they largely correspond to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0078] The block diagrams of devices, apparatuses, devices, and systems disclosed herein are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, devices, and systems can be connected, arranged, and configured in any manner. Words such as “comprising,” “including,” “having,” etc., are open-ended terms meaning “including but not limited to,” and are used interchangeably with them. The terms “or” and “and” as used herein refer to the terms “and / or,” and are used interchangeably with them unless the context clearly indicates otherwise. The term “such as” as used herein refers to the phrase “such as but not limited to,” and is used interchangeably with it.
[0079] The methods and apparatus of this disclosure may be implemented in many ways. For example, they may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above-described order of steps for the methods is for illustrative purposes only, and the steps of the methods of this disclosure are not limited to the order specifically described above unless otherwise specifically stated. Furthermore, in some embodiments, this disclosure may also be implemented as a program recorded on a recording medium, the program including machine-readable instructions for implementing the methods according to this disclosure. Thus, this disclosure also covers recording media storing programs for performing the methods according to this disclosure.
[0080] It should also be noted that in the apparatus, devices, and methods of this disclosure, the components or steps can be disassembled and / or recombined. These disassemblies and / or recombinations should be considered as equivalent solutions to this disclosure.
[0081] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use this disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of this disclosure. Therefore, this disclosure is not intended to be limited to the aspects shown herein, but rather to be carried out within the widest scope consistent with the principles and novel features disclosed herein.
[0082] The above description has been given for purposes of illustration and description. Furthermore, this description is not intended to limit the embodiments of this disclosure to the forms disclosed herein. Although numerous exemplary aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations therein.
Claims
1. A method for constructing an image, characterized in that, The method is applied to a compilation server, the compilation server including a preset cache layer, and the method includes: In response to a received project image request, create the target build container node for the project; A target sharing network is established between the target compilation container node and the preset cache layer. The target sharing network is used to share compilation image files between the target compilation container node and the preset cache layer, so that the target compilation container node stores the compilation image files in the preset cache layer. The compilation image files are obtained by the target compilation container node from the preset server during the image compilation process. The preset cache layer is mounted to the preset image container node so that when the preset image container node executes the image build command, it can obtain the compiled image file from the preset cache layer and build the target image based on the compiled image file.
2. The method according to claim 1, characterized in that, The step of creating the target build container node for the project in response to the received project image request includes: In response to the received project image request, a container resource management component is created by invoking a preset container creation plugin; Container parameters are configured by configuring the component template of the container resource management component. The container parameters include container volume definition and type, container specifications, and container volume mount point. The container is run based on the container parameters, and the running container is determined as the target compilation container node of the project.
3. The method according to claim 2, characterized in that, The establishment of a target shared network between the target compilation container node and the preset cache layer, wherein the target shared network is used for sharing compilation image files between the target compilation container node and the preset cache layer, includes: Create the target cache directory in the preset cache layer; Mount the container volume of the target compiled container node to the target cache directory; A target mount point is created for the target cache directory of the container volume on which the target compilation container node is mounted, so that the target compilation container node can access the target cache directory through the target mount point and persistently store the compilation image file in the target cache directory of the preset cache layer.
4. The method according to claim 3, characterized in that, Mounting the container volume of the target compiled container node to the target cache directory includes: The target container volume of the target compilation container node is determined based on the container parameters of the target compilation container node. The target container volume is the container volume of the target compilation container node to be mounted to the target cache directory. Mount the target container volume to the target cache directory of the preset cache layer.
5. The method according to claim 4, characterized in that, The step of determining the target container volume of the target compilation container node based on the container parameters of the target compilation container node, wherein the target container volume of the target compilation container node is the container volume of the target compilation container node to be mounted to the target cache directory, includes: Obtain the container volume definition and its type from the container parameters of the target compiled container node; The container volume definition and the container volume corresponding to its type are determined as the target container volume, which is the container volume of the target compiled container node to be mounted to the target cache directory.
6. The method according to claim 5, characterized in that, The step of mounting the preset cache layer to the preset image container node, so that the preset image container node can obtain the compiled image file from the preset cache layer when executing the image build command, and build the target image based on the compiled image file, includes: Mount the target cache directory of the preset cache layer to the preset image container node; When the preset image container node executes the image build command, it obtains the compiled image file from the target cache directory of the preset cache layer through the preset image container node, and builds the target image of the project based on the compiled image file.
7. A mirror construction apparatus, characterized in that, The apparatus is applied to a compilation server, the compilation server including a preset cache layer, and the apparatus includes: The container creation module is used to create the target build container node for the project in response to a received project image request; The file sharing module is used to establish a target sharing network between the target compilation container node and the preset cache layer. The target sharing network is used for sharing compilation image files between the target compilation container node and the preset cache layer, so that the target compilation container node stores the compilation image files in the preset cache layer. The compilation image files are obtained by the target compilation container node from the preset server during the image compilation process. The image building module is used to mount the preset cache layer to the preset image container node, so that when the preset image container node executes the image building command, it can obtain the compiled image file from the preset cache layer and build the target image based on the compiled image file.
8. An electronic device, characterized in that, include: Memory, used to store computer program products; A processor is configured to execute a computer program product stored in the memory, wherein, when the computer program product is executed, it implements the method described in any one of claims 1-6.
9. A computer-readable storage medium having computer program instructions stored thereon, characterized in that, When the computer program instructions are executed by the processor, they implement the method described in any one of claims 1-6.
10. A computer program product comprising computer program instructions, characterized in that, When the computer program instructions are executed by the processor, they implement the method described in any one of claims 1-6.