Online compiling and packaging method, system and equipment and storage medium
By automating the packaging process within Docker containers, various problems in packaging and deployment in a front-end/back-end separation architecture are solved, achieving an efficient and reliable compilation and packaging method and system that supports multiple platforms and self-updates, thereby improving software delivery efficiency and quality.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- THE 711TH RES INST OF CHINA STATE SHIPBUILDING CORP
- Filing Date
- 2026-01-09
- Publication Date
- 2026-05-05
AI Technical Summary
Existing technologies suffer from problems such as fragmented processes, excessive manual intervention, strong environmental dependence, lack of unified management interface, insufficient multi-platform support, lack of self-updating capability, insufficient isolation of build environment, inconvenient management of build artifacts, and lack of standardized processes during the packaging and deployment of front-end and back-end separation architectures, resulting in low efficiency and poor consistency.
This invention provides an online compilation and packaging method and system. By building containers in Docker containers, the packaging process is automated, including pulling remote code, executing preset packaging and compilation scripts, generating packaging artifacts for front-end and back-end projects, and providing a web interface operation. It supports multiple packaging types and self-updating mechanisms to ensure environment consistency and centralized management of build artifacts.
It improves packaging efficiency and automation, increases build success rate, solves environment dependency issues, shortens build time, reduces service interruption time, and enables centralized management and enterprise-level standardization of build artifacts, thus lowering the technical threshold.
Smart Images

