Environment deployment method and device, electronic equipment and storage medium
By using an automated environment deployment method and leveraging task queues and bridge technology, multiple environments can be deployed efficiently and flexibly on the same device, solving the problem of low efficiency in manual deployment.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- MICRO DREAM TECHTRONIC NETWORK TECH CHINACO
- Filing Date
- 2026-02-25
- Publication Date
- 2026-06-05
AI Technical Summary
In existing technologies, equipment environment deployment requires manual operation by professional technicians, which is inefficient and prone to errors, and cannot meet the needs of rapid deployment of multiple environments.
By automatically acquiring target deployment information based on the task queue of the environment to be deployed, generating target access containers and business containers, and using a bridge to connect the containers, it supports the automatic deployment of multiple environments on the same device.
It improves environment deployment efficiency, reduces waste of human resources, lowers the risk of deployment errors, supports flexible deployment of multiple environments on the same device, and reduces the number of devices required.
Smart Images

Figure CN122160281A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of environmental deployment technology, and in particular to an environmental deployment method, apparatus, electronic device and storage medium. Background Technology
[0002] In related technologies, when deploying the environment within a device, it often requires manual deployment by professional technicians, and deploying an environment can take several hours, resulting in poor environment deployment efficiency. Summary of the Invention
[0003] This application provides an environment deployment method, apparatus, electronic device, and storage medium that can automatically deploy the environment to be deployed, thereby improving the efficiency of environment deployment.
[0004] The technical solution of this application embodiment is implemented as follows:
[0005] This application provides an environment deployment method, including:
[0006] Based on the task queue of the environment to be deployed, the target information to be deployed is obtained; wherein, the task queue of the environment to be deployed includes at least one information to be deployed corresponding to the environment to be deployed, the information to be deployed is used to indicate at least one preset project, and the target information to be deployed is any information to be deployed in the task queue of the environment to be deployed.
[0007] Based on the target deployment information, obtain the configuration information corresponding to the target deployment environment; wherein, the target deployment environment is the environment corresponding to the target deployment information;
[0008] Based on the configuration information, a target access container and a target business container corresponding to each preset project indicated by the target deployment information are generated.
[0009] Based on the bridge corresponding to the target deployment environment, the target access container, and the target service container corresponding to each preset project, a connected container is generated to complete the deployment of the environment.
[0010] This application provides an environmental deployment device, including:
[0011] The first acquisition module is used to acquire target deployment information based on the deployment environment task queue; wherein, the deployment environment task queue includes deployment information corresponding to at least one deployment environment, the deployment information is used to indicate at least one preset project, and the target deployment information is any deployment information in the deployment environment task queue;
[0012] The second acquisition module is used to acquire configuration information corresponding to the target deployment environment based on the target deployment information; wherein, the target deployment environment is the environment corresponding to the target deployment information;
[0013] The first generation module is used to generate a target access container and a target business container corresponding to each preset project indicated by the target deployment information, based on the configuration information.
[0014] The second generation module is used to generate connected containers based on the bridge corresponding to the target deployment environment, the target access container, and the target service container corresponding to each preset project, so as to complete the deployment of the environment.
[0015] In some embodiments, the first generation module is configured to:
[0016] A specified directory is generated based on the configuration information; wherein, the specified directory includes an Nginx configuration directory and a project code directory corresponding to at least one preset project;
[0017] For each preset project, based on the configuration information, the target business container corresponding to the preset project is obtained, and the project code directory corresponding to the preset project is mounted to the target business container; the target business container is used to provide corresponding functions when the corresponding environment is accessed;
[0018] For each of the preset projects, a vhost configuration file is generated based on the Nginx configuration template corresponding to the preset project and the configuration information;
[0019] Add the vhost configuration file to the Nginx configuration directory and mount the Nginx configuration directory;
[0020] The target access container is created based on the Nginx configuration directory and the access port identifier of the available ports; the target access container is used to provide access to the corresponding environment.
[0021] In some embodiments, the target service container includes a first target service container or a second target service container, and the configuration information includes technology stack information; the first generation module is configured to:
[0022] Based on the technology stack information corresponding to the preset project, determine whether the preset project is a first preset project implemented in a first type of language;
[0023] If the preset project is determined to be a first preset project, a first image is created based on the executable file corresponding to the first preset project; wherein, the executable file is a file obtained by compiling the project code corresponding to the first preset project;
[0024] Based on the first image, create the first target business container;
[0025] If it is determined that the preset project is a second preset project implemented in a second type of language, obtain the second image corresponding to the second preset project;
[0026] Based on the second image, create the second target business container.
[0027] In some embodiments, the target deployment information includes an environment identifier; the second generation module is configured to:
[0028] Create the bridge described above;
[0029] Iterate through the target access container and target business container corresponding to the target deployment environment;
[0030] The target access container and the target service container are both connected to the bridge to obtain connected containers.
[0031] In some embodiments, the configuration information includes a domain name identifier corresponding to each preset item; the apparatus further includes: a third generation module, configured to:
[0032] Based on the domain name identifier corresponding to each target service container in the connected container and the Internet identifier corresponding to the target access container, a correspondence between the Internet identifier and each domain name identifier is constructed; the domain name identifier of the target service container is consistent with the domain name identifier of the corresponding preset project;
[0033] Based on the aforementioned correspondence, a host file is generated.
[0034] In some embodiments, the apparatus further includes: a deletion module, configured to:
[0035] Based on the obtained environment deletion request, delete the running information of the first deployed environment corresponding to the environment deletion request; wherein, the running information includes the connected container;
[0036] The runtime of the second deployed environment is recorded; if the runtime is greater than or equal to a preset duration, the runtime information corresponding to the second deployed environment is deleted.
[0037] In some embodiments, the apparatus further includes: an execution module, configured to:
[0038] Obtain a target request; wherein the target request includes a target identifier, and the target request is used to indicate at least one of the following: querying information in a deployed environment, deleting a deployed environment, or configuring an environment to be deployed;
[0039] Based on the target identifier, determine whether there is a deployed environment corresponding to the target identifier;
[0040] If it is determined that a deployment environment corresponding to the target identifier exists, the target request is executed in the deployment environment corresponding to the target identifier;
[0041] If it is determined that there is no deployed environment corresponding to the target identifier, the target request is executed, or a prompt message for the target request is generated.
[0042] This application provides an electronic device, including:
[0043] processor;
[0044] Memory used to store computer programs or instructions;
[0045] The processor executes the computer program or instructions to implement the method provided in the embodiments of this application.
[0046] This application provides a computer-readable storage medium storing a computer program or instructions thereon, which, when executed by a processor, implements the method provided in this application.
[0047] This application provides a computer program product, including a computer program or instructions, which, when executed by a processor, implement the method provided in this application.
[0048] The technical solutions provided by the embodiments of this application may include the following beneficial effects:
[0049] This disclosure provides an environment deployment method that can automatically determine whether a deployment environment exists based on a task queue of deployment environments. If a deployment environment exists, it is automatically deployed, thereby improving deployment efficiency and saving human resources. Automatic deployment also reduces deployment errors or omissions caused by manual deployment. Furthermore, the deployment task queue can include deployment information corresponding to at least one deployment environment, supporting the deployment of multiple deployment environments on the same device and multiple deployments of the same deployment environment within the overall environment, improving the flexibility and freedom of environment deployment. When multiple deployment environments need to be deployed, they can be deployed on the same device, reducing the number of devices required for environment deployment.
[0050] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0051] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0052] Figure 1 This is a schematic diagram of the structure of an electronic device according to an exemplary embodiment.
[0053] Figure 2 This is a flowchart illustrating an environment deployment method according to an exemplary embodiment.
[0054] Figure 3 This is a schematic diagram of a framework according to an exemplary embodiment.
[0055] Figure 4 This is a flowchart illustrating a configuration environment according to an exemplary embodiment. Detailed Implementation
[0056] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0057] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0058] In the embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0059] Unless otherwise defined, all technical and scientific terms used in the embodiments of this application have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in the embodiments of this application is for the purpose of describing the embodiments of this application only and is not intended to limit this application.
[0060] In e-commerce environments, technicians need to manually set up the environment on the device. E-commerce projects often have numerous modules with complex dependencies, and setting up a single environment can take up to four hours, with no guarantee that the environment will be operational. Furthermore, each environment often occupies an entire device (such as a virtual machine), wasting significant resources and failing to meet development needs.
[0061] For example, manually creating an environment on a physical machine requires installing and configuring PHP-FPM and its extensions, the Go build toolchain, deploying and configuring an Nginx reverse proxy, and adjusting system services and file permissions. The entire process involves the coordinated configuration of multiple components, is cumbersome, has complex dependencies, and relies entirely on manual operation. This makes it prone to service failures due to configuration errors, resulting in low deployment efficiency and difficulty in maintenance.
[0062] This application provides an environment deployment method, apparatus, electronic device, and storage medium, which can automatically deploy environments to be deployed and can deploy different environments to be deployed on the same device. This reduces the number of devices required for deploying multiple environments, improves deployment efficiency, and reduces waste of human resources. The following describes exemplary applications of the electronic device provided in this application. The electronic device can be implemented as various types of user terminals such as laptops, tablets, desktop computers, set-top boxes, and mobile devices (e.g., mobile phones, portable music players, personal digital assistants, dedicated messaging devices, portable gaming devices), or as a server.
[0063] See Figure 1 , Figure 1 This is a schematic diagram illustrating the structure of an electronic device 100 according to an exemplary embodiment. Figure 1 The terminal 100 shown includes at least one processor 110, a memory 150, at least one network interface 120, and a user interface 130. The various components in the terminal 100 are coupled together via a bus system 140. It is understood that the bus system 140 is used to implement communication between these components. In addition to a data bus, the bus system 140 also includes a power bus, a control bus, and a status signal bus. However, for clarity, ... Figure 1 The general labeled all buses as Bus System 140.
[0064] The processor 110 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc.
[0065] User interface 130 includes one or more output devices 131 that enable the presentation of media content, including one or more speakers and / or one or more visual displays. User interface 130 also includes one or more input devices 132, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
[0066] The memory 150 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state storage, hard disk drives, optical disk drives, etc. The memory 150 may optionally include one or more storage devices physically located away from the processor 110.
[0067] The memory 150 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), and the volatile memory may be random access memory (RAM). The memory 150 described in this application embodiment is intended to include any suitable type of memory.
[0068] In some embodiments, memory 150 is capable of storing data to support various operations, examples of which include programs, modules, and data structures or subsets or supersets thereof, as illustrated below.
[0069] Operating system 151 includes system programs for handling various basic system services and performing hardware-related tasks, such as the framework layer, core library layer, driver layer, etc., for implementing various basic business functions and handling hardware-based tasks;
[0070] The network communication module 152 is used to reach other computing devices via one or more (wired or wireless) network interfaces 120, exemplary network interfaces 120 including: Bluetooth, Wi-Fi, and Universal Serial Bus (USB), etc.
[0071] Presentation module 153 is configured to enable the presentation of information (e.g., a user interface for operating peripheral devices and displaying content and information) via one or more output devices 131 associated with user interface 130 (e.g., a display screen, a speaker, etc.).
[0072] The input processing module 154 is used to detect and translate one or more user inputs or interactions from one or more input devices 132.
[0073] In some embodiments, the apparatus provided in this application can be implemented in software. Figure 1 An environment deployment device 155 stored in memory 150 is shown. This device can be software in the form of programs and plug-ins, and includes the following software modules: a first acquisition module 1551, a second acquisition module 1552, a first generation module 1553, and a second generation module 1554. These modules are logically linked and can therefore be arbitrarily combined or further divided according to their implemented functions. The functions of each module will be described below.
[0074] In other embodiments, the apparatus provided in this application can be implemented in hardware. As an example, the apparatus provided in this application can be a processor in the form of a hardware decoding processor, which is programmed to execute the method provided in this application. For example, the processor in the form of a hardware decoding processor can be one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), or other electronic components.
[0075] The following description, in conjunction with exemplary applications and implementations of the terminals provided in the embodiments of this application, illustrates an environment deployment method provided in the embodiments of this application.
[0076] See Figure 2 , Figure 2 This is a flowchart illustrating an environment deployment method according to an exemplary embodiment, which combines... Figure 2 The steps shown are explained.
[0077] Step 201: Based on the task queue of the environment to be deployed, obtain the target information to be deployed; wherein, the task queue of the environment to be deployed includes at least one information to be deployed corresponding to the environment to be deployed, the information to be deployed is used to indicate at least one preset project, and the target information to be deployed is any information to be deployed in the task queue of the environment to be deployed.
[0078] In this embodiment of the disclosure, the electronic device includes, but is not limited to, devices such as computers, servers, terminals, and virtual machines. The electronic device can deploy at least one environment to be deployed in itself or in a device connected to the electronic device through the above-described environment deployment method. For example, the device used to deploy the environment is a virtual machine, which runs on the electronic device. Thus, one or more environments can be deployed in each virtual machine, so that when there are many environments to be deployed, fewer virtual machines can be used, which greatly reduces the deployment cost of the environment.
[0079] Environments not yet deployed are designated as "to-be-deployed environments," while already deployed environments are designated as "deployed environments." Since the same environment can be deployed multiple times, a deployed environment can be either partially deployed or fully deployed. "To-be-deployed environments" refer to the deployment of the overall environment or a portion of an overall environment. For example, in an e-commerce platform, the overall environment includes the closed-loop platform environment and the virtual store environment. Multiple "to-be-deployed environments" can be used to indicate the deployment of multiple overall environments and / or portions of multiple overall environments; multiple "to-be-deployed environments" can correspond to at least one overall environment.
[0080] The information to be deployed includes, but is not limited to, environment name, environment identifier, and project name. This information can be obtained from a POST request entered by the user, or the user can directly enter a POST request into the electronic device. The environment identifier may include an identity identifier (id) assigned to the environment to uniquely identify it; the environment name can also uniquely identify the environment. The default project can be a Golang project, a PHP project, a C project, a Python project, or a Java project, etc.; this disclosure does not limit the default project.
[0081] Electronic devices can periodically scan the task queue of the environment to be deployed. For example, electronic devices can scan the task queue of the environment to be deployed based on a preset time interval. If the task queue of the environment to be deployed is empty, the electronic device will not determine the target information to be deployed.
[0082] The task queue for environments to be deployed may include one or more deployment information entries corresponding to environments to be deployed. If the task queue for environments to be deployed includes only one deployment information entry, this entry will be used as the target deployment information entry.
[0083] When the task queue for the environment to be deployed includes multiple pieces of information to be deployed, the target information to be deployed can be determined according to the order in which the information to be deployed is obtained. For example, if the task queue for the environment to be deployed includes three pieces of information to be deployed, and the order in which the three pieces of information to be deployed is the first piece of information to be deployed, the second piece of information to be deployed, and the third piece of information to be deployed, the target information to be deployed is the first piece of information to be deployed. After the environment to be deployed corresponding to the first piece of information to be deployed is deployed, the target information to be deployed is the second environment to be deployed.
[0084] Of course, when single-threaded operation is supported, an electronic device can deploy one environment at a time; when multi-threaded operation is supported, an electronic device can deploy multiple environments at a time.
[0085] Step 202: Based on the target deployment information, obtain the configuration information corresponding to the target deployment environment; wherein, the target deployment environment is the environment corresponding to the target deployment information.
[0086] In this embodiment of the disclosure, based on the target deployment information, the detailed information of the deployment environment is configured. For example, the database has a config table, which is a database table used to store software or system configuration information. It is usually used to save and configure related information so that it can be read the next time it is used. The design of the config table can improve the maintainability and scalability of the system and allow the system behavior to be dynamically adjusted at runtime.
[0087] The electronic device can retrieve detailed information about the target deployment environment from the config table. This detailed information includes at least one of the following: a project list, technology stack, resource quotas, network domain name, and code pull information for preset projects. The project list may include one or more preset projects, and the code pull information may include Git address, branch, authentication token, etc. The configuration information may include detailed information and target deployment information, thus enabling the electronic device to obtain the information required when deploying the target deployment environment.
[0088] Step 203: Based on the configuration information, generate the target access container and the target business container corresponding to each preset project indicated by the target deployment information.
[0089] In this embodiment of the disclosure, the target access container is used to indicate the access point of the target deployment environment. When multiple environments are deployed on the same device, different deployment environments can be distinguished through different target access containers. The target access container includes at least one of the following: the IP address of the deployment environment, the domain name of a preset project, etc., so that the deployment environment can be located through the target access container, and services can be provided externally through the target access container.
[0090] The target business container serves as the runtime environment for applications, focusing on the execution of specific business functions and data processing. Within a microservice architecture, it assumes the role of implementing specific services and does not directly interact with end-users. For example, the target business container may include at least one of the following: runnable code, compiled code, or a runnable image file, thereby enabling the deployment environment to run through the target business container.
[0091] Step 204: Based on the bridge, target access container, and target service container corresponding to the target deployment environment, generate connected containers to complete the deployment of the environment.
[0092] In this embodiment of the disclosure, the target access container and the target service container are interconnected through a bridge, thereby enabling the target access container and the target service container corresponding to the target deployment environment to communicate through the bridge. The overall environment in which the already deployed environment to be deployed is located can be regarded as the deployed environment. For example, the first, second, and third deployment information are all deployed to the same overall environment. Different deployed environments correspond to different bridges, so that each deployed environment uses an independent bridging network and does not cause interconnection between containers in different deployed environments. This isolates containers in different environments and enables communication with the container network.
[0093] This disclosure provides an environment deployment method that can automatically determine whether a deployment environment exists based on a task queue of deployment environments. If a deployment environment exists, it is automatically deployed, thereby improving deployment efficiency and saving human resources. Automatic deployment also reduces deployment errors or omissions caused by manual deployment, achieving efficient environment delivery. Furthermore, the deployment task queue can include deployment information corresponding to at least one deployment environment, supporting the deployment of multiple deployment environments on the same device and multiple deployments of the same deployed environment, improving the flexibility and freedom of environment deployment. When multiple deployment environments need to be deployed, they can be deployed on the same device, reducing the number of devices required for environment deployment.
[0094] In some embodiments, step 203 includes steps 1031 to 1035, wherein:
[0095] Step 2031: Generate a specified directory based on the configuration information; wherein the specified directory includes the Nginx configuration directory and the project code directory corresponding to at least one preset project.
[0096] In this embodiment of the disclosure, the electronic device can create a specified directory on a specified storage node based on configuration information. The specified directory includes an Nginx configuration directory, a log directory, and a project code directory corresponding to at least one preset project.
[0097] The Nginx configuration directory is used to provide an access window to the outside world; the log directory is used to record the deployment process of the environment to be deployed; and the project code directory corresponding to the preset project is used to run the environment to be deployed.
[0098] Of course, the overall environment may include at least one environment to be deployed, and each environment to be deployed corresponds to one piece of information to be deployed. For example, the first piece of information to be deployed might indicate the deployment of a portion of the projects in the overall environment, and the second piece of information to be deployed might indicate the deployment of another portion of the projects in the overall environment. When deploying the first piece of information to be deployed, an Nginx configuration directory, a log directory, and the project code directory corresponding to the project indicated by the first piece of information to be deployed will be created. Assuming that the first piece of information to be deployed has already been deployed, and the target piece of information to be deployed is the second piece of information to be deployed, when generating the specified directory, the project code directory corresponding to the project indicated by the second piece of information to be deployed will be created, and the specified directory will be generated using the already created Nginx configuration directory and log directory.
[0099] Step 2032: For each preset project, based on the configuration information, obtain the target business container corresponding to the preset project, and mount the project code directory corresponding to the preset project to the target business container; the target business container is used to provide corresponding functions when the corresponding environment is accessed.
[0100] In this embodiment of the disclosure, the electronic device can obtain the target business container corresponding to each preset project, so that each target business container can implement one preset project. For example, the preset project can be a PHP project. The electronic device can obtain the target business container of the PHP project and mount the project code directory corresponding to the PHP project to the target business container corresponding to the PHP project.
[0101] For example, after deploying a virtual machine environment, the virtual machine can implement functions such as internal product recommendation, order placement, after-sales settlement, and transaction records. Each preset project corresponds to one function, that is, the target business container can implement the functions of internal product recommendation, order placement, after-sales settlement, or transaction records. Thus, one target business container can be created for each function, achieving functional decoupling and improving the maintainability and flexibility of the environment.
[0102] Step 2033: For each preset project, generate a vhost configuration file based on the Nginx configuration template and configuration information corresponding to the preset project.
[0103] In this embodiment, each preset project can correspond to one Nginx configuration template, which can be based on configuration information including project information corresponding to each preset project. For each preset project's project information and its corresponding Nginx configuration template, a configured Nginx configuration template is generated, and this template is used as a vhost configuration file. The vhost configuration file provides an accessible port number to the outside world.
[0104] Project information includes the project domain name, project container name, and can also include a dynamic port number for each project using a dynamic port allocation algorithm, making the vhost configuration file include the dynamic port number. The vhost configuration file includes at least one of the following: the default project domain name identifier, the project container name, and the container's container port identifier.
[0105] Step 2034: Add the vhost configuration file to the Nginx configuration directory and mount the Nginx configuration directory.
[0106] In this embodiment of the disclosure, at least one vhost configuration file is added to the Nginx configuration directory, so that the Nginx configuration directory can include the vhost configuration files corresponding to all preset projects, thereby determining the number of preset projects, the access entry point of the preset projects, etc. through the Nginx configuration directory.
[0107] Step 2035: Create a target access container based on the Nginx configuration directory and the access port identifier of the available ports; the target access container is used to provide access to the corresponding environment's ports.
[0108] In this embodiment of the disclosure, step 1035 may include: mounting the Nginx configuration directory and constructing a mapping relationship between the Nginx configuration directory and the access port identifiers of the available ports.
[0109] Access port identifiers include port numbers and other information, and can uniquely identify a port. If the environment to be deployed is deployed in a virtual machine, it is necessary to determine the available ports of the virtual machine and assign port numbers to the available ports of the virtual machine, so that the assigned available ports can be used as the ports for the target to access the container.
[0110] The number of available ports can be one or more, and the target access container includes the Nginx container. For example, two available ports are assigned port numbers, one as the HTTP port and the other as the HTTPS port, thus providing an access point for external access to the environment to be deployed. The Nginx configuration directory is mounted, and a mapping relationship is established between the Nginx configuration directory and the port numbers of the available ports. With the HTTP and HTTPS port mappings working correctly, the Nginx container is successfully built.
[0111] In some embodiments, the target service container includes a first target service container or a second target service container, and the configuration information includes technology stack information; for each preset project, based on the configuration information, the target service container corresponding to the preset project is obtained, including steps 301 to 305, wherein:
[0112] Step 301: Based on the technology stack information corresponding to the preset project, determine whether the preset project is a first preset project implemented in the first type of language.
[0113] In this embodiment of the disclosure, the technology stack information refers to the collection of various technologies and tools used during the deployment process, including programming languages, frameworks, databases, operating systems, etc. By identifying the programming languages used in the technology stack, it can be determined whether the preset project is a Golang project, a PHP project, a C project, a Python project, or a Java project, etc. This disclosure uses a Golang project and a PHP project as examples for illustration; the first preset project can refer to a Golang project.
[0114] Step 302: If the preset project is determined to be the first preset project, create a first image based on the executable file corresponding to the first preset project; wherein, the executable file is the file obtained by compiling the project code corresponding to the first preset project.
[0115] In this embodiment of the disclosure, since the Golang project includes code written in the Golang language, the code needs to be compiled (dynamic language). The electronic device can initiate a compilation task through the GitLab CI / CD pipeline, sending the project code corresponding to the first preset project to a remote device. The remote device compiles the project code corresponding to the first preset project, generates an executable file, and sends the executable file to the electronic device. Alternatively, the remote device may contain the project code corresponding to the first preset project, and the electronic device can send compilation instructions to the remote device to enable the remote device to compile the project code corresponding to the first preset project.
[0116] Electronic devices can create a first image based on an executable file. The first image is a Docker image, which packages and snapshots the project code corresponding to the first preset project and the runtime environment of the code. After compilation, the image is built, ensuring that the runtime environment of the project code is consistent. In other words, the first image enables the project code to run in the environment to be deployed, and also simplifies the deployment process.
[0117] Before step 302, the process also includes: based on the code retrieval information corresponding to the first preset project, retrieving the project code corresponding to the first preset project from the code repository; adding the project code corresponding to the first preset project to the project code directory corresponding to the first preset project, so that the project code corresponding to the first preset project can be obtained through Git address, branch, authentication token, etc., and the version of the code is consistent with the branch, so that the code required by the first preset project can be obtained.
[0118] In step 302, the electronic device can push the constructed first image to the image repository, thereby saving the image in the image repository.
[0119] Step 303: Create the first target business container based on the first image.
[0120] In this embodiment of the disclosure, a first image corresponding to a first preset project can be pulled from an image repository to create a first target business container. The first target business container is a Docker container. Then, a runnable first target business container can be created from the first image. The target deployment environment and the running environment of the project code can be isolated through the first target business container to achieve the correct running of the project code.
[0121] Step 304: If it is determined that the preset project is a second preset project implemented in the second type of language, obtain the second image corresponding to the second preset project.
[0122] In this embodiment of the disclosure, a second image can be pulled from an image repository. The second preset project includes a PHP project, and the second image is a PHP image. Since the PHP image does not depend on the compiled executable file, the second image can be a pre-prepared fixed PHP image.
[0123] Step 305: Create a second target business container based on the second image.
[0124] In this embodiment of the disclosure, a second target business container for a PHP project can be created based on a second image. The second target business container is a Docker container.
[0125] Steps 301 to 305 above are illustrated using either a Golang or PHP project as an example. Since the Golang project code needs to be compiled before an image can be built, while the PHP project image can be directly pulled, the process of creating the first target business container for a Golang project differs from the process of creating the second target business container for a PHP project. Furthermore, different containers are used to implement the functions corresponding to different preset projects, reducing the coupling between containers and functions. If an exception occurs in one container, it will not affect the operation of other containers, facilitating the management of the deployment environment.
[0126] In some embodiments, the target deployment information includes an environment identifier; step 204 includes steps 2041 to 2043, wherein:
[0127] Step 2041, create a bridge.
[0128] In this embodiment of the disclosure, the bridge includes a Docker bridge, and the name of the bridge can be the environment name of the target deployment environment, thereby enabling the bridge to be named according to the environment name entered by the user.
[0129] Step 2042: Traverse the target access container and target business container corresponding to the target deployment environment.
[0130] In this embodiment of the disclosure, all containers in the target deployment environment are traversed. The target access container can refer to the container obtained through steps 301 to 305 above, and may also include containers created during the previous deployment of the overall environment containing the deployment environment. The target access container includes Docker containers, and the target business container includes Nginx containers.
[0131] Step 2043: Control both the target access container and the target service container to connect to the bridge, thus obtaining connected containers.
[0132] In this embodiment of the disclosure, each container is connected to a bridge, thereby enabling containers in the same deployment environment to communicate, and enabling containers in the same deployment environment to communicate through container names or bridges.
[0133] In some embodiments, the configuration information includes a domain name identifier corresponding to each preset item; the method further includes steps 401 to 402, wherein:
[0134] Step 401: Based on the domain name identifier corresponding to each target service container in the container and the Internet identifier corresponding to the target access container, construct the correspondence between the Internet identifier and each domain name identifier; the domain name identifier of the target service container is consistent with the domain name identifier of the corresponding preset project.
[0135] In this embodiment of the disclosure, the domain name identifier includes a domain name, and the Internet identifier includes the Internet Protocol (IP). The IP address of the bridge can be set to the IP address of the target service container. The domain name of the target service container is the domain name of its corresponding preset project. In the connected containers, the domain name and IP address corresponding to each target service container are bound together to establish a correspondence.
[0136] Step 402: Generate a host file based on the correspondence.
[0137] In this embodiment of the disclosure, this correspondence is written into a custom host file, so that preset projects within the target deployment environment can call each other through domain names, and users can locate a unique IP through a simple domain name, reducing the cost of use. After the IP changes, only the host file needs to be modified, and the above-mentioned container does not need to be modified, reducing the modifications required when the IP changes.
[0138] In some embodiments, the method further includes at least one of the following:
[0139] Step 501: Based on the obtained environment deletion request, delete the running information of the first deployed environment corresponding to the environment deletion request; wherein, the running information includes connected containers.
[0140] In this embodiment of the disclosure, the environment deletion request is used to instruct the deletion of the first deployed environment. The environment deletion request may include at least one of the following: access port identifier, environment name, environment ID, etc. The environment deletion request can be a user-input request, thereby enabling the deletion of the first deployed environment in real time in response to user input.
[0141] An environment deletion request can uniquely identify the first deployed environment. By deleting the containers associated with the first deployed environment, the memory occupied by the first deployed environment is reduced, providing storage space for subsequent deployed environments. The runtime information can also include a hosts file, which avoids mapping errors when locating deployable environments by domain name because the deployable environment has been deleted. It also releases allocated domain names, enabling the circular use of domain names.
[0142] Step 502: Calculate the runtime of the second deployed environment; if the runtime is greater than or equal to the preset duration, delete the runtime information corresponding to the second deployed environment.
[0143] In this embodiment of the disclosure, the runtime of the second deployed environment can be automatically counted. The second deployed environment can be a test environment, a VIP environment, or any deployed environment, etc. This disclosure does not limit the second deployed environment.
[0144] Runtime may refer to the actual running time, renewal time, or unmaintained time of the second deployed environment, etc. This disclosure does not limit the runtime.
[0145] For example, the second deployed environment is any deployed environment, and the runtime is the renewal duration. After creating a deployed environment, the user can apply for the renewal duration of the deployed environment. The renewal duration can be 1 year, and the preset duration is 1 year. That is, the user can apply to continue running the deployed environment every year, so that the electronic device can automatically clear the deployed environment that does not need to run, which can reduce the storage space occupied by deployed environments that have not been running for a long time.
[0146] In some embodiments, reminder information is generated and output based on runtime and preset duration.
[0147] In this embodiment of the disclosure, the user is reminded to renew the service when the runtime approaches a preset duration, thus preventing the environment from automatically destroying due to lack of reminders. The electronic device can obtain user information, which may include at least one of the following: phone number, email address, software ID, etc., thereby enabling reminders to the user via telephone, SMS, software, etc.
[0148] In some embodiments, the method further includes steps 601 to 604, wherein:
[0149] Step 601, obtain the target request; wherein the target request includes a target identifier, and the target request is used to indicate at least one of the following: query information in the deployed environment, delete the deployed environment, or configure the environment to be deployed.
[0150] In this embodiment of the disclosure, target requests are categorized according to function, and may include environment deletion requests, environment configuration requests, project deletion requests, or information query requests, etc. Target requests are also categorized according to code type, and may include POST requests or GET requests. POST requests are used to instruct the deletion of a deployed environment, the deletion of a preset project within a deployed environment, or the deployment of an environment to be deployed. GET requests are used to instruct the querying of information.
[0151] Of course, the target request can be used to instruct the extension of the runtime of the deployed environment, adjust the parameters in the deployed environment, etc., and this disclosure does not limit the target request.
[0152] Step 602: Based on the target identifier, determine whether there is a deployed environment corresponding to the target identifier.
[0153] In this embodiment of the disclosure, the target identifier can be used to locate a unique environment to be deployed. The target identifier may include at least one of the following: access port identifier, environment name, environment ID, etc.
[0154] Step 603: If it is determined that there is a deployed environment corresponding to the target identifier, execute the target request in the deployed environment corresponding to the target identifier.
[0155] In this embodiment of the disclosure, when the target request is used to instruct the deletion of a deployed environment, the target request can be used as an environment deletion request, or an environment deletion request can be generated based on the target request. The deployed environment corresponding to the target identifier is the first deployed environment, and then step 501 is executed to delete the first deployed environment.
[0156] When the target request is used to instruct the deployment of the environment to be deployed, the target request includes the information to be deployed, or the information to be deployed is generated based on the target request. The environment to be deployed corresponding to the target identifier is the target environment to be deployed. Then, the above steps 202 to 204 are performed to deploy the target environment to be deployed.
[0157] When the target request is used to instruct a query for information in the deployed environment, the information indicated by the target request can be queried in the runtime information corresponding to the deployed environment.
[0158] Step 604: If it is determined that there is no deployed environment corresponding to the target identifier, execute the target request, or generate a prompt message for the target request.
[0159] In this embodiment of the disclosure, the prompt information includes a first prompt information. When a target request is used to instruct the deletion of a deployed environment, since there is no deployed environment corresponding to the target identifier, a first prompt information can be generated to inform the user that the environment does not exist, and therefore the environment indicated by the target request cannot be deleted.
[0160] When a target request is used to instruct the deployment of an environment to be deployed, since there is no deployed environment corresponding to the target identifier, this is the first time the environment corresponding to the target identifier is deployed. The target request may include information to be deployed, or information to be deployed may be generated based on the target request.
[0161] The prompt message includes a second prompt message. When the target request is used to instruct a query for information in the environment to be deployed, since no deployed environment corresponding to the target identifier exists, a second prompt message can be generated to inform the user that the environment does not exist and that the information for the environment indicated by the target request cannot be queried.
[0162] Figure 3 This is a schematic diagram of a framework according to an exemplary embodiment, such as... Figure 3 As shown, when opening a virtual store on a closed-loop platform, electronic devices... Figure 3The framework shown enables the processing of closed-loop platforms and virtual stores. The framework includes a front-end UI, presentation layer, business layer, data layer, database, and runtime environment. The front-end UI can utilize HTML, CSS, and Vue technologies, allowing electronic devices to display pages and enabling users to input their desired requests through the front-end UI.
[0163] The presentation layer supports template engine rendering and Ajax interaction. Template engine rendering provides code compilation functionality for displaying the front-end pages. Ajax interaction provides interfaces for POST and GET requests, enabling the front-end pages to display the corresponding pages for POST and GET requests respectively.
[0164] The business layer supports features such as deployment of PHP projects, Go projects, closed-loop PHP projects, and resource recycling. A Go project refers to the aforementioned Golang project. When deploying a Go project, the corresponding project code needs to be compiled, which can be done by calling the GitLab pipeline.
[0165] The data layer includes a deployment information table, a project information table, and a user table. The deployment information table records the environments to be deployed and the deployed environments after deployment; the project information table records the projects to be deployed in each environment to be deployed and the projects that have already been deployed; the user table records information about verified users, as well as the time when users performed deployments in the environments to be deployed, and the time when they modified or queried the deployed environments.
[0166] Logs can record information related to each function in the business layer and changes in data in each table in the data layer, so that when abnormalities occur in the operation of electronic devices, the abnormalities can be reviewed, eliminated and optimized in a timely manner.
[0167] Electronic devices also support access control functions. For example, when deploying projects within a virtual store using the PHP project deployment function, it is necessary to determine whether the user has deployment permissions. Thus, access control functions can increase the security of the virtual store and the closed-loop platform.
[0168] The databases include MySQL and Redis. MySQL enables persistent storage of information, while Redis enables caching. For example, MySQL can store the connected containers and hosts file of the environment to be configured, while Redis can store information such as domain names, environment names, and project container names required during the configuration process.
[0169] The runtime environment adopts a distributed runtime environment, which enables different preset projects to run in the same deployment environment. The bridge enables communication between multiple preset projects, avoids single point of failure that could cause the entire deployment environment to fail, and allows for the expansion of functions and information in the deployment environment by adding preset projects.
[0170] Figure 4 This is a flowchart illustrating a configuration environment according to an exemplary embodiment, such as... Figure 4 As shown, steps 41 to 51 are included, wherein:
[0171] Step 41: Based on the task queue of the environment to be deployed, determine whether there is an environment to be deployed. If yes, proceed to step 42; otherwise, proceed to step 41.
[0172] Step 42: Obtain the deployment information of the environment to be deployed, and use this environment to be deployed as the target environment to be deployed, and use this deployment information as the target deployment information; and pull the configuration information of the target environment to be deployed; the configuration information includes the technology stack, domain name and code retrieval information corresponding to the preset project;
[0173] Step 43: Based on the configuration information, create and mount the specified directory; wherein, the specified directory includes the Nginx configuration directory and the project code directory corresponding to at least one preset project;
[0174] Step 44: Based on the code retrieval information, retrieve the required project code from the code repository;
[0175] Step 45: Based on the technology stack corresponding to the preset project, determine whether the preset project is a Golang project. If yes, proceed to step 46; otherwise, proceed to step 47.
[0176] Step 46: Compile the Golang project code using a remote device to obtain an executable file, and create a Docker image corresponding to the Golang project based on the executable file;
[0177] Step 47: Create a Docker container based on the Docker image corresponding to the preset project;
[0178] Step 48: For each preset project, add the domain name, container port name, and container port identifier corresponding to the preset project to the vhost file corresponding to the preset project;
[0179] Step 49: Use the available ports on the physical machine as HTTP and HTTPS ports; add the vhost file to the Nginx configuration directory; mount the Nginx configuration directory and map the HTTP and HTTPS ports to obtain the Nginx container;
[0180] Step 50: Create a bridge and connect the Docker container and the Nginx container to the bridge;
[0181] Step 51: Obtain the IP address of the Nginx container; bind the domain name and IP address of each container and write them to the hosts file.
[0182] In this embodiment, in step 41, the user can send a POST request through the front-end UI. For example, the user can request to create a virtual store on the closed-loop platform or configure the closed-loop platform. The closed-loop platform has functions such as internal product recommendation, order placement, after-sales settlement, and transaction records. Configuring the virtual store or closed-loop platform requested by the user can be considered as configuring the environment. The POST request can include information such as environment name, environment ID, and project name, and can also include the user's username, user ID, and verification code. Based on the POST request, the electronic device generates deployment information and adds it to the deployment environment task queue. The deployment environment can be used to indicate: deploying a virtual store, deploying a preset project for a virtual store, or deploying the closed-loop platform.
[0183] The electronic device may include a deployment scheduling module, which determines, based on a scheduled task, whether the task queue of the environment to be deployed includes information to be deployed; if the task queue of the environment to be deployed includes information to be deployed, it is determined that an environment to be deployed exists; if the task queue of the environment to be deployed does not include information to be deployed, it is determined that no environment to be deployed exists.
[0184] Scheduled tasks can be used to indicate the interval between two adjacent queries. For example, a scheduled task can indicate 1 second, and the deployment scheduling module can determine once per second whether the task queue for the environment to be deployed includes information to be deployed.
[0185] When the task queue of the environment to be deployed includes multiple pieces of information to be deployed, the target information to be deployed can be determined from the multiple pieces of information to be deployed.
[0186] The electronic device may also include an environment configuration module. This module can retrieve detailed information about the target deployment environment based on the deployment information and records in the `config` table of the database. This detailed information may include a project list, technology stack (Golang / PHP), resource quotas, domain name, code retrieval information, etc. The configuration information includes the deployment information and detailed information, and includes at least one of the following: environment identifier, project list, technology stack, resource quotas, domain name of a preset project, code retrieval information of a preset project, etc.
[0187] The electronic device also includes a storage management module. Based on configuration information, this module can create a specified directory corresponding to the target deployment environment on a designated storage node and mount the directory. This directory can include the project code directory, log directory, and Nginx configuration directory. After mounting the directory, the storage management module will set its permissions to read and write for the docker user group, allowing users to access the specified directory via a GET request and continue configuring the target deployment environment via a subsequent POST request.
[0188] For example, the target deployment environment is used to instruct the creation of a virtual store. When the target deployment environment is deployed for the first time, the virtual products of the virtual store can be deployed. When the target deployment environment is deployed for the second time, the order function, settlement function, coupon function, etc. of the virtual store can be deployed.
[0189] The electronic device also includes an authentication module. This module verifies the user's identity after receiving POST or GET requests, protecting the security of the virtual store and closed-loop platform. For example, the electronic device can provide a login interface. Only after the user logs in can the device display pages for environment configuration, deletion, or querying. Login functionality can be achieved through mobile authentication, granting the user permissions to edit or delete environments only after login.
[0190] The electronic device also includes a code retrieval module. This module retrieves project code from the code repository based on code retrieval information, including the Git address, branch, and authentication token. This ensures that the required project code is completely retrieved to the specified project code directory, guaranteeing that the code version matches the configured branch.
[0191] The electronic device also includes a project type identification module. Based on the project configuration information, the project type identification module determines whether the preset project is a Golang project. The preset project can be a Golang project, a PHP project, a C project, a Python project, or a Java project, etc. This solution will be explained using the example that the project can be a Golang project or a PHP project.
[0192] The project configuration information includes the technology stack, which includes frameworks, programming languages, and other information. It can determine whether the default project is a Golang project based on the programming language. For example, if the programming language in the technology stack is PHP, the default project is a PHP project; if the programming language is Go, the default project is a Golang project.
[0193] The electronic device also includes a Golang compilation and image building module. This module triggers compilation tasks through the GitLab CI / CD pipeline, instructing remote devices to compile the code corresponding to the Golang project, generating an executable file. Based on the executable file, it builds a Go application image and pushes the Go application image to the image repository. The Go application image is the first image.
[0194] The electronic device also includes a container creation module, which pulls Go application images from an image repository; creates a Go application container for each Go application image; and mounts the project code directory corresponding to the Golang project to the Go application container. The Go application container is the first target business container, the PHP application image is the second image, and the PHP application container is the second target business container.
[0195] The container creation module can directly obtain the PHP application image corresponding to the PHP project from the image repository, create a PHP application container for each PHP application image, and mount the project code directory corresponding to the PHP project into the PHP application container. This enables the successful creation and running of the target business container corresponding to the preset project. Docker containers include target business containers, which include PHP application containers and Go application containers. The target business container is the runtime environment for the application, focusing on the execution of specific business functions and data processing. In a microservice architecture, the target business container plays a specific service implementation role and does not directly face end-user access.
[0196] The electronic device also includes an Nginx configuration management module. The Nginx configuration management module pulls the Nginx configuration template corresponding to each project from the configuration library; for each preset project, it adds parameters such as the domain name, project container name and container port identifier corresponding to the preset project to the Nginx configuration template corresponding to the preset project to generate a vhost configuration file; and adds the vhost configuration file corresponding to each preset project to the Nginx configuration directory.
[0197] The electronic device also includes an Nginx container management module. This module detects the available ports on the device and selects two ports as the HTTP and HTTPS ports for the Nginx container, respectively. It mounts the Nginx configuration directory and establishes mappings between the Nginx configuration directory and the HTTP and HTTPS ports. This allows it to mount vhost configuration files and create mappings between the Nginx configuration directory and the ports. If the port mappings are successful, the Nginx container is created successfully. The Nginx container is a special type of Docker container that serves as the entry point to the target deployment environment. In multi-environment deployments, the Nginx container distinguishes different deployment environments using different host ports. The Nginx container can mount configuration files to provide static files and SSL (Secure Socket Layer) certificates for connections to other devices, thus providing traffic management and routing functions and providing an entry point for external access.
[0198] The electronic device also includes a network management module. This module creates Docker bridges and uses the environment name as the bridge name. It iterates through all containers within the target deployment environment and performs bridge connection operations for each container. This allows all containers in the target deployment environment to be connected to the bridge. Containers can communicate using their container names, or they can be assigned different bridges, enabling communication via IP addresses within the bridge. A bridge can refer to a bridged network, which provides basic network connectivity and automatic service discovery. Containers can communicate directly using domain names.
[0199] The electronic device also includes a domain name resolution module, which uses the Nginx container's IP address as the bridge's IP address. Each pre-defined project has an independent domain name, and each pre-defined project corresponds to one target business container. The domain name of the target business container and the IP address of the bridge are bound together, and the binding relationship between the domain name of the target business container and the IP address of the bridge is recorded in the host file. This allows the pre-defined projects within the target deployment environment to call each other via domain names, thus completing the deployment of the target deployment environment. The host file, as a supplement to static domain name resolution, can be used to customize domain name mapping, cross-environment service calls, or override the default DNS resolution rules.
[0200] The method disclosed herein is used on e-commerce platforms and supports the deployment of closed-loop platforms and virtual stores. It also supports multiple deployments of the same closed-loop platform or virtual store, meaning that multiple closed-loop platforms and / or multiple virtual stores can be deployed on the same electronic device. For example, more than 20 preset projects can be deployed in a virtual store, allowing relevant personnel to manage the environment efficiently and significantly reducing project development and testing environment issues. This can reduce project development and testing environment issues by 90% and also improve deployment flexibility.
[0201] During deployment, each preset project corresponds to a target business container, which is used to implement specific business functions and data processing, thereby reducing the coupling between different containers and facilitating the management of preset projects.
[0202] The method replaces manual deployment of environments with automated deployment by electronic devices, reducing unnecessary manpower waste. It also reduces the time required to deploy an environment from hours to minutes. For example, while it takes 4 hours for workers to deploy an environment, electronic devices can deploy it in just 5 minutes, improving deployment efficiency and time utilization. In related technologies, deploying nine environments requires nine devices, while in this method, one electronic device supports the deployment of multiple environments. Therefore, the number of devices required to deploy nine environments can be less than nine; for example, nine environments can be deployed on two electronic devices, significantly reducing the number of devices needed.
[0203] Furthermore, the aforementioned environment deployment method achieves automated environment deployment and simplifies the process through a fully automated closed-loop process, a unified framework across multiple technology stacks, deep integration of DevOps and containerization, integrated network and domain name management, and modular design. When deploying each environment, multiple complete environments can be deployed on the same device. For each overall environment, the host file and the bridge complement each other in container communication, working together. The host file provides flexible domain name management, while the bridged network ensures reliable network connectivity, jointly building a complete container network solution.
[0204] The following description continues to illustrate the exemplary structure of the environment deployment device 155 provided in the embodiments of this application as a software module. In some embodiments, such as... Figure 1 As shown, the software modules stored in the environment deployment device 155 of the memory 150 may include:
[0205] The first acquisition module 1551 is used to acquire target deployment information based on the deployment environment task queue; wherein, the deployment environment task queue includes at least one deployment information corresponding to the deployment environment, the deployment information is used to indicate at least one preset project, and the target deployment information is any deployment information in the deployment environment task queue.
[0206] The second acquisition module 1552 is used to acquire configuration information corresponding to the target deployment environment based on the target deployment information; wherein, the target deployment environment is the environment corresponding to the target deployment information;
[0207] The first generation module 1553 is used to generate target access containers and target business containers corresponding to each preset project indicated by the target deployment information based on the configuration information.
[0208] The second generation module 1554 is used to generate connected containers based on the bridge corresponding to the target deployment environment, the target access container, and the target service container corresponding to each preset project, so as to complete the deployment of the environment.
[0209] In some embodiments, the first generation module 1553 is configured to:
[0210] A specified directory is generated based on the configuration information; the specified directory includes the Nginx configuration directory and the project code directory corresponding to at least one preset project;
[0211] For each preset project, based on the configuration information, the target business container corresponding to the preset project is obtained, and the project code directory corresponding to the preset project is mounted to the target business container; the target business container is used to provide corresponding functions when the corresponding environment is accessed;
[0212] For each preset project, a vhost configuration file is generated based on the corresponding Nginx configuration template and configuration information.
[0213] Add the vhost configuration file to the Nginx configuration directory and mount the Nginx configuration directory;
[0214] A target access container is created based on the Nginx configuration directory and the access port identifier of the available ports; the target access container is used to provide access to the corresponding environment's ports.
[0215] In some embodiments, the target service container includes a first target service container or a second target service container, and the configuration information includes technology stack information; the first generation module 1553 is used for:
[0216] Based on the technology stack information corresponding to the preset project, determine whether the preset project is the first preset project implemented in the first type of language;
[0217] If the preset project is determined to be the first preset project, a first image is created based on the executable file corresponding to the first preset project; wherein, the executable file is the file obtained by compiling the project code corresponding to the first preset project;
[0218] Based on the first image, create the first target business container;
[0219] If the preset project is determined to be a second preset project implemented in a second type of language, obtain the second image corresponding to the second preset project;
[0220] Create a second target business container based on the second image.
[0221] In some embodiments, the target deployment information includes an environment identifier; the second generation module 1554 is configured to:
[0222] Create a bridge;
[0223] Iterate through the target access container and target business container corresponding to the target deployment environment;
[0224] Both the target access container and the target service container are connected to the bridge, resulting in a connected container.
[0225] In some embodiments, the configuration information includes a domain name identifier corresponding to each preset item; the apparatus further includes: a third generation module, configured to:
[0226] Based on the domain name identifier corresponding to each target service container in the container and the Internet identifier corresponding to the target access container, a correspondence between the Internet identifier and each domain name identifier is constructed; the domain name identifier of the target service container is consistent with the domain name identifier of the corresponding preset project.
[0227] Based on the correspondence, a host file is generated.
[0228] In some embodiments, the apparatus further includes a deletion module for:
[0229] Based on the obtained environment deletion request, delete the runtime information of the first deployed environment corresponding to the environment deletion request; wherein, the runtime information includes connected containers;
[0230] Calculate the runtime of the second deployed environment; if the runtime is greater than or equal to the preset duration, delete the runtime information corresponding to the second deployed environment.
[0231] In some embodiments, the apparatus further includes an execution module, configured to:
[0232] Obtain the target request; wherein the target request includes a target identifier and is used to indicate at least one of the following: querying information in the deployed environment, deleting the deployed environment, or configuring the environment to be deployed;
[0233] Based on the target identifier, determine whether there is a deployed environment corresponding to the target identifier;
[0234] If it is determined that a deployment environment corresponding to the target identifier exists, the target request is executed in the deployment environment corresponding to the target identifier;
[0235] If it is determined that there is no deployed environment corresponding to the target identifier, execute the target request, or generate a prompt message for the target request.
[0236] This application provides a computer program product comprising a computer program or computer-executable instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer program or executable instructions from the computer-readable storage medium and executes the computer program or executable instructions, causing the electronic device to perform the method described in this application.
[0237] This application provides a computer-readable storage medium storing a computer program or computer-executable instructions. When the computer program or executable instructions are executed by a processor, the processor will execute the environment deployment method provided in this application, for example, such as... Figure 2 The environment deployment method is shown.
[0238] In some embodiments, the computer-readable storage medium may be a memory such as RAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or it may be a variety of devices including one or any combination of the above-mentioned memories.
[0239] In some embodiments, computer-executable instructions may take the form of programs, software, software modules, scripts, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as stand-alone programs or as modules, components, subroutines, or other units suitable for use in a computing environment.
[0240] As an example, computer-executable instructions may, but do not necessarily, correspond to files in a file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple co-located files (e.g., a file that stores one or more modules, subroutines, or code sections).
[0241] As an example, computer-executable instructions can be deployed to execute on a single computing device, or on multiple computing devices located in one location, or on multiple computing devices distributed across multiple locations and interconnected via a communication network.
[0242] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, and improvements made within the spirit and scope of this application are included within the scope of protection of this application.
Claims
1. An environmental deployment method, characterized in that, The method includes: Based on the task queue of the environment to be deployed, the target information to be deployed is obtained; wherein, the task queue of the environment to be deployed includes at least one information to be deployed corresponding to the environment to be deployed, the information to be deployed is used to indicate at least one preset project, and the target information to be deployed is any information to be deployed in the task queue of the environment to be deployed. Based on the target deployment information, obtain the configuration information corresponding to the target deployment environment; wherein, the target deployment environment is the environment corresponding to the target deployment information; Based on the configuration information, a target access container and a target business container corresponding to each preset project indicated by the target deployment information are generated. Based on the bridge corresponding to the target deployment environment, the target access container, and the target service container corresponding to each preset project, a connected container is generated to complete the deployment of the environment.
2. The method according to claim 1, characterized in that, The step of generating a target access container and a target business container corresponding to each preset project indicated by the target deployment information based on the configuration information includes: A specified directory is generated based on the configuration information; wherein, the specified directory includes an Nginx configuration directory and a project code directory corresponding to at least one preset project; For each preset project, based on the configuration information, the target business container corresponding to the preset project is obtained, and the project code directory corresponding to the preset project is mounted to the target business container; the target business container is used to provide corresponding functions when the corresponding environment is accessed; For each of the preset projects, a vhost configuration file is generated based on the Nginx configuration template corresponding to the preset project and the configuration information; Add the vhost configuration file to the Nginx configuration directory and mount the Nginx configuration directory; The target access container is created based on the Nginx configuration directory and the access port identifier of the available ports; the target access container is used to provide access to the corresponding environment.
3. The method according to claim 2, characterized in that, The target service container includes a first target service container or a second target service container, and the configuration information includes technology stack information; For each preset project, based on the configuration information, obtaining the target business container corresponding to the preset project includes: Based on the technology stack information corresponding to the preset project, determine whether the preset project is a first preset project implemented in a first type of language; If the preset project is determined to be a first preset project, a first image is created based on the executable file corresponding to the first preset project; wherein, the executable file is a file obtained by compiling the project code corresponding to the first preset project; Based on the first image, create the first target business container; If it is determined that the preset project is a second preset project implemented in a second type of language, obtain the second image corresponding to the second preset project; Based on the second image, create the second target business container.
4. The method according to claim 1, characterized in that, The target deployment information includes an environment identifier; the generation of connected containers based on the bridge corresponding to the target deployment environment, the target access container, and the target service container corresponding to each preset project includes: Create the bridge described above; Iterate through the target access container and target business container corresponding to the target deployment environment; The target access container and the target service container are both connected to the bridge to obtain connected containers.
5. The method according to claim 1, characterized in that, The configuration information includes a domain name identifier corresponding to each preset item; the method further includes: Based on the domain name identifier corresponding to each target service container in the connected container and the Internet identifier corresponding to the target access container, a correspondence between the Internet identifier and each domain name identifier is constructed; the domain name identifier of the target service container is consistent with the domain name identifier of the corresponding preset project; Based on the aforementioned correspondence, a host file is generated.
6. The method according to any one of claims 1 to 5, characterized in that, The method further includes at least one of the following: Based on the obtained environment deletion request, delete the running information of the first deployed environment corresponding to the environment deletion request; wherein, the running information includes the connected container; The runtime of the second deployed environment is recorded; if the runtime is greater than or equal to a preset duration, the runtime information corresponding to the second deployed environment is deleted.
7. The method according to any one of claims 1 to 5, characterized in that, The method further includes: Obtain a target request; wherein the target request includes a target identifier, and the target request is used to indicate at least one of the following: querying information in a deployed environment, deleting a deployed environment, or configuring an environment to be deployed; Based on the target identifier, determine whether there is a deployed environment corresponding to the target identifier; If it is determined that a deployment environment corresponding to the target identifier exists, the target request is executed in the deployment environment corresponding to the target identifier; If it is determined that there is no deployed environment corresponding to the target identifier, the target request is executed, or a prompt message for the target request is generated.
8. An environmental deployment device, characterized in that, The device includes: The first acquisition module is used to acquire target deployment information based on the deployment environment task queue; wherein, the deployment environment task queue includes deployment information corresponding to at least one deployment environment, the deployment information is used to indicate at least one preset project, and the target deployment information is any deployment information in the deployment environment task queue; The second acquisition module is used to acquire configuration information corresponding to the target deployment environment based on the target deployment information; wherein, the target deployment environment is the environment corresponding to the target deployment information; The first generation module is used to generate a target access container and a target business container corresponding to each preset project indicated by the target deployment information, based on the configuration information. The second generation module is used to generate connected containers based on the bridge corresponding to the target deployment environment, the target access container, and the target service container corresponding to each preset project, so as to complete the deployment of the environment.
9. An electronic device, characterized in that, include: processor; Memory used to store computer programs or instructions; The processor executes the computer program or instructions to implement the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program or instructions, characterized in that, When the computer program or instructions are executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.