Web application development environment building method and device, equipment and storage medium
By building basic image of the production environment and development project image, and using container technology to mount code files and mapping ports, the problem of inconsistency between the development environment and the production environment is solved, and the efficiency of development and testing and the stability of application is improved.
Patent Information
- Application Number
- CN202311385505.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-24
- Publication Date
- 2025-04-25
AI Technical Summary
During the web application development process, the development environment is inconsistent with the production environment, resulting in problems that may not occur during testing after the application is launched.
By building a basic image corresponding to the production environment and building a project image of the development project on it, ensure that the local development environment is consistent with the production environment. At the same time, the code files of the development project are mounted into the container using container technology and the ports of the container are mapped to the local port for easy access to the development project.
It avoids additional testing problems caused by inconsistency between the development environment and the production environment, improves the efficiency of development and testing, and ensures the stability after the application is launched.
Smart Images

Figure CN119883247A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, equipment and storage medium for building a development environment for a web application. Background Art
[0002] A web application is a computer program that is stored on a remote server and run by its users through a web browser. When developing a web application, you need to build a development environment, which is a series of software tools installed on the development device for the purpose of developing web applications.
[0003] In the related art, developers build a development environment on their own development devices and then develop web applications. However, the development environment built on the development device may be different from the actual production environment, resulting in problems that did not appear during testing after the application is launched. Summary of the invention
[0004] The present application provides a method, device, equipment and storage medium for building a development environment for a web application, which ensures that the local development environment is consistent with the production environment, and avoids the occurrence of additional testing problems caused by the inconsistency between the development environment and the production environment.
[0005] In a first aspect, the present application provides a method for building a development environment for a web application, comprising:
[0006] For a web application to be developed, respectively building a base image corresponding to the production environment of the web application and a project image corresponding to the development project of the web application; the project image is built on the base image;
[0007] Create containers corresponding to the base image and the project image respectively;
[0008] Mounting a directory storing code files corresponding to the development project to a directory of a container corresponding to the project image, so as to install the development project in the container;
[0009] The port of the container corresponding to the project image is mapped to the local port, so that the local can access the development project by accessing the local port.
[0010] Optionally, for the web application to be developed, respectively building a base image corresponding to the production environment of the web application and a project image corresponding to the development project of the web application includes:
[0011] Obtain a project startup script corresponding to the web application; the project startup script includes build commands corresponding to each of the images;
[0012] Execute the build commands corresponding to the images to build the base image and the project image.
[0013] Optionally, the project startup script also includes image parameters corresponding to the base image and the project image respectively; the image parameters include a startup command, environment variables, port, and user name and password; the image parameters are used to start the corresponding image.
[0014] Optionally, the method further comprises:
[0015] When receiving a building request sent by a device other than a local device, the project startup script is sent to the device, so that the device builds a development environment corresponding to the web application according to the project startup script.
[0016] Optionally, the creating containers corresponding to the base image and the project image respectively includes:
[0017] The application container engine Docker is used to create containers corresponding to the basic image and the project image respectively.
[0018] Optionally, the method further comprises:
[0019] According to the project development instruction triggered by the user, the container corresponding to the project image is started to start the development project.
[0020] In a second aspect, the present application provides a device for building a development environment for a web application, comprising:
[0021] A construction module, for respectively constructing a base image corresponding to a production environment of a web application to be developed and a project image corresponding to a development project of the web application; the project image is constructed on the base image;
[0022] A creation module, used to create containers corresponding to the base image and the project image respectively;
[0023] A mounting module, used to mount the directory storing the code files corresponding to the development project to the directory of the container corresponding to the project image, so as to install the development project in the container;
[0024] A mapping module is used to map the port of the container corresponding to the project image to a local port, so that the development project can be accessed locally by accessing the local port.
[0025] Optionally, the building block includes:
[0026] An acquisition submodule is used to acquire a project startup script corresponding to the web application; the project startup script includes a build command corresponding to each of the images;
[0027] The execution submodule is used to execute the build commands corresponding to each of the images to build the base image and the project image.
[0028] In a third aspect, the present application provides an electronic device, comprising: a processor and a memory communicatively connected to the processor;
[0029] The memory stores computer-executable instructions;
[0030] The processor executes the computer-executable instructions stored in the memory to implement the method for building a development environment for a web application as described in any one of the first aspects.
[0031] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method for building a development environment for a web application as described in any one of the first aspects.
[0032] In a fifth aspect, the present application provides a computer program product, comprising computer executable instructions, which, when executed by a processor, implement the method for building a development environment for a web application as described in any one of the first aspects.
[0033] The web application development environment building method, device, equipment and storage medium provided in the present application provide a solution for building a development environment for web applications. For the web application to be developed, a basic image corresponding to the production environment of the web application is directly built, so that the project image corresponding to the development project of the web application can be built on the basic image, thereby ensuring that the local development environment is consistent with the production environment, avoiding the occurrence of additional testing problems caused by the inconsistency between the development environment and the production environment. On this basis, by mounting the directory storing the code files corresponding to the development project to the directory of the container corresponding to the project image, the development project can be deployed in the container, so that the development project can be started in the container later, and by mapping the port of the container corresponding to the project image to the local port, the local can access the development project by accessing the local port. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0035] Figure 1 It is a schematic diagram of an application scenario provided by this application;
[0036] Figure 2 It is a flowchart of a method for building a development environment for a web application provided by this application;
[0037] Figure 3 It is a flowchart of another method for building a development environment for a web application provided by the present application;
[0038] Figure 4 This is a schematic diagram of a web application development environment construction process provided by this application;
[0039] Figure 5 It is a structural diagram of a device for building a development environment for a web application provided by the present application;
[0040] Figure 6 It is a structural schematic diagram of an electronic device provided by this application.
[0041] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0042] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0043] The terms "first", "second", etc. are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. In the description of the following embodiments, "multiple" means more than two, unless otherwise clearly and specifically defined.
[0044] In order to clearly understand the technical solution of the present application, the solution of the prior art is first introduced in detail.
[0045] Currently, when developing web applications, it is necessary to build a development environment, which is a series of software tools installed on a development device for the purpose of developing web applications.
[0046] In the related art, developers build a development environment on their own development devices and then develop web applications. However, the development environment built on the development device may have different operating systems from the actual production environment, which may cause problems that did not appear during testing after the application is launched.
[0047] In view of the problems existing in the prior art, the inventor of the present application has found in the research that in order to solve the problem, the basic image corresponding to the production environment can be directly constructed in the process of constructing the development environment, thereby ensuring that the project image corresponding to the development project can be based on the production environment, avoiding the occurrence of additional testing problems caused by the inconsistency between the development environment and the production environment. Specifically, the present application provides a solution for building a development environment for a web application. For the web application to be developed, the basic image corresponding to the production environment of the web application is directly constructed, so that the project image corresponding to the development project of the web application can be constructed on the basic image, thereby ensuring that the local development environment is consistent with the production environment, avoiding the occurrence of additional testing problems caused by the inconsistency between the development environment and the production environment. On this basis, by mounting the directory where the code files corresponding to the development project are stored to the directory of the container corresponding to the project image, the development project can be deployed in the container so that the development project can be started in the container later, and by mapping the port of the container corresponding to the project image to the local port, the local can access the development project by accessing the local port.
[0048] The following is an introduction to the application scenarios of the method for building a development environment for a web application provided in an embodiment of the present application.
[0049] Figure 1 is a schematic diagram of an application scenario provided by this application. Figure 1 As shown, the application scenario includes: development device 1. Among them, development device 1 is a device used by developers of web applications. Developers build a development environment for web applications on development device 1, and then develop web applications based on the development environment. In this embodiment, for the web application to be developed, a basic image corresponding to the production environment of the web application and a project image corresponding to the development project of the web application are respectively constructed, and then containers corresponding to the basic image and the project image are created respectively, and then the directory storing the code files corresponding to the development project is mounted to the directory of the container corresponding to the project image to install the development project in the container; then the port of the container corresponding to the project image is mapped to the local port, so that the local can access the development project by accessing the local port.
[0050] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0051] Figure 2 The flowchart of the method for building a development environment for a web application provided by the present application is shown in FIG. The execution subject of the method for building a development environment for a web application provided by the present application is a device for building a development environment for a web application, and the device for building a development environment for a web application is integrated in a development device. Figure 2 As shown, the method for building a development environment for a web application provided in this embodiment includes the following steps:
[0052] Step S101 , for a web application to be developed, a basic image corresponding to a production environment of the web application and a project image corresponding to a development project of the web application are respectively constructed; the project image is constructed on the basic image.
[0053] Wherein, the web application can be any web application to be developed. Before developing the web application, the development environment of the web application is first built. In this embodiment, the development device executes the method for building a development environment for the web application provided in this application under the triggering of the environment building instruction. Wherein, the environment building instruction can be manually triggered by the user or automatically triggered, such as a timed trigger. The environment building instruction is used to indicate the development environment for building the web application, and the user can be a developer of the web application or other person who can trigger the environment building instruction. Exemplarily, the development device can display a development page, and an environment building button is displayed on the development page. When the user wants to develop a web application, the environment building button can be triggered, so that the development device responds to the environment building button being triggered and determines that the environment building instruction is detected. Exemplarily, the user can also set an automated task through the development device in advance, and the automated task is used to trigger the environment building instruction at a scheduled time, so that the development device executes the automated task to achieve the triggering of the environment building instruction.
[0054] The production environment refers to the operating system where the web application is installed after it goes online, such as Windows, macOS, or Linux. The development environment refers to the operating system where the web application is developed. Since the development environment and the production environment are inconsistent, problems that did not occur during development may occur after the application goes online. Therefore, in this step, the base image corresponding to the production environment is directly built. Since the project image corresponding to the development project is built on the base image, the development environment and the production environment are consistent.
[0055] Step S102: Create containers corresponding to the base image and the project image respectively.
[0056] In this embodiment, after the base image and the project image are built, containers corresponding to the images are created so that the web application runs in the container.
[0057] Step S103 , mount the directory storing the code files corresponding to the development project to the directory of the container corresponding to the project image, so as to install the development project in the container.
[0058] The directory storing the code files corresponding to the development project refers to the local folder storing the code files. The development project is installed in the container by mounting the local folder to the directory of the container corresponding to the project image, so as to facilitate access to the development project in the container.
[0059] Step S104, mapping the port of the container corresponding to the project image to the local port, so that the local can access the development project by accessing the local port.
[0060] The port of the container corresponding to the project image can be regarded as the web port running after the development project is started. Then, by mapping the port to the local port, the local can access the development project by accessing the local port. For example, the local port is port 3000.
[0061] This embodiment provides a solution for building a development environment for web applications. For the web application to be developed, a basic image corresponding to the production environment of the web application is directly built, so that the project image corresponding to the development project of the web application can be built on the basic image, thereby ensuring that the local development environment is consistent with the production environment, avoiding the occurrence of additional testing problems caused by the inconsistency between the development environment and the production environment. On this basis, by mounting the directory storing the code files corresponding to the development project to the directory of the container corresponding to the project image, the development project can be deployed in the container, so that the development project can be started in the container later, and by mapping the port of the container corresponding to the project image to the local port, the local can access the development project by accessing the local port.
[0062] Figure 3 It is a flowchart of another method for building a development environment for a web application provided by this application, such as Figure 3 As shown, based on the previous embodiment, this embodiment refines step S101. The method for building a development environment for a web application provided in this embodiment includes the following steps:
[0063] Step S201, for the web application to be developed, obtain a project startup script corresponding to the web application; the project startup script includes build commands corresponding to the basic image corresponding to the production environment of the web application and the project image corresponding to the development project of the web application.
[0064] In one possible design, the development device stores a project startup script corresponding to the web application, and when triggered by the environment building instruction, the development device obtains the project startup script. The user writes the project startup script in advance and stores the project startup script through the development device. The build command corresponding to the image can be implemented according to the command provided by Docker (application container engine) in the relevant technology, which will not be repeated here.
[0065] Step S202, executing the build commands corresponding to each image to build a base image and a project image; the project image is built on the base image.
[0066] After the project startup script is obtained, the project startup script is executed to build the image.
[0067] In this embodiment, steps S201-S202 provide a specific implementation method for building a base image corresponding to the production environment of the web application and a project image corresponding to the development project of the web application for the web application to be developed. By obtaining the project startup script corresponding to the web application and executing the build command in the project startup script, the automatic construction of the base image corresponding to the production environment of the web application and the project image corresponding to the development project of the web application is achieved, and the construction efficiency is high.
[0068] In a possible design, in addition to the build command, the project startup script also includes image parameters corresponding to the base image and the project image respectively; the image parameters include the startup command, environment variables, port, and username and password; the image parameters are used to start the corresponding image. Among them, the specific image parameters can be set according to user needs, and this embodiment does not limit this.
[0069] In this embodiment, by further configuring the image parameters in the project startup script, data support is provided for the startup and processing of subsequent images.
[0070] Step S203: Create containers corresponding to the base image and the project image respectively.
[0071] In this embodiment, after the base image and the project image are built, containers corresponding to the images are created so that the web application runs in the container.
[0072] In a possible design, the implementation method of step S203 includes: using the application container engine Docker to create containers corresponding to the basic image and the project image respectively.
[0073] Each image has its own corresponding container, and the startup or creation of the container depends on the image. The container is a running instance created by the image. Each container can be started, started, stopped and deleted. At the same time, the containers are isolated from each other to ensure the safety of the application during operation.
[0074] In this embodiment, the image is a read-only file containing the environment and code that the program must depend on to run, and a container corresponding to the image is created to provide a running environment for the development project of the web application.
[0075] Step S204 , mount the directory storing the code files corresponding to the development project to the directory of the container corresponding to the project image, so as to install the development project in the container.
[0076] Step S205, mapping the port of the container corresponding to the project image to the local port, so that the local can access the development project by accessing the local port.
[0077] In this embodiment, the implementation of step S204-step S205 is the same as the implementation of step S103-step S104 in the previous embodiment, and will not be repeated here.
[0078] In one possible design, the method for building a development environment for a web application provided in this application further includes the following steps:
[0079] According to the project development instructions triggered by the user, the container corresponding to the project image is started to start the development project.
[0080] The project development instruction is manually triggered by the user. The project development instruction is used to trigger the start of the development project. Exemplarily, the development device can display a development page, and a project development button is also displayed in the development page. When the user wants to start the development project, the project development button can be triggered, so that the development device determines that the project development instruction is detected in response to the project development button being triggered.
[0081] In this embodiment, after creating a container corresponding to the project image, the user can trigger the project development instruction as needed, thereby triggering the development device to start the container corresponding to the project image, thereby starting the development project. In this way, the user can operate the development project to realize the development of the web application. The project startup is more flexible and the user experience is better.
[0082] Exemplarily, the project development instructions may also be triggered automatically, such as by timing. Accordingly, the user sets an automation task through the development device in advance. The automation task is used to trigger the project development instructions by timing, so that the development device executes the automation task to trigger the project development instructions.
[0083] In this embodiment, the project startup script may also include relevant commands for instructing steps S203 to S205, so that the development device can build a development environment by executing the project startup script. In a possible design, the method for building a development environment for a web application provided in this application also includes the following steps:
[0084] When receiving a build request sent by a device other than the local device, a project startup script is sent to the device so that the device builds a development environment corresponding to the web application according to the project startup script.
[0085] Among them, other devices refer to other devices other than this machine. In the actual application development process, a development project is mostly developed by a project team, which includes multiple developers. Then, when a new developer joins the project team, the new developer needs to build the development environment through his own development device. In this case, in order to improve the building efficiency, the new developer can control his own development device to send a building request to the development devices of other developers in the group. When the development device receives the building request, it can obtain the local project startup script and send the project startup script to the device that sent the building request, so that the development device used by the new developer can execute the project startup script after receiving the project startup script to build the development environment.
[0086] In this embodiment, the project startup script is transferred through data interaction between different development devices, so that the development device only needs to execute the project startup script to build the development environment, thereby improving the building efficiency.
[0087] Figure 4 This is a schematic diagram of a web application development environment construction process provided by this application, such as Figure 4 As shown, vscode (a lightweight integrated development environment) is deployed locally, and webedee (an online integrated development environment) is deployed by Docker. vscode exposes the port to webedee, and then the source code is mounted locally to docker as a storage volume.
[0088] In the prior art, due to the increasing number of dependencies on web application development, there are also a variety of local development environments. In order to adapt to different local environments, many complex configurations have been made, resulting in increasing maintenance costs. When new developers join the project development, they often spend a lot of time to install the development environment first, making it difficult to iterate the development of business functions in the first place. As a result, when the project is on schedule, developers seconded from outside cannot directly improve development efficiency. In addition, because there are dependencies between company projects, it is impossible to link to the environment of other projects during local debugging for various reasons. It is necessary to wait for the developers of other projects to prepare the relevant environment. In addition, the development environment is also heavily dependent on the network environment to access other projects. For example, the database and other applications that cannot be linked to the test due to network reasons, and the local installation of databases and other applications is very time-consuming and complex to configure, which creates a lot of uncertainty. If an error occurs in one place, a lot of time will be wasted.
[0089] The present application provides a solution for building a development environment for web applications. For the web application to be developed, a basic image corresponding to the production environment of the web application is directly built, so that the project image corresponding to the development project of the web application can be built on the basic image, thereby ensuring that the local development environment is consistent with the production environment, avoiding the occurrence of additional testing problems caused by the inconsistency between the development environment and the production environment. On this basis, by executing the project startup script, it is convenient for new developers to build a development environment, and if they want to connect to the environment of other projects, they can do so in a mirrored manner, thereby reducing the difficulty of linking other environments.
[0090] Figure 5 It is a structural diagram of a device for building a development environment for a web application provided by the present application, such as Figure 5 As shown, in this embodiment, the web application development environment construction device 300 can be set in the development device, and the web application development environment construction device 300 includes:
[0091] A construction module 301 is used to construct a basic image corresponding to the production environment of the web application and a project image corresponding to the development project of the web application for the web application to be developed; the project image is constructed on the basic image;
[0092] A creation module 302 is used to create containers corresponding to the base image and the project image respectively;
[0093] The mounting module 303 is used to mount the directory storing the code files corresponding to the development project to the directory of the container corresponding to the project image, so as to install the development project in the container;
[0094] The mapping module 304 is used to map the port of the container corresponding to the project image to the local port, so that the local can access the development project by accessing the local port.
[0095] Optionally, the construction module 301 includes:
[0096] Get the submodule, which is used to get the project startup script corresponding to the web application; the project startup script contains the build commands corresponding to each image;
[0097] The execution submodule is used to execute the build commands corresponding to each image to build the base image and project image.
[0098] Optionally, the project startup script also includes image parameters corresponding to the base image and the project image respectively; the image parameters include a startup command, environment variables, port, and user name and password; the image parameters are used to start the corresponding image.
[0099] Optionally, the apparatus 300 further includes:
[0100] The sending module is used to send a project startup script to the device when receiving a building request sent by other devices other than the local device, so that the device builds the development environment corresponding to the web application according to the project startup script.
[0101] Optionally, the creation module 302 includes:
[0102] Create a submodule to use the application container engine Docker to create containers corresponding to the base image and project image.
[0103] Optionally, the apparatus 300 includes:
[0104] The startup module is used to start the container corresponding to the project image according to the project development instruction triggered by the user to start the development project.
[0105] The web application development environment building device provided in this embodiment can execute the technical solution of the corresponding method embodiment. Its implementation principle and technical effect are similar to those of the corresponding method embodiment, which will not be repeated here.
[0106] The present application embodiment also provides a development device, which can be provided as an electronic device. The electronic device is intended to be various forms of digital computers, such as mobile phones, notebook computers, laptop computers, desktop computers, workstations, personal digital assistants and other suitable computers.
[0107] Figure 6 Schematic diagram of the structure of an electronic device provided by this application. Figure 6 As shown, the electronic device 400 includes: a processor 401 and a memory 402 communicatively connected to the processor 401 .
[0108] The memory 402 stores computer-executable instructions; the processor 401 executes the computer-executable instructions stored in the memory 402 to implement the method for building a development environment for a web application provided in the present application.
[0109] In the embodiment of the present application, the memory 402 and the processor 401 are connected via a bus. The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0110] The components, their connections and relationships, and their functions shown herein are only examples and are not intended to limit the implementation of the present application described and / or required herein. The various components are interconnected using different buses and can be installed on a common motherboard or in other ways as needed.
[0111] In an exemplary embodiment, a computer-readable storage medium is also provided, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the method for building a development environment for a web application provided in the present application.
[0112] In an exemplary embodiment, a computer program product is also provided, including computer-executable instructions. When the computer-executable instructions in the computer program product are executed by a processor, they are used to implement the method for building a development environment for a web application provided in the present application.
[0113] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.
[0114] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0115] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.
[0116] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application may be integrated into one unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.
[0117] If the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. Unless otherwise specified, the processor may be any appropriate hardware processor, such as a central processing unit (CPU), a graphics processing unit (GPU), an application specific integrated circuit (ASIC), a digital signal processor (DSP), a programmable logic device (PLD), a field programmable gate array (FPGA), a controller, a microcontroller, a microprocessor or other electronic components. Unless otherwise specified, the memory may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as a USB flash drive, random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), enhanced dynamic random access memory (EDRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), resistive random access memory (RRAM), high-bandwidth memory HBM (High-BandwidthMemory), hybrid memory cube HMC (Hybrid Memory Cube), magnetic storage, flash memory, magnetic disk, optical disk, mobile hard disk or disk, etc.
[0118] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the whole or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the methods of each embodiment of the present application.
[0119] In the above embodiments, the description of each embodiment has its own emphasis. For the part not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0120] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0121] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A method for building a development environment for a web application, characterized in that: The method comprises: For a web application to be developed, respectively building a base image corresponding to the production environment of the web application and a project image corresponding to the development project of the web application; the project image is built on the base image; Create containers corresponding to the base image and the project image respectively; Mounting a directory storing code files corresponding to the development project to a directory of a container corresponding to the project image, so as to install the development project in the container; The port of the container corresponding to the project image is mapped to the local port, so that the local can access the development project by accessing the local port.
2. The method according to claim 1, characterized in that The step of respectively building a basic image corresponding to the production environment of the web application and a project image corresponding to the development project of the web application for the web application to be developed includes: Obtain a project startup script corresponding to the web application; the project startup script includes build commands corresponding to each of the images; Execute the build commands corresponding to the images to build the base image and the project image.
3. The method according to claim 2, characterized in that The project startup script also includes image parameters corresponding to the base image and the project image respectively; the image parameters include a startup command, environment variables, port, and username and password; the image parameters are used to start the corresponding image.
4. The method according to claim 2, characterized in that: The method further comprises: When receiving a building request sent by a device other than a local device, the project startup script is sent to the device, so that the device builds a development environment corresponding to the web application according to the project startup script.
5. The method according to claim 1, characterized in that The creating containers corresponding to the base image and the project image respectively includes: The application container engine Docker is used to create containers corresponding to the basic image and the project image respectively.
6. The method according to claim 1, characterized in that The method further comprises: According to the project development instruction triggered by the user, the container corresponding to the project image is started to start the development project.
7. A device for building a development environment for a web application, characterized in that: include: A construction module, used to respectively construct a base image corresponding to the production environment of the web application to be developed and a project image corresponding to the development project of the web application; The project image is built on the base image; A creation module, used to create containers corresponding to the base image and the project image respectively; A mounting module, used to mount the directory storing the code files corresponding to the development project to the directory of the container corresponding to the project image, so as to install the development project in the container; A mapping module is used to map the port of the container corresponding to the project image to a local port, so that the development project can be accessed locally by accessing the local port.
8. The device according to claim 7, characterized in that The building blocks include: An acquisition submodule is used to acquire a project startup script corresponding to the web application; the project startup script includes a build command corresponding to each of the images; The execution submodule is used to execute the build commands corresponding to each of the images to build the base image and the project image.
9. An electronic device, characterized in that: include: A processor and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method for building a development environment for a web application according to any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method for building a development environment for a web application according to any one of claims 1 to 6.