Code compiling method and device, host, code compiling system and storage medium
By obtaining the Docker image from a public server and automatically compiling the code in the host environment, the problem of complex instruction operations in the Docker container is solved, and a simplified code compilation process and improved user experience are achieved.
Patent Information
- Application Number
- CN202510711356.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-29
- Publication Date
- 2025-09-12
AI Technical Summary
In the prior art, the code compilation process of embedded software requires entering complex instructions in the Docker container, which leads to high operational complexity and affects the user experience.
By obtaining the target Docker image from a public server, running the image to obtain a container, and receiving compilation instructions in the host environment, the environment parameters and code are obtained by using the mounted directory to achieve automatic compilation of the Docker container.
It reduces the complexity of user operations during code compilation, improves user experience, and increases the flexibility and applicability of the compilation process.
Smart Images

Figure CN120631369A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of computers, and in particular to a code compilation method, device, host, code compilation system, and storage medium. Background Art
[0002] Software development, especially embedded software, requires building a complex compilation environment, including installing various system toolkits, cross-compilation tool chains, Python packages, Nodejs components (Node.js as part of the backend server), etc.
[0003] Currently, code compilation is typically done within a Docker container by setting up a compilation environment and installing tools. However, this approach requires engineers to enter complex instructions within the Docker container before compilation can begin, making the compilation process more complex. Summary of the Invention
[0004] The present application provides a code compilation method, device, host, code compilation system and storage medium to reduce the complexity of the compilation process.
[0005] In the first aspect, the present application provides a code compilation method, including: obtaining a target docker image corresponding to a code to be compiled from a public server; wherein the public server includes multiple docker images; running the target docker image to obtain a target docker container; loading a specified directory into the target docker container, so that the target docker container obtains the pre-set environmental parameters and the code to be compiled in the host environment; after receiving a compilation instruction in the host environment, passing the compilation instruction to the target docker container, so that the target docker container compiles the code to be compiled based on the compilation parameters corresponding to the compilation instruction; after the target docker container completes compiling the code, receiving the compilation result returned by the target docker container.
[0006] In an embodiment of the present application, the target docker image corresponding to the code to be compiled can be directly obtained from the server, and then the docker image is run to obtain a docker container. The environment parameters can be obtained through the mounted specified directory, so that the deployment of the compilation environment can be completed. The mounted specified directory enables the docker container to obtain the code to be compiled from the specified directory after receiving the compilation instruction, and then complete the compilation of the code to be compiled, obtain and forward the compilation result. Since the deployment process of the docker container and the compilation process of the code do not require user participation, the user does not need to pay attention to the specific use of docker to complete the compilation of the code, thereby reducing the complexity of user operations during the code compilation process and improving the user experience.
[0007] In combination with the technical solution provided in the first aspect above, in some possible implementations, after the host environment receives the compilation instruction, the method also includes: determining whether the code to be compiled corresponding to the compilation instruction is compiled through the Docker container; if so, passing the compilation instruction to the target Docker container so that the target Docker container compiles the code corresponding to the compilation instruction; if not, compiling the code in the host environment.
[0008] In the embodiment of the present application, after the host environment receives the compilation instruction, it is necessary to further determine whether the code to be compiled needs to be compiled through the Docker container. This allows different codes to be compiled in different ways, improving the flexibility of this solution.
[0009] In combination with the technical solution provided in the first aspect above, in some possible implementations, after receiving a compilation instruction in a host environment, passing the compilation instruction to a target Docker container includes: after receiving the compilation instruction in the host environment, recording and storing the compilation instruction; wherein the compilation instruction includes compilation parameters; and after the target Docker container is started, passing the stored compilation instruction to the target Docker container.
[0010] In the embodiment of the present application, the compilation parameters are configured in the compilation instruction, so that after the Docker container receives the compilation instruction, the compilation parameters can be obtained, and the code to be compiled can be compiled according to the compilation parameters.
[0011] In combination with the technical solution provided in the first aspect above, in some possible implementations, compilation parameters corresponding to the code to be compiled are also pre-set in the designated directory. After the compilation instruction is passed to the target Docker container, the Docker container obtains the compilation parameters corresponding to the compilation instruction from the designated directory.
[0012] In the embodiment of the present application, by configuring the compilation parameters in a specified directory, the compilation parameters can be reused by different codes to be compiled, thereby reducing the configuration complexity of the compilation parameters.
[0013] In combination with the technical solution provided in the first aspect above, in some possible implementations, the method further includes: compiling a Docker image that may be used, and deploying the compiled Docker image to the public server.
[0014] In an embodiment of the present application, the docker image obtained by compiling the possible docker image is deployed to a public server, so that the docker image on the public server can be updated, thereby meeting the compilation requirements of more codes and improving the scope of application of this solution.
[0015] In combination with the technical solution provided in the first aspect above, in some possible implementations, obtaining a target Docker image corresponding to the code to be compiled from a public server includes: obtaining configuration information of the code to be compiled, the configuration information including the name of the target Docker image; and based on the name of the target Docker image, downloading a test target Docker image from the public server.
[0016] In an embodiment of the present application, the corresponding target Docker image can be accurately downloaded from a public server through the name of the target Docker image included in the configuration information of the code to be compiled.
[0017] In the second aspect, the present application provides a code compilation device, including: an acquisition module and a processing module, the acquisition module is used to obtain a target docker image corresponding to the code to be compiled from a public server; wherein the public server includes multiple docker images; the processing module is used to run the target docker image to obtain a target docker container; the processing module is also used to load a specified directory into the target docker container, so that the target docker container obtains the pre-set environmental parameters and the code to be compiled in the host environment; the processing module is also used to pass the compilation instruction to the target docker container after receiving the compilation instruction in the host environment, so that the target docker container compiles the code corresponding to the compilation instruction; the processing module is also used to receive the compilation result returned by the target docker container after the target docker container completes compiling the code.
[0018] In a third aspect, the present application provides a host comprising: a memory and a processor, wherein the memory and the processor are connected; the memory is used to store programs; and the processor is used to call the programs stored in the memory to execute the method described in the first aspect above and / or in combination with any possible implementation of the first aspect above.
[0019] In a fourth aspect, the present application provides a code compilation system, comprising: a public server and at least one host as described in the third aspect above, each of the hosts being communicatively connected to the public server.
[0020] In a fifth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a computer, it executes the method described in the first aspect and / or in combination with any possible implementation of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.
[0022] Figure 1 A flowchart of a code compilation method shown in an embodiment of the present application;
[0023] Figure 2 This is a structural block diagram of a code compilation device shown in an embodiment of the present application;
[0024] Figure 3 This is a structural block diagram of a code compilation system shown in an embodiment of the present application;
[0025] Figure 4 A schematic diagram of a code compilation system flow diagram shown in an embodiment of the present application;
[0026] Figure 5 This is a structural block diagram of a host shown in an embodiment of the present application. DETAILED DESCRIPTION
[0027] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0028] It should be noted that similar numbers and letters represent similar items in the following figures, so once an item is defined in one figure, it does not need to be further defined and explained in the subsequent figures. At the same time, in the description of this application, relational terms such as "first", "second", etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or equipment including a series of elements includes not only those elements, but also includes other elements not clearly listed, or also includes elements inherent to such process, method, article or equipment. In the absence of further restrictions, the elements defined by the sentence "comprise a..." do not exclude the presence of other identical elements in the process, method, article or equipment including the elements.
[0029] The technical solution of this application will be described in detail below with reference to the accompanying drawings.
[0030] Currently, during software development, engineers typically need to first compile a Docker image on a device, then create a Docker container based on that image. They then enter complex instructions to set up the compilation environment, and then perform compilation operations within the Docker container.
[0031] However, this method requires engineers to perform a large number of complex operations, and as long as one of the steps is wrong, the subsequent compilation will not be completed. Based on this, the present application provides a code compilation method that can reduce the complexity of the operations of engineers during the compilation process.
[0032] See also Figure 1 , Figure 1 This is a flow chart of a code compilation method shown in the embodiment of the present application. Figure 1 Describe the steps it involves.
[0033] S100: Obtain a target Docker image corresponding to the code to be compiled from a public server.
[0034] Among them, the public server includes a variety of docker images.
[0035] In one embodiment, a code identifier corresponding to each Docker image may be pre-configured on a public server. The code identifier may be, for example, a code name, code number, or other identifier that characterizes the code. When a target Docker image corresponding to the code to be compiled is needed from the public server, the identifier of the code to be compiled may be sent to the public server, and the public server will then send the Docker image based on the identifier.
[0036] Alternatively, a method of obtaining a target Docker image corresponding to the code to be compiled from a public server may include first obtaining configuration information of the code to be compiled, the configuration information including the name of the target Docker image, and then downloading the target Docker image from the public server based on the name of the target Docker image.
[0037] For example, if the code to be compiled is product foo. / build.sh foo, and the configuration information of foo. / build.sh foo contains docker_image = ubuntu_2004_default, then the name of the Docker image required for compiling foo. / build.sh foo is ubuntu_2004_default. Therefore, the Docker image named ubuntu_2004_default is downloaded from the public server. This example is for ease of understanding only and should not be construed as a limitation of this application.
[0038] In one implementation, if the target Docker image corresponding to the code to be compiled fails to be obtained from a public server, a preset Dockerfile (a text file used to automatically build a Docker image) can be loaded to compile the target Docker image locally.
[0039] The specific method of locally compiling a Docker image using Dockerfile is well known to those skilled in the art and will not be described here for brevity.
[0040] In one implementation, the docker image that may be used may also be compiled, and the compiled docker image may be deployed on a public server.
[0041] By compiling the docker images that may be used, the docker images obtained are deployed to the public server, so that the docker images on the public server can be updated, thereby meeting the compilation requirements of more codes and improving the scope of application of this solution.
[0042] For example, you can use Jenkins (an open source software project, a continuous integration tool developed based on Java) to regularly compile the Docker images required by each project and then store them on a public server. In this way, when compiling, you only need to automatically download the latest Docker image, eliminating the need to spend a lot of time compiling the Docker image.
[0043] S200: Run the target Docker image to obtain the target Docker container.
[0044] After obtaining the target Docker image, you can run the Docker image to obtain the target Docker container. The method of running the Docker image to obtain the Docker container is well known to those skilled in the art and will not be repeated here for the sake of simplicity.
[0045] S300: Load the specified directory into the target Docker container, so that the target Docker container obtains the environment parameters and the code to be compiled that are pre-set in the host environment.
[0046] The specified directory can include the home directory $HOME and the code directory ${base_home}. The home directory contains information such as the system and ccache, and the code directory contains multiple codes to be compiled.
[0047] Optionally, you can use a preset command to load the specified directory into the target Docker container, for example
[0048]
[0049] Among them, docer_image_to_run is the target Docker container.
[0050] After loading the specified directory into the target Docker container, the target Docker container can obtain environment parameters and the code to be compiled by accessing the specified directory. It can also obtain compilation cache information.
[0051] In one embodiment, the environment parameters can be pre-configured and stored in a .evn file. After the Docker container is started, the .evn file storing the environment parameters can be retrieved to obtain the environment parameters. The .evn file can be stored in a specified directory.
[0052] The specific implementation code for importing environment parameters into the docker container can be
[0053]
[0054] Based on this, the purpose of importing the environment parameters in the .evn file in the host environment into the Docker container can be achieved.
[0055] S400: After receiving the compilation instruction in the host environment, the compilation instruction is passed to the target Docker container, so that the target Docker container compiles the code to be compiled based on the compilation parameters corresponding to the compilation instruction.
[0056] The compilation instruction may be generated in real time after the user triggers a compilation option, or may be a compilation instruction received from another device.
[0057] In one embodiment, after receiving a compilation instruction in a host environment, the compilation instruction is passed to a target Docker container in a specific manner: after receiving the compilation instruction in the host environment, the compilation instruction is recorded and stored; wherein the compilation instruction includes compilation parameters; after the target Docker container is started, the stored compilation instruction is passed to the target Docker container.
[0058] Optionally, the specified directory may also contain pre-set compilation parameters for the code to be compiled. After the compilation instructions are passed to the target Docker container, the Docker container retrieves the compilation parameters corresponding to the compilation instructions from the specified directory. The compilation instructions are then executed based on the compilation parameters to complete the compilation of the code to be compiled. By configuring the compilation parameters in the specified directory, the compilation parameters can be reused by different code to be compiled, thereby reducing the complexity of compiling parameter configuration.
[0059] For example, the code above that transfers compilation instructions to the Docker container content can be:
[0060] Based on this, the compilation instructions can be transferred to the command variable and run by bash in the docker container to compile the code to be compiled.
[0061] In one implementation, before obtaining the target Docker image corresponding to the code to be compiled from the public server, it is first determined whether the code to be compiled needs to be compiled using a Docker container.
[0062] If you need to compile through a Docker container, obtain the target Docker image corresponding to the code to be compiled from a public server.
[0063] If you do not need to compile the code in a Docker container, you can compile the code in the host environment. For example, you can compile the code using a compilation tool such as a cross-compiler or CMake (a cross-platform compilation tool) that has been pre-installed on the host.
[0064] In one implementation, after the host environment receives the compilation instruction, it can also first determine whether the to-be-compiled code corresponding to the compilation instruction is compiled through the Docker container.
[0065] If the compilation is performed through a Docker container, the compilation instruction is passed to the target Docker container so that the target Docker container compiles the code corresponding to the compilation instruction.
[0066] If you are not compiling in a Docker container, compile the code in the host environment. For example, you can use a cross-compiler, CMake, or other compilation tools that have been pre-installed on the host to compile the code.
[0067] After receiving the compilation instruction, the host environment needs to further determine whether the code to be compiled needs to be compiled through the Docker container. This allows different codes to be compiled in different ways, increasing the flexibility of this solution.
[0068] Optionally, compilation mode information indicating whether the code to be compiled needs to be compiled using a docker container may be pre-configured in the configuration information of the code to be compiled. Accordingly, the method for determining whether the code to be compiled corresponding to the compilation instruction is compiled through a docker container may be: determining whether the compilation mode information in the configuration information of the code to be compiled indicates that the code is to be compiled using a docker container.
[0069] For example, you could write export docker_image="" in platform / foo / config. The presence of this statement indicates that compilation is not performed using a Docker container. If the statement export docker_image="" is detected in the configuration information of the code to be compiled, compilation is performed in the host environment.
[0070] When it is detected that the statement export docker_image="" does not exist in the configuration information of the code to be compiled, the compilation instruction is passed to the target Docker container, so that the target Docker container compiles the code corresponding to the compilation instruction.
[0071] Alternatively, you can specify export docker_image="*" in platform / foo / config, where * is 0 or 1. If export docker_image="1" is specified, the Docker container is used for compilation. If export docker_image="0" is specified, the Docker container is not used for compilation.
[0072] The examples here are only for ease of understanding and should not be construed as limiting this application.
[0073] In one embodiment, a compilation mode can be pre-configured for each code to be compiled. When the compilation mode corresponding to the code to be compiled is to compile using a Docker container, upon receiving a compilation instruction indicating that the code to be compiled is to be compiled, the compilation instruction is passed to the target Docker container, so that the target Docker container compiles the code corresponding to the compilation instruction.
[0074] In a case where the compilation mode corresponding to the code to be compiled is indicative of compiling using a host, upon receiving a compilation instruction indicative of compiling the code to be compiled, compilation is performed in a host environment.
[0075] For example, you can add a statement indicating the compilation mode to the configuration information of the code to be compiled, such as exportkernel_docker_image="*", where * is 0 or 1. When exportkernel_docker_image="1", it indicates that the Docker container is used for compilation. When exportkernel_docker_image="0", it indicates that the Docker container is not used for compilation.
[0076] Optionally, you can also add the name of the target Docker image to the statement that represents the compilation method.
[0077] For example, export kernel_docker_image = ubuntu_2004_default, export uboot_docker_image = ubuntu_2204_default, export buildroot_docker_image = "", etc. Among them, export kernel_docker_image = ubuntu_2004_default and export uboot_docker_image = ubuntu_2204_default both indicate that the docker container named ubuntu_2004_default needs to be used for compilation, while export buildroot_docker_image = "" indicates that the docker container does not need to be used for compilation, but the host computer is used for compilation. The examples here are only for ease of understanding and should not be regarded as limitations of this application.
[0078] S500: After the target Docker container completes compiling the code, receiving the compilation result returned by the target Docker container.
[0079] Optionally, after the compilation is complete, the Docker container can exit and the host environment obtains the compilation results.
[0080] Alternatively, after the compilation is completed, the Docker container does not exit, and the host environment directly obtains the compilation results from the Docker container.
[0081] Optionally, you can use the return value of the docker command to obtain the compilation result in the docker container.
[0082] For example, it could be
[0083]
[0084] Based on this, you can get the compilation results from the docker container. The examples here are only for ease of understanding and should not be used as a limitation of this application.
[0085] To facilitate understanding of the above compilation method, an example is given below to illustrate.
[0086] First, obtain the configuration information for the code to be compiled, which includes the name of the target Docker image. Then, based on the target Docker image name, download the target Docker image from a public server. If the target Docker image for the code to be compiled from the public server fails, load the pre-set Dockerfile and compile the target Docker image locally.
[0087] After obtaining the target Docker image, run the Docker image to obtain the target Docker container. Then load the specified directory into the target Docker container so that the target Docker container can obtain the pre-set environment parameters and the code to be compiled in the host environment.
[0088] After receiving the compilation instructions in the host environment, the compilation instructions are recorded and stored. After the target Docker container is started, the stored compilation instructions and the corresponding compilation parameters are passed to the target Docker container. The compilation parameters are pre-configured in a specified directory. The target Docker container executes the compilation instructions based on the compilation parameters to complete the compilation of the code to be compiled. After the target Docker container completes the compilation of the code, the compilation result is returned by the target Docker container.
[0089] In addition, you can also compile a Docker image that can be used and deploy the compiled Docker image to a public server to update the public server.
[0090] The example here is only one implementation of the code compilation method provided by this application and should not be regarded as a limitation of this application.
[0091] Based on the same technical concept, this application also provides a code compilation device, such as Figure 2 As shown, the code compiling device 100 includes an acquisition module 110 and a processing module 120 .
[0092] The acquisition module 110 is used to obtain a target Docker image corresponding to the code to be compiled from a public server; wherein the public server includes multiple Docker images.
[0093] The processing module 120 is used to run the target Docker image to obtain a target Docker container.
[0094] The processing module 120 is further configured to load the specified directory into the target Docker container, so that the target Docker container obtains the pre-set environment parameters and the code to be compiled in the host environment.
[0095] The processing module 120 is further configured to, after receiving the compilation instruction in the host environment, pass the compilation instruction to the target Docker container, so that the target Docker container compiles the code corresponding to the compilation instruction.
[0096] The processing module 120 is further configured to receive a compilation result returned by the target Docker container after the target Docker container completes compiling the code.
[0097] After the host environment receives the compilation instruction, the processing module 120 is also used to determine whether the to-be-compiled code corresponding to the compilation instruction is compiled through the Docker container; if so, the compilation instruction is passed to the target Docker container so that the target Docker container compiles the code corresponding to the compilation instruction; if not, the code is compiled in the host environment.
[0098] The processing module 120 is specifically configured to record and store the compilation instruction after receiving the compilation instruction in the host environment; wherein the compilation instruction includes compilation parameters; and after the target Docker container is started, pass the stored compilation instruction to the target Docker container.
[0099] In one embodiment, the specified directory also pre-sets compilation parameters corresponding to the code to be compiled. After the compilation instruction is passed to the target Docker container, the Docker container obtains the compilation parameters corresponding to the compilation instruction from the specified directory.
[0100] The processing module 120 is further configured to compile a Docker image that may be used and deploy the compiled Docker image to the public server.
[0101] The acquisition module 110 is specifically used to obtain configuration information of the code to be compiled, wherein the configuration information includes the name of the target Docker image; based on the name of the target Docker image, download the target Docker image from the public server.
[0102] The code compilation device 100 provided in the embodiment of the present application has the same implementation principle and technical effects as those of the aforementioned code compilation method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding content in the aforementioned code compilation method embodiment.
[0103] Based on the same technical concept, this application also provides a code compilation system such as Figure 3 As shown, the code compilation system 10 includes at least one host 200 and a public server 300 .
[0104] A plurality of docker images are provided on the public server 300. Each host 200 is connected to the public server 300 for communication.
[0105] The public server 300 may be any existing type of server, and the specific type of the public server 300 is not limited here.
[0106] The host 200 may be an electronic device such as a computer that can implement the aforementioned code compilation method.
[0107] The communication logic between the host 200 and the public server 300 is as follows Figure 4 shown.
[0108] Host 200 first obtains the target Docker image corresponding to the code to be compiled from a public server. It then runs the target Docker image to obtain a target Docker container. It then loads a specified directory into the target Docker container, allowing the target Docker container to obtain the pre-set environment parameters and code to be compiled in the host environment. After receiving the compilation instructions in the host environment, the compilation instructions are passed to the target Docker container, causing it to compile the code to be compiled based on the compilation parameters corresponding to the compilation instructions. Finally, after the target Docker container completes compiling the code, it receives the compilation results returned by the target Docker container.
[0109] The specific implementation methods of the above steps have been clearly described in the previous text and will not be repeated here for the sake of brevity.
[0110] Optionally, a docker image that may be used may be compiled in the host 200 , and the compiled docker image may be deployed to the public server 300 .
[0111] See also Figure 5 , which is a host 200 provided in an embodiment of the present application. The host 200 includes: a processor 210 and a memory 220.
[0112] The memory 220 and the processor 210 are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines. The memory 220 is used to store computer programs, such as Figure 2The software function module shown in is the code compilation device 100. The code compilation device 100 includes at least one software function module that can be stored in the memory 220 in the form of software or firmware or fixed in the operating system (OS) of the host 200. The processor 210 is used to execute the executable module stored in the memory 220, such as the software function module or computer program included in the code compilation device 100. At this time, the processor 210 is used to obtain the target Docker image corresponding to the code to be compiled from a public server; wherein the public server includes multiple Docker images; run the target Docker image to obtain a target Docker container; load the specified directory into the target Docker container so that the target Docker container obtains the environment parameters and the code to be compiled pre-set in the host environment; after receiving the compilation instruction in the host environment, pass the compilation instruction to the target Docker container so that the target Docker container compiles the code to be compiled based on the compilation parameters corresponding to the compilation instruction; after the target Docker container completes compiling the code, receive the compilation result returned by the target Docker container.
[0113] Among them, the memory 220 can be, but is not limited to, RAM (Random Access Memory), ROM (Read Only Memory), PROM (Programmable Read-Only Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electric Erasable Programmable Read-Only Memory), etc.
[0114] The processor 210 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a CPU (Central Processing Unit), an NP (Network Processor), etc.; it may also be a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor may be a microprocessor, or the processor 210 may also be any conventional processor, etc.
[0115] The host 200 mentioned above includes but is not limited to a personal computer, a server, etc.
[0116] The present application also provides a computer-readable storage medium (hereinafter referred to as storage medium) having a computer program stored thereon. When the computer program is executed by a computer, such as the host 200 described above, the computer-readable storage medium executes the code compilation method described above. The computer-readable storage medium includes various media capable of storing program code, such as a USB flash drive, a mobile hard drive, a read-only memory, a random access memory, a magnetic disk, or an optical disk.
[0117] The above description is merely a preferred embodiment of the present application and is not intended to limit the present application. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present application shall be included within the scope of protection of the present application.
Claims
1. A code compilation method, characterized in that: include: Obtain a target Docker image corresponding to the code to be compiled from a public server; wherein the public server includes multiple Docker images; Run the target Docker image to obtain the target Docker container; Load the specified directory into the target Docker container, so that the target Docker container obtains the pre-set environment parameters and the code to be compiled in the host environment; After receiving the compilation instruction in the host environment, the compilation instruction is passed to the target Docker container, so that the target Docker container compiles the code to be compiled based on the compilation parameters corresponding to the compilation instruction; After the target Docker container completes compiling the code, the compilation result returned by the target Docker container is received.
2. The method according to claim 1, characterized in that After the host environment receives the compilation instruction, the method further includes: Determine whether the code to be compiled corresponding to the compilation instruction is compiled through the Docker container; If yes, pass the compilation instruction to the target Docker container, so that the target Docker container compiles the code corresponding to the compilation instruction; If not, the code is compiled in the host environment.
3. The method according to claim 1, characterized in that After receiving the compilation instructions in the host environment, the compilation instructions are passed to the target Docker container, including: After receiving the compilation instruction in the host environment, recording and storing the compilation instruction; wherein the compilation instruction includes compilation parameters; After the target Docker container is started, the stored compilation instruction is passed to the target Docker container.
4. The method according to claim 1, wherein The specified directory also pre-sets compilation parameters corresponding to the code to be compiled. After the compilation instruction is passed to the target Docker container, the Docker container obtains the compilation parameters corresponding to the compilation instruction from the specified directory.
5. The method according to claim 1, characterized in that The method further comprises: Compile the Docker image that may be used, and deploy the compiled Docker image to the public server.
6. The method according to claim 1, characterized in that Get the target Docker image corresponding to the code to be compiled from the public server, including: Obtain configuration information of the code to be compiled, wherein the configuration information includes the name of the target Docker image; Based on the name of the target Docker image, download the target Docker image from the public server.
7. A code compiling device, characterized in that: include: An acquisition module is used to obtain a target Docker image corresponding to the code to be compiled from a public server; wherein the public server includes multiple Docker images; A processing module is used to run the target Docker image to obtain a target Docker container; The processing module is further configured to load the specified directory into the target Docker container, so that the target Docker container obtains the pre-set environment parameters and the code to be compiled in the host environment; The processing module is further configured to, after receiving a compilation instruction in the host environment, pass the compilation instruction to the target Docker container, so that the target Docker container compiles the code corresponding to the compilation instruction; The processing module is further configured to receive a compilation result returned by the target Docker container after the target Docker container completes compiling the code.
8. A host, characterized in that: include: a memory and a processor, the memory and the processor being connected; The memory is used to store programs; The processor is configured to call a program stored in the memory to execute the method according to any one of claims 1 to 6.
9. A code compilation system, characterized in that: include: A public server and at least one host according to claim 8, each of the hosts being communicatively connected to the public server.
10. A computer-readable storage medium, characterized in that A computer program is stored thereon, and when the computer program is run by a computer, the method according to any one of claims 1 to 6 is executed.