Figure CN121979534A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of industrial Internet of Things (IoT) technology, specifically to online compilation and packaging methods, systems, devices, and storage media. Background Technology
[0002] With the widespread adoption of front-end / back-end separation architectures in modern web systems, the deployment and release process has become more complex. Deploying front-end / back-end separation projects typically requires developers to manually perform multiple independent steps, including front-end compilation, resource copying, and back-end packaging. This process is not only inefficient but also prone to build failures due to environmental differences. Therefore, it is necessary to provide a reliable compilation and packaging solution suitable for front-end / back-end separation architectures. Summary of the Invention
[0003] This invention provides an online compilation and packaging method, system, device, and storage medium to offer a reliable compilation and packaging method suitable for front-end and back-end separation architectures.
[0004] Firstly, an online compilation and packaging method is provided, applicable to a front-end / back-end separation architecture, which includes front-end and back-end projects; the method includes: Get the packaging task request triggered by the user; Build a container based on the packaging task request; Pull target code from a remote code repository into the container; the target code is the latest code in the remote code repository; Within the container, a pre-defined packaging and compilation script is executed based on the packaging task request and the target code to generate the packaging artifacts corresponding to the front-end project and / or the back-end project.
[0005] In some embodiments, a preset packaging and compilation script is executed based on the packaging task request and the target code, including: Determine the packaging type based on the packaging task request; Pass the packaging type as a command-line argument to the preset packaging and compilation script; Executes a pre-defined packaging and compilation script based on command-line arguments and target code.
[0006] In some embodiments, the packaging type includes at least one of Electron client packaging and JAR package packaging.
[0007] In some embodiments, command-line parameters include packaging a first application and packaging a second application; Execute a pre-defined packaging and compilation script based on command-line arguments and target code, including: If the command-line argument is to package the first application, execute the first packaging logic; If the command-line argument is to package a second application, execute the second packaging logic.
[0008] In some embodiments, the execution of the first packaging logic includes: Retrieve the front-end code from the front-end project; Then, the following steps are executed sequentially: installing front-end dependencies, compiling the front-end, executing the first packaging, and collecting client files to generate the first packaged artifact.
[0009] In some embodiments, the second packaging logic is executed, including: Retrieve the front-end code from the front-end project and the back-end code from the back-end project; Then, the installation of front-end dependencies, front-end compilation, and execution of the second packaging are performed sequentially to generate the second packaged artifact.
[0010] In some embodiments, performing a second packaging includes: moving the distribution directory to the backend directory, backend packaging, collecting JARs, and configuration.
[0011] In some embodiments, packaging the first application is packaging an Electron application, and packaging the second application is packaging a Web application.
[0012] Secondly, an online compilation and packaging system is also provided, applicable to a front-end / back-end separation architecture, which includes front-end projects and back-end projects; the system includes: The acquisition module is used to acquire user-triggered packaging task requests; The build module is used to build containers based on packaging task requests; The pull module is used to pull target code from a remote code repository into the container; the target code is the latest code in the remote code repository. The generation module is used to execute a preset packaging and compilation script in the container based on the packaging task request and the target code to generate the packaging artifacts corresponding to the front-end project and / or the back-end project.
[0013] Thirdly, an electronic device is also provided, including a memory and a processor, wherein a computer program is stored in the memory, and the computer program, when executed by the processor, implements the method described in the first aspect.
[0014] Fourthly, a computer-readable storage medium is also provided, on which a computer program is stored, the computer program being loaded by a processor to perform the steps of the method described in the first aspect.
[0015] Beneficial Effects: This application provides an online compilation and packaging method, system, device, and storage medium. The online compilation and packaging method includes: obtaining a packaging task request triggered by a user; constructing a container based on the packaging task request; pulling target code from a remote code repository into the container; wherein the target code is the latest code in the remote code repository; and executing a preset packaging and compilation script in the container according to the packaging task request and the target code to generate packaging artifacts corresponding to the front-end project and / or the back-end project. The online compilation and packaging method provided by this application constructs a container based on a user-triggered packaging task request and automatically performs compilation and packaging within the container, reducing manual intervention and improving the efficiency and automation of compilation and packaging. Therefore, it provides a reliable compilation and packaging method suitable for front-end and back-end separation architectures. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a flowchart of an online compilation and packaging method provided in the embodiments of this application; Figure 2 This is a schematic diagram of the online packaging and compilation script workflow provided in the embodiments of this application; Figure 3 This is a schematic diagram of the principle structure of an online compilation and packaging system provided in the embodiments of this application; Figure 4 This is a schematic diagram of the structure of an online compilation and packaging system provided in the embodiments of this application; Figure 5 This is a schematic diagram of the overall operation process of an online compilation and packaging system provided in the embodiments of this application. Detailed Implementation
[0018] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0019] In the description of this application, it should be understood that the terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientation or positional relationships based on the orientation or positional relationships shown in the accompanying drawings, are used only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this application. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, features defined with "first" and "second" may explicitly or implicitly include one or more of the stated features. In the description of this application, "a plurality of" means two or more, unless otherwise explicitly specified.
[0020] "A and / or B" includes the following three combinations: A only, B only, and a combination of A and B.
[0021] The use of "applies to" or "configured to" in this application implies open and inclusive language, which does not exclude the applicability to or configuration to devices performing additional tasks or steps. Additionally, the use of "based on" implies openness and inclusivity, because processes, steps, calculations, or other actions "based on" one or more of the stated conditions or values may in practice be based on additional conditions or values beyond those stated.
[0022] In this application, the term "exemplary" is used to mean "used as an example, illustration, or description." Any embodiment described as "exemplary" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is provided to enable any person skilled in the art to make and use this application. Details are set forth in the following description for purposes of explanation. It should be understood that those skilled in the art will recognize that this application can be made without using these specific details. In other instances, well-known structures and processes are not described in detail to avoid obscuring the description of this application with unnecessary detail. Therefore, this application is not intended to be limited to the embodiments shown, but is consistent with the broadest scope of the principles and features disclosed in this application.
[0023] The applicant's research revealed that with the widespread adoption of front-end / back-end separation architectures in modern web systems, the deployment and release process has become increasingly complex. Typically, in a front-end / back-end separation project, the front-end is responsible for building the user interface, using frameworks such as Vue and React to generate static resource files (Hypertext Markup Language (HTML), JavaScript (JS), and Cascading Style Sheets (CSS)). The back-end uses frameworks such as Java (Spring Boot) to provide interface services and overall business logic support. Under this architecture, system deployment often requires packaging and integrating the front-end and back-end separately to form a complete, runnable system. For example, front-end static files might be copied to the back-end static directory, and then a build tool might be used to generate an executable package (such as a JAR file) containing all the content. Furthermore, some systems also require building a local running version, such as an Electron client, for offline operation and to enhance the user experience.
[0024] In traditional development workflows, packaging and deploying a front-end / back-end separated project typically involves the following steps: First, front-end developers independently compile the front-end code, generating static resource files. Then, they manually copy the compiled front-end artifacts to a designated directory in the back-end project. Next, back-end developers execute the back-end project packaging command to generate the final deployment package. Finally, deployment personnel upload the packaged artifacts to the server for deployment.
[0025] In related technologies, there are several main solutions for packaging Java Web applications. The first is to use Maven or Gradle plugins to automatically copy resources to the backend static directory after frontend compilation. The second is to use Continuous Integration (CI) / Continuous Deployment (CD) tools (such as Jenkins) to connect the frontend and backend compilation processes. The third is to manually perform the frontend and backend compilation and resource integration steps.
[0026] For Electron client packaging, common practices include: developers executing Electron packaging commands locally; automating the packaging process through scripts but lacking a unified management interface; and using third-party cloud build services but failing to integrate with internal enterprise systems.
[0027] Through research and analysis of relevant technologies, the following main problems were found in the current solution: First, the process is fragmented and requires a lot of manual intervention: traditional methods require developers to manually execute multiple independent steps, which is prone to errors and inefficient. The front-end and back-end compilation processes are separated, lacking unified automated process control.
[0028] Second, it is highly dependent on the environment: existing packaging solutions typically rely on the local environment configuration of developers, making it difficult to guarantee the consistency of packaging results across different machines. Environmental differences may lead to packaging failures or inconsistent outputs.
[0029] Third, there is a lack of a unified management interface: most packaging solutions need to be executed through command lines or scattered CI / CD tools, without providing an intuitive web interface, making it difficult for non-technical personnel to participate in the packaging process.
[0030] Fourth, insufficient multi-platform support: Existing systems often only support a single packaging type (such as only supporting JAR packages or only supporting Electron), lacking integrated solutions that support multiple packaging types simultaneously.
[0031] Fifth, lack of self-updating capability: Traditional JAR packages require manual stopping and restarting after deployment, which cannot achieve seamless self-updating, resulting in extended service interruption time.
[0032] Sixth, insufficient isolation of the build environment: Most existing solutions execute the build directly on the host environment or CI server, which may lead to build failure due to environmental pollution. There is a lack of an isolated environment like Docker containers to ensure build consistency.
[0033] Seventh, build artifact management is inconvenient: build artifacts generated in the traditional way are scattered in different locations, lacking a centralized management and download mechanism, which is not conducive to version control and release management.
[0034] Eighth, there is a lack of standardized processes: the packaging processes for various projects in the existing technology vary greatly, making it difficult to form a unified enterprise standard, which increases maintenance costs and learning costs for new employees.
[0035] In summary, existing packaging and building technologies still have significant shortcomings in terms of convenience, user-friendliness, multi-platform compatibility, and self-updating capabilities.
[0036] In view of this, embodiments of this application provide an online compilation and packaging method, system, device, and storage medium. The online compilation and packaging method provided in this application constructs a container based on a user-triggered packaging task request and automatically performs compilation and packaging within the container, reducing manual intervention and improving the efficiency and automation of compilation and packaging. Thus, it can provide a reliable compilation and packaging method suitable for front-end and back-end separation architectures.
[0037] Figure 1This is a flowchart illustrating an online compilation and packaging method provided in this embodiment. On one hand, this embodiment provides an online compilation and packaging method applicable to front-end and back-end separated architectures, enabling online compilation and packaging of the front-end and back-end separated architecture and improving the reliability of the compilation and packaging process. This method can be executed by an online compilation and packaging system, which can be implemented in software and / or hardware, and can be configured in the processor or server (e.g., an online compilation and packaging server) of the front-end and back-end separated architecture. The front-end and back-end separated architecture consists of a front-end project and a back-end project. In this application, the front-end project is developed based on the Vue framework, and the back-end project is developed using the Spring Boot framework. Figure 1 As shown, the method includes the following steps: Step 110: Obtain the packaging task request triggered by the user.
[0038] A packaging task request is a request issued by a user when they need to package a package. For example, a user selects a packaging type and submits a packaging task request through a web interface.
[0039] Step 120: Build the container based on the packaging task request.
[0040] The containers are built using a dedicated Docker container.
[0041] The Docker container in this application is a compilation and packaging environment. The cloned code repository is a local repository cloned from a remote code repository, containing the code submitted by the developer. The packaged artifact is the software that deployment and operation personnel need to install and deploy on the target machine.
[0042] Step 130: Pull the target code from the remote code repository into the container.
[0043] The target code is the latest code in the remote code repository. Users submit new feature requests and identify problems based on their usage, and developers modify the code according to user feedback before committing it to the remote code repository. When a build request is received, pulling the latest code is done to generate a new build artifact that meets the user's needs.
[0044] The remote code repository is a Git repository. A Git repository stores the code developed and designed by software engineers. For example, a software engineer completes software development on their work computer and uploads the code to a Git repository.
[0045] Step 140: In the container, execute the preset packaging and compilation script according to the packaging task request and the target code to generate the packaging artifacts corresponding to the front-end project and / or the back-end project.
[0046] The container stores a pre-defined packaging and compilation script.
[0047] Specifically, after developers complete the development of a new feature, they commit the code to a remote code repository. Then, they manually trigger the online packaging operation of the system. The server starts a Docker container, pulls the latest code from the remote code repository into a local repository within the Docker container, executes the packaging and compilation script, and the generated packaged artifacts are also in the Docker container. The development, packaging, and deployment of this application are decoupled. In contrast, the existing packaging process involves developers packaging the code on their own computers and handing it over to deployment and operations personnel. In this application, packaging and deployment are not done on the developer's computer but are moved online, allowing operations personnel to package the code as needed without relying on developers.
[0048] In some embodiments, within a container, executing a preset packaging and compilation script based on a packaging task request and target code includes: determining a packaging type based on the packaging task request; passing the packaging type as a command-line argument to the preset packaging and compilation script; and executing the preset packaging and compilation script based on the command-line argument and target code.
[0049] The packaging task request includes a field corresponding to the packaging type. Therefore, by identifying the corresponding field based on the content of the packaging task request, the packaging type of the request can be determined. For example, when sending an HTTP POST request, the type field in the request body specifies the type. When type is Jar, it indicates that a web application is being packaged; when type is Linux, it indicates that an Electron client under Linux is being packaged.
[0050] After receiving an HTTP request, the backend server starts a packaging script in a Docker container and passes the received packaging type as a command-line parameter to a preset packaging and compilation script. The preset packaging and compilation script packages different target artifacts according to the packaging type.
[0051] In some embodiments, the packaging type includes at least one of Electron client packaging and JAR package packaging.
[0052] In some embodiments, the command-line parameters include packaging a first application and packaging a second application; executing a preset packaging and compilation script based on the command-line parameters and target code includes: executing a first packaging logic when the command-line parameter is to package the first application; and executing a second packaging logic when the command-line parameter is to package the second application.
[0053] The packaging of the first application and the packaging of the second application are different. The first application can be packaged as an Electron client or a JAR file, and similarly, the second application can be packaged as a JAR file or an Electron client. The specific settings can be configured according to the actual situation, and no specific restrictions are made here.
[0054] In some embodiments, packaging the first application is packaging an Electron application, and packaging the second application is packaging a Web application.
[0055] For example, in this embodiment of the application, the packaging of the first application is an Electron application and the packaging of the second application is a Web application. This will not be repeated below.
[0056] In some embodiments, executing the first packaging logic includes: pulling the front-end code of the front-end project; and sequentially executing the following steps: installing front-end dependencies, compiling the front-end, executing the first packaging, and collecting client files to generate the first packaging artifact.
[0057] Specifically, the process involves obtaining the user-triggered packaging task request, determining the packaging type based on the request, and passing the packaging type as a command-line argument to the preset packaging and compilation script. The preset packaging and compilation script is then executed based on the command-line argument and the target code. Specifically, the preset packaging and compilation script executes different packaging logic depending on the passed command-line argument. For example, assuming the packaging type is Electron client packaging and the passed command-line argument is to package an Electron application, only the command to compile the front-end project into Electron will be executed, followed by sequentially installing front-end dependencies, compiling the front-end, executing the first packaging, and collecting client files to generate the first packaged artifact (i.e., the Electron executable program).
[0058] In some embodiments, executing the second packaging logic includes: pulling the front-end code of the front-end project and the back-end code of the back-end project; and sequentially executing the installation of front-end dependencies, front-end compilation, and execution of the second packaging to generate the second packaging artifact.
[0059] Specifically, the process involves obtaining the user-triggered packaging task request, determining the packaging type based on the request, and passing the packaging type as a command-line argument to the preset packaging and compilation script. The preset packaging and compilation script is then executed based on the command-line argument and the target code. Specifically, the preset packaging and compilation script executes different packaging logic depending on the passed command-line argument. For example, assuming the packaging type is JAR file packaging and the passed command-line argument is "package a web application," the logic for compiling the front-end project into static web files is executed first. Then, the static files are copied to the back-end project, and the back-end project is compiled into a JAR file (the second packaging artifact). This JAR file is a web application, including all the logic from both the front-end and back-end projects.
[0060] In some embodiments, performing a second packaging includes: moving the distribution directory to the backend directory, backend packaging, collecting JARs, and configuration.
[0061] It should be noted that after generating the final product (i.e., generating the first packaged product and the second packaged product), the process also includes cleaning up temporary files and marking as successful (i.e. marking the packaged compilation as successful).
[0062] Figure 2 This is a schematic diagram of the online packaging and compilation script workflow provided in the embodiments of this application. For an example, please refer to... Figure 2 The workflow of this online packaging and compilation script is as follows: After receiving a packaging task request triggered by the user, packaging begins. First, the environment is initialized, and the packaging type corresponding to the packaging task request is checked. If the packaging type is Electron client packaging, only the front-end code is fetched. Then, front-end dependencies are installed, and the front-end is compiled. After that, Electron packaging is executed. After Electron packaging, client files are collected to generate the final artifact, i.e., the first packaging artifact, the Electron executable program. Finally, temporary files are cleaned up, and the packaging and compilation are marked as successful.
[0063] If the packaging type is a JAR package, the frontend and backend code are fetched. Then, frontend dependencies are installed and the frontend is compiled. Afterward, the distribution directory (dist) is moved to the backend directory, the backend is packaged using Maven, and the JAR and configuration are collected to generate the final artifact, the second packaging artifact, the JAR package. Finally, temporary files are cleaned up, and the packaging and compilation are marked as successful. Maven is a project management and build tool primarily used for Java projects to compile and package Java code into a JAR package.
[0064] If the package type is found to be invalid, the process is marked as failed and the packaging and compilation process exits. Additionally, if frontend dependency installation fails or frontend compilation fails, both are marked as failed and the packaging and compilation process exits.
[0065] Figure 3 This is a schematic diagram illustrating the principle structure of an online compilation and packaging system provided in this application embodiment. On the other hand, this application embodiment provides an online compilation and packaging system applied to a front-end / back-end separation architecture, which includes a front-end project and a back-end project. Please refer to... Figure 3 The online compilation and packaging system 100 includes: an acquisition module 101 for acquiring a packaging task request triggered by a user; a build module 102 for building a container according to the packaging task request; a pull module 103 for pulling target code from a remote code repository into the container; wherein the target code is the latest code in the remote code repository; and a generation module 104 for executing a preset packaging and compilation script in the container according to the packaging task request and the target code to generate the packaging artifacts corresponding to the front-end project and / or the back-end project.
[0066] The technical solution of this application provides an online compilation and packaging system. By building a container according to the packaging task request triggered by the user, and automatically performing compilation and packaging within the container, manual intervention is reduced, and the efficiency and automation of compilation and packaging are improved. Thus, a reliable compilation and packaging method suitable for front-end and back-end separation architecture can be provided.
[0067] In some embodiments, the online compilation and packaging system further includes: a user interface, which provides a packaging type selection interface and a triggering interface for the packaging task request, as well as real-time recording and archiving of compilation and packaging.
[0068] The user interface includes web interfaces, etc.
[0069] In some embodiments, the generation module 104 is further configured to: Determine the packaging type based on the packaging task request; Pass the packaging type as a command-line argument to the preset packaging and compilation script; Executes a pre-defined packaging and compilation script based on command-line arguments and target code.
[0070] In some embodiments, the packaging type includes at least one of Electron client packaging and JAR package packaging.
[0071] In some embodiments, the command-line parameters include packaging a first application and packaging a second application; the generation module 104 is further configured to: If the command-line argument is to package the first application, execute the first packaging logic; If the command-line argument is to package a second application, execute the second packaging logic.
[0072] In some embodiments, the execution of the first packaging logic includes: Only fetch the front-end code of the front-end project; Then, the following steps are executed sequentially: installing front-end dependencies, compiling the front-end, executing the first packaging, and collecting client files to generate the first packaged artifact.
[0073] In some embodiments, the second packaging logic is executed, including: Retrieve the front-end code from the front-end project and the back-end code from the back-end project; Then, the installation of front-end dependencies, front-end compilation, and execution of the second packaging are performed sequentially to generate the second packaged artifact.
[0074] In some embodiments, performing a second packaging includes: moving the distribution directory to the backend directory, backend packaging, collecting JARs, and configuration.
[0075] In some embodiments, packaging the first application is packaging an Electron application, and packaging the second application is packaging a Web application.
[0076] Figure 4 This is a schematic diagram of the structure of an online compilation and packaging system provided in an embodiment of this application. For an example, please refer to [link / reference needed]. Figure 4 The online compilation and packaging system of this application adopts a front-end and back-end separation architecture, providing a standardized build environment through Docker containers and realizing an automated packaging process for multiple platforms. The entire system involves four parties: software development engineers complete software development on their work computers and upload the code to a Git repository; the online compilation and packaging server pulls the code from the Git repository and compiles and packages it after the user triggers the packaging task. After packaging, software engineers can download the target file for debugging via a web page, and operations and maintenance personnel can download the target file for one-click deployment.
[0077] The core of the online compilation and packaging system provided in this application lies in its intelligent build controller (e.g., a Linux compilation and packaging script), which can automatically execute differentiated processes based on the packaging type selected by the user. For example, for JAR package packaging, the system will sequentially complete the front-end code retrieval, dependency installation, front-end compilation, resource copying to the back-end directory, and final Maven packaging within the container. For Electron client packaging, it executes (i.e., the Linux compilation and packaging script is executed in a Docker container) the Electron build command specific to the platform. This design is based on the theory of environment isolation and the principle of continuous delivery, ensuring the consistency of the build environment through containerization technology, while following CI / CD best practices to achieve full automation of the build process.
[0078] Figure 5 This is a schematic diagram illustrating the overall operation flow of an online compilation and packaging system provided in this application embodiment. For an example, please refer to [link to example]. Figure 5When the online build and package system is working, the user first selects the packaging type and submits a packaging task request through a web interface. Upon receiving the request, the backend service (i.e., the online build and package server) starts a dedicated Docker build container. Inside the container, the system executes a predefined build script (i.e., a preset packaging and build script), which dynamically adjusts the build process based on the packaging type. During the build process, all operation logs and artifacts are recorded and archived in real time, and the build status is fed back to the user interface via HTTP in real time.
[0079] Compared with related technologies, the online compilation and packaging system provided in this application provides significant improvements. First, it fully automates the packaging process, which originally required multiple manual steps, increasing the build success rate from an average of 85% to over 99%. For example, in tests, using the original manual packaging method and when developers packaged themselves, 5 out of 18 packaging failures were due to configuration or environment software installation issues. However, using the automated packaging (i.e., online compilation and packaging) provided in this application, only one out of 112 packaging failures was due to insufficient server disk resources. Second, the environment isolation provided by Docker containers completely solves the environment dependency problem of "it can be built on my machine." Third, the unified web management interface allows the packaging of web applications and Electron clients to be completed on the same platform, reducing the average build time by 40%. For example, when packaging manually, the average packaging time for developers on their own computers was 327 seconds; using the automated packaging (i.e., online compilation and packaging) provided in this application, the average packaging time is reduced to 206 seconds. Fourth, the innovative self-update mechanism reduces service update time from minutes to seconds, significantly reducing service interruption time. Furthermore, the online compilation and packaging system of this application enables centralized management of build artifacts and complete context saving, greatly facilitating issue tracing and version management. From a team collaboration perspective, the system lowers the technical barrier to build deployment, allowing non-technical personnel to participate in the packaging process, while establishing enterprise-level build standards and reducing the onboarding time for newcomers from two days to two hours. These improvements overall enhance software delivery efficiency and quality, providing strong support for agile development environments.
[0080] In summary, the online compilation and packaging system provided in this application primarily addresses the technical challenges of fragmented multi-platform packaging processes, strong environment dependencies, and a lack of a unified management interface in traditional software development. For example, in related technologies, the packaging and deployment of front-end and back-end separated projects typically requires developers to manually execute multiple independent steps, including front-end compilation, resource copying, and back-end packaging. This process is not only inefficient but also prone to build failures due to environmental differences. Furthermore, existing packaging solutions often only target a single platform, lacking integrated solutions that simultaneously support web applications and Electron clients, and the management of build artifacts is fragmented, hindering version control and release management. Based on this, the online compilation and packaging system provided in this application enables users to trigger packaging tasks with a single click through a web page, supports both JAR packages and Electron clients for packaging, and supports automatic updates of currently running services, greatly improving the system's build efficiency and ease of use.
[0081] As a specific implementation method, the online compilation and packaging system is implemented as follows: First, Docker service and the Ubuntu image need to be installed on the target machine. After starting the corresponding container, essential tools such as Git, JDK17, Maven3, node.js, and pnpm are installed in the container. The container is started using the command `docker run -d -it --name qiyao-ubuntu --mount type=bind, source= / root / qiyao / docker_code, target= / home / code qiyao-ubuntu` (which starts a packaging container named qiyao-ubuntu in the background to begin packaging, and specifies file mapping, mapping the / home / code directory in Docker to the / root / qiyao / docker_code directory on the local machine, so that the local machine can obtain the packaged artifacts from / root / qiyao / docker_code after packaging is completed), mapping the local / root / qiyao / docker_code folder into the container. The docker_code folder contains the following files: docker-package.sh folder, qiyao-admin folder, qiyaoboot folder, and target folder. The docker-package.sh folder is the core, containing the core script logic for online compilation and packaging. The specific code is as follows: #! / bin / bash # Add the node command to the environment variables; PATH=$PATH: / root / .nvm / versions / node / v20.18.1 / bin # Get the package type from the command-line arguments; the first argument is the package type. PKG_TYPE=$1 # The second parameter of the command line is the packaging remarks, which is obtained by the front end. It usually contains the purpose of this packaging and forms the management of the packaged version. PKG_MESSAGE=$2 # The root directory of the local code repository, where both front-end and back-end code are located; CODE_ROOT= / home / code # Set the path to the front-end code folder; QIYAOBOOT=$CODE_ROOT / qiyaoboot # Set the path to the backend code folder; QIYAO_ADMIN=$CODE_ROOT / qiyao-admin # Set the root folder path for storing the generated target product; TARGET_ROOT=$CODE_ROOT / target # Current timestamp, usually used as the version number of the target artifact; current_time=$(date +"%y%m%d%H%M%S") # The final folder path where the target product is stored; TARGET_DIR=$TARGET_ROOT / $current_time # A flag indicating whether packaging is in progress; RUNNING_FLAG=$TARGET_ROOT / running # Indicator of whether the packaging was successful; SUCCESS_FILE=$TARGET_DIR / success # Whether the packaging failed; FAIL_FILE=$TARGET_DIR / fail # The regular log output file during the packaging process; OUTPUT_FILE=$TARGET_DIR / package.log # Error log output file during the packaging process; ERROR_FILE=$TARGET_DIR / error.log # Function to execute after an error occurs; fail_exit() { # Create execution flag; touch $FAIL_FILE # Remove the "Packaging in progress" flag; rm $RUNNING_FLAG # Exit the packaging task; exit 1 } # Create the root directory to store the packaged files; if [ -d "$TARGET_ROOT" ]; then # If the root directory already exists, print the following information; echo "Directory $TARGET_ROOT already exists" else # Create the root directory if it does not exist; mkdir -p "$TARGET_ROOT fi # Create a flag indicating that packaging is in progress; touch $RUNNING_FLAG # Create the folder containing the packaged files; mkdir -p $TARGET_DIR # Record the packaging start information to the log; echo "$(date +'%H:%M:%S') Create folder $TARGET_DIR">>$OUTPUT_FILE # Record the packaging notes to a file; echo $PKG_MESSAGE>$TARGET_DIR / message.txt # Create different folders depending on the packaging type; if [ "$PKG_TYPE" = jar ]; then # Mark the packaged product as a Jar package; touch $TARGET_DIR / type_$PKG_TYPE elif [ "$PKG_TYPE" = linux ]; then # Mark the packaged output as Electron under Linux; touch $TARGET_DIR / type_$PKG_TYPE else # If the packaged output is not the default, output the error reason in the log and exit the packaging task; echo "$(date +'%H:%M:%S') Unsupported packaging type $PKG_TYPE">>$OUTPUT_FILE fail_exit fi # Print packaging information in the log; echo "$(date +'%H:%M:%S') Start packaging type ${PKG_TYPE}">>$OUTPUT_FILE # Front-end project; cd $QIYAO_ADMIN # Retrieve front-end code; git pull if [ $? -ne 0 ]; then # If the code fetch fails, check the logs and exit; echo "$(date +'%H:%M:%S') git pull failed to fetch the front-end project qiyao-admin">>$OUTPUT_FILE fail_exit else # Print packaging status; echo "$(date +'%H:%M:%S') git pull The front-end project qiyao-admin was successfully pulled">>$OUTPUT_FILE fi # Get the last commit ID from the front end; QIYAO_ADMIN_LAST_COMMIT=$(git log -1 --pretty=format:"%h") # Enter the package directory; cd $TARGET_DIR # Record the ID of the last commit of the packaged front-end project code; touch fe_$QIYAO_ADMIN_LAST_COMMIT if [ "$PKG_TYPE" = jar ]; then # Backend project; cd $QIYAOBOOT # Fetch backend code; git pull if [ $? -ne 0 ]; then # If fetching the backend code fails, print the error log and exit the packaging task; echo "$(date +'%H:%M:%S') git pull failed to fetch backend project qiyaoboot">>$OUTPUT_FILE fail_exit else # Print packaging status; echo "$(date +'%H:%M:%S') git pull The backend project qiyaoboot was successfully pulled">>$OUTPUT_FILE fi # Get the last commit ID of the backend code; QIYAOBOOT_LAST_COMMIT=$(git log -1 --pretty=format:"%h") cd $TARGET_DIR # Store submission information; touch be_$QIYAOBOOT_LAST_COMMIT fi # Navigate to the folder containing the front-end code repository; cd $QIYAO_ADMIN # Install frontend dependencies; npm install 2>>$ERROR_FILE if [ $? -ne 0 ]; then # If the front-end dependency installation fails, print the error log and exit the packaging task; echo "$(date +'%H:%M:%S') npm install failed to install frontend dependencies">>$OUTPUT_FILE fail_exit else # Print packaging status; echo "$(date +'%H:%M:%S') npm install frontend dependency installed successfully">>$OUTPUT_FILE fi # Compile the front end; if [ "$PKG_TYPE" = jar ]; then echo "$(date +'%H:%M:%S') Start compiling the front-end project...">>$OUTPUT_FILE # Perform front-end compilation; pnpm build-only 2>>$ERROR_FILE if [ $? -ne 0 ]; then # If the front-end compilation fails, print the error log and exit the packaging task; echo "$(date +'%H:%M:%S') failed to compile front-end project">>$OUTPUT_FILE fail_exit else # Corresponds to the packaging status; echo "$(date +'%H:%M:%S') Front-end project compiled successfully">>$OUTPUT_FILE fi # Package the compiled front-end results into a single compressed file; mv $QIYAO_ADMIN / dist $QIYAO_ADMIN / admin tar -czf $TARGET_DIR / qiyao_admin_dist.tar.gz -C $QIYAO_ADMIN admin # Move the packaged artifacts to the distribution folder; mv $QIYAO_ADMIN / admin $QIYAO_ADMIN / dist fi # Compiling Linux Electron if [ "$PKG_TYPE" = linux ]; then echo "$(date +'%H:%M:%S') Start compiling $PKG_TYPE version Electron client...">>$OUTPUT_FILE # Perform the compilation of the Electron client; pnpm build:$PKG_TYPE 2>>$ERROR_FILE if [ $? -ne 0 ]; then # If the Electron client compilation fails, print the error log and exit the packaging task; echo "$(date +'%H:%M:%S') Failed to compile $PKG_TYPE version Electron client">>$OUTPUT_FILE fail_exit else # Print packaging status; echo "$(date +'%H:%M:%S') Compiling $PKG_TYPE version Electron client successfully">>$OUTPUT_FILE fi # Package the Electron client and configuration; Copy $QIYAO_ADMIN / ele.json $QIYAO_ADMIN / app-dist cp $QIYAO_ADMIN / build / icons / qiyao-admin.png $QIYAO_ADMIN / app-dist Copy $QIYAO_ADMIN / docs / init / qiyao_linuxAppImage.desktop $QIYAO_ADMIN / app-dist Copy $QIYAO_ADMIN / docs / init / qiyao_linuxUnpacked.desktop $QIYAO_ADMIN / app-dist cd $QIYAO_ADMIN # Compressed and packaged output for users to download; tar -czf $TARGET_DIR / qiyao_linuxAppImage.tar.gz app-dist / ele.jsonapp-dist / *.AppImage app-dist / qiyao-admin.png app-dist / qiyao_linuxAppImage.desktop tar -czf $TARGET_DIR / qiyao_linuxUnpacked.tar.gz app-dist / ele.jsonapp-dist / linux-unpacked app-dist / qiyao-admin.png app-dist / qiyao_linuxUnpacked.desktop cd - fi # Compile the backend; if [ "$PKG_TYPE" = jar ]; then # Copy the compiled front-end code to the back-end project; STATIC_ADMIN_DIR=$QIYAOBOOT / qiyao-system / src / main / resources / static / admin if [ ! -d "$STATIC_ADMIN_DIR" ]; then # If the target folder does not exist, print the packaging status and create the target folder; echo "$(date +'%H:%M:%S') Creates an admin folder under the static folder">>$OUTPUT_FILE mkdir $STATIC_ADMIN_DIR fi # Delete temporary files during execution; rm -rf $STATIC_ADMIN_DIR / * # Copy the front-end packaged artifacts into the back-end code and package them together; cp -r $QIYAO_ADMIN / dist / * $STATIC_ADMIN_DIR if [ $? -ne 0 ]; then # If copying fails, check the error log and exit the packaging task; echo "$(date +'%H:%M:%S') failed to copy the compiled front-end code to the back-end project;">>$OUTPUT_FILE fail_exit fi # Navigate to the backend code directory; cd $QIYAOBOOT echo "$(date +'%H:%M:%S') Start compiling the backend project...">>$OUTPUT_FILE # Compile and package the backend project; mvn clean package -Dmaven.test.skip=true 2>>$ERROR_FILE if [ $? -ne 0 ]; then # If the backend code fails to compile, print the error log and exit the packaging task; echo "$(date +'%H:%M:%S') Backend code compilation error">>$OUTPUT_FILE fail_exit else echo "$(date +'%H:%M:%S') Backend code compiled successfully">>$OUTPUT_FILE fi # Copy the jar file to the target folder; cp $QIYAOBOOT / qiyao-system / target / qiyao-system-0.0.1.jar $TARGET_DIR fi cd $TARGET_ROOT # Compress the target file into a zip file for users to download; zip -r qiyao-$current_time.zip $current_time cd - # Created a successful packaging flag; touch $SUCCESS_FILE # Remove the flag that is currently being packaged; rm $RUNNING_FLAG The qiyao-admin and qiyaoboot folders are project folders cloned from the Git repository. The qiyao-admin folder is the front-end / client project folder, and the qiyaoboot folder is the back-end project folder.
[0082] The `target` folder contains the target files generated during the packaging process. The target files are named using timestamps, for example, 250722170607.
[0083] The folder containing the JAR package contains several files. `application-prod.yml` is the configuration file for the backend project used for packaging. Files starting with `be_` record the commit ID of the backend project used for packaging, such as `be_b6a7c27f`. Files starting with `fe_` record the commit ID of the frontend project used for packaging, such as `fe_1dccad85`. `package.log` records the packaging log, for example: 12:59:02 Create folder / home / code / target / 250724125902; 12:59:02 Start packaging type jar; 12:59:04 git pull successfully retrieved the front-end project qiyao-admin; 12:59:05 git pull successfully pulled the backend project qiyaoboot; 12:59:08 npm install successfully installed frontend dependencies; 12:59:08 Start compiling the front-end project; 13:00:44 Front-end project compiled successfully; 13:00:44 Start compiling the backend project; 13:01:31 The backend code compiled successfully.
[0084] The `error.log` file records error logs; these are used to troubleshoot problems after a packaging failure. `message.txt` records packaging instructions added by the user for this packaging process. The `success` file is a marker file indicating that the packaging was successful. The `type_jar` file is also a marker file, indicating that the package type is a JAR file. `qiyao_admin_dist.tar.gz` is the compressed package of the front-end packaging result, used for debugging by back-end developers, while `qiyao-system-0.0.1.jar` is the back-end service JAR package, used for deployment by operations and maintenance personnel on field workstations.
[0085] The folder containing the Electron client also contains several files. The error.log, fe_xxx, be_xxx, message.txt, package.log, and success files serve the same functions as described above. `type_linux` is a marker file indicating that this package is for a Linux Electron client. `qiyao_linuxAppImage.tar.gz` is an AppImage type client, and `qiyao_linuxUnpacked.tar.gz` is a portable version client. Portable clients start faster than AppImage type clients, but they are distributed as folders, while AppImage clients always exist as single files, making them easier to deploy. Administrators can download the appropriate client type as needed.
[0086] This embodiment also provides an electronic device, including a memory and a processor. The memory stores a computer program, and when the computer program is executed by the processor, it implements the method of any of the above embodiments.
[0087] This embodiment also provides a computer-readable storage medium having a computer program stored thereon, the computer program being loaded by a processor to perform the steps of any of the methods in the above embodiments.
[0088] In the embodiments of this application, the storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), etc.
[0089] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0090] The above provides a detailed description of an online compilation and packaging method, system, device, and storage medium provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. An online compilation and packaging method, characterized in that, Applied to a front-end / back-end separation architecture, wherein the front-end / back-end separation architecture includes a front-end project and a back-end project; the method includes: Get the packaging task request triggered by the user; Build a container based on the packaging task request; Pull target code from a remote code repository into the container; wherein the target code is the latest code in the remote code repository; Within the container, a preset packaging and compilation script is executed according to the packaging task request and the target code to generate the packaging artifacts corresponding to the front-end project and / or the back-end project.
2. The method according to claim 1, characterized in that, The step of executing a preset packaging and compilation script according to the packaging task request and the target code includes: Determine the packaging type based on the packaging task request; Pass the packaging type as a command-line parameter to the preset packaging and compilation script; The preset packaging and compilation script is executed based on the command-line parameters and the target code.
3. The method according to claim 2, characterized in that, The packaging type includes at least one of Electron client packaging and JAR package packaging.
4. The method according to claim 2, characterized in that, The command-line parameters include packaging the first application and packaging the second application; The step of executing the preset packaging and compilation script according to the command-line parameters and the target code includes: If the command-line parameter is the first application to be packaged, execute the first packaging logic; If the command-line parameter is the second application to be packaged, the second packaging logic is executed.
5. The method according to claim 4, characterized in that, The execution of the first packaging logic includes: Retrieve the front-end code of the aforementioned front-end project; Then, the following steps are executed sequentially: installing front-end dependencies, compiling the front-end, executing the first packaging, and collecting client files to generate the first packaged artifact.
6. The method according to claim 4, characterized in that, The execution of the second packaging logic includes: Retrieve the front-end code of the front-end project and the back-end code of the back-end project; Then, the installation of front-end dependencies, front-end compilation, and execution of the second packaging are performed sequentially to generate the second packaged artifact.
7. The method according to claim 6, characterized in that, The second packaging process includes: moving the distribution directory to the backend directory, backend packaging, collecting JARs, and configuration.
8. The method according to claim 4, characterized in that, The first application being packaged is an Electron application, and the second application being packaged is a Web application.
9. An online compilation and packaging system, characterized in that, Applied to a front-end / back-end separation architecture, the front-end / back-end separation architecture includes a front-end project and a back-end project; the system includes: The acquisition module is used to acquire user-triggered packaging task requests; The build module is used to build a container based on the packaging task request; A pull module is used to pull target code from a remote code repository into the container; wherein the target code is the latest code in the remote code repository; A generation module is configured to execute a preset packaging and compilation script in the container according to the packaging task request and the target code to generate the packaging artifacts corresponding to the front-end project and / or the back-end project.
10. The system according to claim 9, characterized in that, The system also includes a user interface, which provides a packaging type selection interface and a packaging task request triggering interface, as well as real-time recording and archiving of compilation and packaging.
11. An electronic device, characterized in that, It includes a memory and a processor, wherein the memory stores a computer program that, when executed by the processor, implements the method as described in any one of claims 1-8.
12. A computer-readable storage medium, characterized in that, It stores a computer program, which is loaded by a processor to perform the steps of the method as described in any one of claims 1-8.