CN116382718A - Code offline deployment method and device, computer equipment and storage medium - Google Patents
Code offline deployment method and device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN116382718A CN116382718A CN202310365104.1A CN202310365104A CN116382718A CN 116382718 A CN116382718 A CN 116382718A CN 202310365104 A CN202310365104 A CN 202310365104A CN 116382718 A CN116382718 A CN 116382718A
- Authority
- CN
- China
- Prior art keywords
- deployment
- code
- file
- local
- image
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 66
- 238000010276 construction Methods 0.000 claims abstract description 25
- 238000004806 packaging method and process Methods 0.000 claims abstract description 22
- 238000010367 cloning Methods 0.000 claims abstract description 21
- 230000006855 networking Effects 0.000 claims abstract description 18
- 238000012545 processing Methods 0.000 claims abstract description 18
- 238000012360 testing method Methods 0.000 claims description 36
- 238000012550 audit Methods 0.000 claims description 26
- 230000001419 dependent effect Effects 0.000 claims description 22
- 230000008569 process Effects 0.000 claims description 22
- 230000003068 static effect Effects 0.000 claims description 19
- 238000011990 functional testing Methods 0.000 claims description 11
- 239000000047 product Substances 0.000 description 13
- 238000010586 diagram Methods 0.000 description 7
- 238000011161 development Methods 0.000 description 5
- 239000011265 semifinished product Substances 0.000 description 5
- 238000004891 communication Methods 0.000 description 4
- 238000007906 compression Methods 0.000 description 4
- 230000006835 compression Effects 0.000 description 4
- 230000010354 integration Effects 0.000 description 4
- 238000005516 engineering process Methods 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 238000012856 packing Methods 0.000 description 3
- 230000009286 beneficial effect Effects 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 238000009434 installation Methods 0.000 description 2
- 238000011900 installation process Methods 0.000 description 2
- 230000008439 repair process Effects 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000004590 computer program Methods 0.000 description 1
- 230000008878 coupling Effects 0.000 description 1
- 238000010168 coupling process Methods 0.000 description 1
- 238000005859 coupling reaction Methods 0.000 description 1
- 235000019800 disodium phosphate Nutrition 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 230000010365 information processing Effects 0.000 description 1
- 238000007689 inspection Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000000275 quality assurance Methods 0.000 description 1
- 239000013589 supplement Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/61—Installation
- G06F8/63—Image based installation; Cloning; Build to order
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/43—Checking; Contextual analysis
- G06F8/433—Dependency analysis; Data or control flow analysis
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer And Data Communications (AREA)
Abstract
The embodiment of the application belongs to the technical field of computers and relates to a code offline deployment method, which comprises the steps of obtaining an external configuration file, a packaging script and an image file by obtaining a deployment file and decompressing the deployment file, wherein the external configuration file comprises code datum line information; based on the code reference line information, cloning codes from a remote server to the local to obtain local codes, and storing the local codes to a designated position; and under an intranet or non-intranet environment, carrying out dependency association and mirror image construction on the local code by adopting a package script and a mirror image file to obtain a Docker deployment mirror image, and executing service deployment processing on a client server by adopting the Docker deployment mirror image. The application also provides a code offline deployment device, computer equipment and a storage medium. According to the technical scheme, networking is not needed to obtain codes or components during deployment, so that the safety of the client for deploying the codes is improved.
Description
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method and apparatus for offline code deployment, a computer device, and a storage medium.
Background
With the continuous development of information technology, in order to rapidly meet the daily and monthly demands of users, the iteration speed of the product is very high; teams participating in large business development are also growing, and multiple teams are simultaneously maintaining one product. In this background and project demand, development of continuous integration has evolved, and complete continuous integration typically involves processes such as code version control, code static inspection, compilation, unit testing, packaging, deployment, and automated testing. Typically complete continuous integration development is done by a continuous integration server.
Currently, when a continuous integrated server packages and deploys a code file, an external network is generally required to be connected to download a resource package on which the package depends, so that the package of the code file can be completed. However, some enterprises are in safety consideration, and links such as site delivery, code audit, package deployment and the like are required to be performed, so that in order to avoid potential safety hazards caused by an external network to each server of the enterprises, each server of the enterprises is not allowed to be connected with the external network, and therefore, the conventional technology limits cause the problems in terms of safety and quality assurance.
Disclosure of Invention
The embodiment of the application aims to provide a code offline deployment method, a code offline deployment device, computer equipment and a storage medium, so as to solve the security problem in the client code deployment process.
In order to solve the above technical problems, the embodiments of the present application provide a code offline deployment method, which adopts the following technical schemes:
acquiring a deployment file, decompressing the deployment file to obtain an external configuration file, a package script and an image file, wherein the external configuration file comprises code reference line information;
based on the code reference line information, cloning codes from a remote server to the local to obtain local codes, and storing the local codes to a designated position;
under an intranet or no-intranet environment, carrying out dependency association and mirror image construction on the local code by adopting the package script and the mirror image file to obtain a Docker deployment mirror image;
and executing deployment processing by adopting the deployment mirror image.
Further, before the step of obtaining the deployment file, the method further includes:
constructing the mirror image file according to a networking module and a dependent package;
storing the image file in a legal path, wherein the legal path is determined based on the dependency relationship in the dependency package.
Further, in the intranet or the no-intranet environment, the adopting the package script and the mirror image file to perform dependency association and mirror image construction on the local code to obtain a Docker deployment mirror image includes:
acquiring a dependent package in the image file, wherein the dependent package is designated in an external configuration file and is automatically downloaded and installed in the process of constructing the image;
judging whether the dependency required for generating the deployment image exists in the dependency package or not by adopting a packaging script, wherein the packaging script is used for analyzing the content in the dependency package and automatically packaging and constructing a local code;
if the dependency package exists, generating a static product command based on the dependency in the dependency package, and if the dependency package does not exist, acquiring the required dependency through the networking module to obtain a dependency file;
and executing an automatic construction instruction based on the local code, the static product command and the dependent file to generate the deployment image.
Further, the code reference line information includes an operation instruction and/or code library branch information, so as to determine a state and a version of a code library, and cloning codes from a remote server to a local based on the code reference line information, so as to obtain the local codes includes:
Determining code branches to be deployed according to the operation instructions and/or the code library branch information;
and cloning codes in the code branches from a remote server to the local to obtain local codes.
Further, the external configuration file further includes a specific path, where the specific path is used to store relevant parameters for installing the image file, and after decompressing the deployment file to obtain the external configuration file, the package script and the image file, the method further includes:
and acquiring relevant parameters for installing the image file from the specific path, and installing the image file according to the relevant parameters.
Further, after the step of storing the local code to a specified location, the method further includes:
and extracting an audit code from the local code, and sending the audit code to a client so that the client performs compliance audit according to the audit code.
Further, the performing deployment processing using the deployment image includes:
deploying the deployment image to a client test environment;
when a deployment completion message is detected, respectively carrying out stability and functionality tests on the deployment mirror image to obtain a stable test result and a functional test result;
And if the stable test result and the functional test result reach the expected conditions, confirming that the deployment is successful.
In order to solve the above technical problems, the embodiments of the present application further provide a code offline deployment device, which adopts the following technical scheme:
the device comprises an acquisition module, a storage module and a storage module, wherein the acquisition module is used for acquiring a deployment file, decompressing the deployment file and acquiring an external configuration file, a package script and an image file, wherein the external configuration file comprises code reference line information;
the cloning module is used for cloning codes from a remote server to the local on the basis of the code reference line information to obtain local codes, and storing the local codes to the appointed positions;
the construction module is used for carrying out dependency association and mirror image construction on the local code by adopting the package script and the mirror image file in an intranet or non-intranet environment to obtain a Docker deployment mirror image;
and the deployment module is used for executing service deployment processing on the client server by adopting the Docker deployment mirror image.
Further, the code offline deployment device further comprises:
the generation module is used for constructing the mirror image file according to the networking module and the dependence package;
and the storage module is used for storing the image file in a legal path, wherein the legal path is determined based on the dependency relationship in the dependency package.
Further, the building module includes:
a dependent package obtaining unit, configured to obtain a dependent package in the image file, where the dependent package is specified in an external configuration file and is automatically downloaded and installed in the process of constructing the image;
the dependency judging unit is used for judging whether the dependency required by generating the deployment image exists in the dependency package or not by adopting a packaging script, wherein the packaging script is used for analyzing the content in the dependency package and automatically packaging and constructing a local code;
the judging and executing unit is used for generating a static product command based on the dependence in the dependence package if the dependence exists, and acquiring the required dependence through the networking module to obtain a dependence file if the dependence exists;
and the image generation unit is used for executing an automatic construction instruction based on the local code, the static product command and the dependency file to generate the deployment image.
Further, the code offline deployment device further comprises:
and the auditing module is used for extracting auditing codes from the local codes and sending the auditing codes to the client so that the client can conduct compliance auditing according to the auditing codes.
Further, the deployment module includes:
the deployment unit is used for deploying the deployment image to the client testing environment;
the test unit is used for respectively carrying out stability and functionality tests on the deployment mirror image when the deployment completion message is detected, so as to obtain a stable test result and a functional test result;
and the result determining unit is used for confirming successful deployment if the stable test result and the functional test result reach the expected conditions.
To solve the above technical problem, the embodiments of the present application further provide a computer device, where the computer device includes a memory and a processor, where the memory stores computer readable instructions, and the processor implements the steps of the code offline deployment method described above when executing the computer readable instructions.
To solve the above technical problem, the embodiments of the present application further provide a computer readable storage medium, where computer readable instructions are stored on the computer readable storage medium, and when the computer readable instructions are executed by a processor, the steps of the code offline deployment method described above are implemented.
Compared with the prior art, the embodiment of the application has the following main beneficial effects: obtaining an external configuration file, a packaging script and an image file by obtaining a deployment file and decompressing the deployment file, wherein the external configuration file comprises code reference line information; based on the code reference line information, cloning codes from a remote server to the local to obtain local codes, and storing the local codes to a designated position; in an intranet or intranet-free environment, a package script and an image file are adopted to carry out dependency association and image construction on a local code, a Docker deployment image is obtained, service deployment processing is carried out on a client server by adopting the Docker deployment image, and image construction is carried out through association dependency, so that the image contains all dependency components required by deployment, and therefore, the deployment can be directly carried out in the intranet-free or intranet-free environment without obtaining codes or components through networking, and the security of the code deployment of a client is improved.
Drawings
For a clearer description of the solution in the present application, a brief description will be given below of the drawings that are needed in the description of the embodiments of the present application, it being obvious that the drawings in the following description are some embodiments of the present application, and that other drawings may be obtained from these drawings without inventive effort for a person of ordinary skill in the art.
FIG. 1 is an exemplary system architecture diagram in which the present application may be applied;
FIG. 2 is a flow chart of one embodiment of a code offline deployment method according to the present application;
FIG. 3 is a flow chart of one embodiment of step S203 of FIG. 2;
FIG. 4 is a flow chart of one embodiment of step S204 of FIG. 2;
FIG. 5 is a schematic structural view of one embodiment of a code offline deployment device according to the present application;
FIG. 6 is a schematic diagram of one embodiment of the building block shown in FIG. 5;
FIG. 7 is a schematic diagram of one embodiment of the deployment module of FIG. 5;
FIG. 8 is a schematic structural diagram of one embodiment of a computer device according to the present application.
Detailed Description
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used in the description of the applications herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "comprising" and "having" and any variations thereof in the description and claims of the present application and in the description of the figures above are intended to cover non-exclusive inclusions. The terms first, second and the like in the description and in the claims or in the above-described figures, are used for distinguishing between different objects and not necessarily for describing a sequential or chronological order.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the present application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments.
In order to better understand the technical solutions of the present application, the following description will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the accompanying drawings.
As shown in fig. 1, a system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used as a medium to provide communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The user may interact with the server 105 via the network 104 using the terminal devices 101, 102, 103 to receive or send messages or the like. Various communication client applications, such as a web browser application, a shopping class application, a search class application, an instant messaging tool, a mailbox client, social platform software, etc., may be installed on the terminal devices 101, 102, 103.
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablet computers, electronic book readers, MP3 players (Moving Picture Experts Group Audio Layer III, dynamic video expert compression standard audio plane 3), MP4 (Moving Picture Experts Group Audio Layer IV, dynamic video expert compression standard audio plane 4) players, laptop and desktop computers, and the like.
The server 105 may be a server providing various services, such as a background server providing support for pages displayed on the terminal devices 101, 102, 103.
It should be noted that, the code offline deployment method provided in the embodiments of the present application is generally executed by a server/terminal device, and accordingly, the code offline deployment apparatus is generally set in the server/terminal device.
It should be understood that the number of terminal devices, networks and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continued reference to FIG. 2, a flow chart of one embodiment of a code offline deployment method according to the present application is shown. The offline code deployment method comprises the following steps:
Step S201, a deployment file is obtained, and is decompressed to obtain an external configuration file, a packaging script and an image file, wherein the external configuration file comprises code reference line information.
In this embodiment, the electronic device (e.g., the server/terminal device shown in fig. 1) on which the code offline deployment method operates may receive the code deployment request from the client through a wired connection or a wireless connection. It should be noted that the wireless connection may include, but is not limited to, 3G/4G/5G connection, wiFi connection, bluetooth connection, wiMAX connection, zigbee connection, UWB (ultra wideband) connection, and other now known or later developed wireless connection.
Specifically, when the client arrives at the site, the delivery server is accessed in a region with a compliance network, and under the condition that the client is legal for examination, the deployment file is downloaded from the delivery server and decompressed.
The deployment file refers to a file to be deployed to the client, and it should be noted that the file to be deployed to the client often has more dependent files or components, so that when the client deploys relevant codes, deployment and installation are required through a network.
Further, the external configuration file further includes a specific path, where the specific path is used to store related parameters for installing the image file, and after decompressing the deployment file to obtain the external configuration file, the package script and the image file, the offline deployment of the code further includes:
and acquiring relevant parameters for installing the image file from the specific path, and installing the image file according to the relevant parameters.
In a specific embodiment, the relevant parameters are written into the file and stored in a specific path, and when the mirror image file is installed, the file containing the relevant parameters is read from the path, and then the installation is performed according to the relevant parameters.
It should be noted that, in the front-end code development process, it is necessary to use Git for version control to ensure stability and traceability of the code. To ensure code security, we host the code in a secure area and control access rights. Therefore, only authorized personnel can access and modify the code library, and the code reference line information and a specific path for storing related parameters for installing the image file are stored into the external configuration file, so that the access authority of the code library is flexibly controlled in the deployment process, and the safety of the process is ensured.
Step S202, cloning codes from a remote server to the local based on the code reference line information, obtaining local codes, and storing the local codes to the appointed position.
Further, the code reference line information includes operation instructions and/or code library branch information for determining a state and a version of the code library, cloning the code from the remote server to the local based on the code reference line information, and obtaining the local code includes:
determining code branches to be deployed according to the operation instructions and/or code library branch information;
the code in the code branch is cloned from the remote server to the local, resulting in the local code. The branch information of the code library refers to information for determining a code library branch, and when the code library is managed, the code library branch needs to be provided with a branch, and generally comprises a default branch and a protection branch, wherein the default branch is used as a basic branch for cloning, creating a branch, combining a request and browsing codes, and meanwhile, the protection branch can be deleted by mistake. Protection branches limit delete branches, limit Force Push (Force Push). The operation instruction refers to an instruction for operating on a code base branch, including but not limited to browsing, cloning, and the like.
In this embodiment, the requirements of different clients are different, and the deployment codes are selected according to the requirements of the clients, so that when the deployment is required in the following process, the code reference line information is analyzed to obtain the required operation instruction and/or code library branch information, and the code branches to be deployed are determined, and codes in the code branches are cloned from a remote server to the local area for later use. The designated position can be set according to actual needs, the designated position is not limited herein, and the local code is stored in the designated position, so that in the subsequent processing process, only the local code of the designated position is processed, and the access authority of the code library of other areas is not required to be authorized, thereby being beneficial to improving the access security.
And step 203, in an intranet or no-intranet environment, adopting a package script and an image file to carry out dependency association and image linkage construction on the local code to obtain a Docker deployment image.
In this embodiment, the packaging script refers to a computer program for executing automated build and packaging native code. The packaging script may read the project configuration file, retrieve the dependent items, and package them into an image file. Dependency correlation refers to the combining of native code with its associated dependency package and building it as part of an image file. The build process typically involves cloning the native code and dependencies into a temporary container and creating a new image file on the basis of which the deployment image, which is an already built image file, can be migrated to the target computer or cloud environment and used directly to deploy the application. In order to build the mirror image locally, a dependence package is firstly obtained, the content in the dependence package is analyzed through a package script, the semi-finished mirror image is inherited, cloned source codes are stored at a designated position, dependence of the semi-finished product is associated, further script execution codes build new mirror image files according to project configuration files, local codes, dependence items and association relations in a temporary container, and a Docker deployment mirror image is obtained.
The packing script is generally implemented by adopting a shell script, is convenient for different platforms to identify, and can be particularly build. The script determines if a dependency exists, uses the local dependency if it exists, and then executes the command to generate the static product. Therefore, time and energy can be greatly saved, and the production efficiency is improved.
The static product refers to a static resource in the deployment process, and the command for generating the static product refers to determining the static resource after judging that the local dependency exists, and generating a calling instruction based on the static resource so as to facilitate subsequent deployment calling. In this embodiment, the purpose of separate deployment of the static resources and the dynamic resources is to ensure that unilateral repair does not need to mobilize multiparty resources, reduce coupling work, improve iteration and subsequent maintenance efficiency, reduce the number of repeated downloads, and improve the efficiency of packaging processing before deployment.
And step S204, performing service deployment processing on the client server by adopting the Docker deployment mirror image.
In this embodiment, after the deployment image is migrated to the client, a test is performed to ensure that the application program can run normally. Testing may involve verifying aspects of the functionality, performance, stability, etc. of the application. If the test results show that the application program passes the test, the deployment process of the client code is completed and can be regarded as successful delivery. If the test results fail, the deployment process of the client code is considered to be delivery failure. In this case, further repairs to the application and redeployment of the deployment process are required until the test passes.
According to the method and the device, the mirror image is built through the association dependence, so that the mirror image contains all dependence components required by deployment, the deployment can be directly performed in a network-free or intranet environment, the code or components are not required to be acquired through networking, and the security of the code deployment of the client is improved.
In some optional implementations of this embodiment, before step 201, the electronic device may further perform the following steps:
constructing an image file according to the networking module and the dependent package;
storing the image file in a legal path, wherein the legal path is determined based on the dependency relationship in the dependency package.
Where a dependency package refers to a software module or library in a software development that is used to support, supplement, or extend a primary code library, which modules or libraries are created by a third party or the same developer and hosted in a public or private code repository. These dependency packages are typically specified by software developers in project profiles and may be automatically downloaded and installed during the build process.
In the embodiment, the networking module and the dependency package are constructed into the mirror image file, so that when the dependency component or the code in the dependency package is needed to be used later, the follow-up use efficiency is improved, meanwhile, the mirror image file is stored in a legal way, and the legal way is written into an external configuration file, thereby facilitating the follow-up operation and use, avoiding the leakage of rights of other code libraries and improving the safety.
In some alternative implementations, referring to fig. 3, fig. 3 shows a flowchart according to one embodiment of step S203 of the present application, step S203 comprising the steps of:
step S2031, obtaining a dependent package in an image file, wherein the dependent package is specified in an external configuration file and is automatically downloaded and installed in the process of constructing the image;
step S2032, judging whether the dependency required for generating the deployment image exists in the dependency package by adopting a packaging script, wherein the packaging script is used for analyzing the content in the dependency package and automatically packaging and constructing a local code;
step S2033, if there is, generating a static product command based on the dependencies in the dependency package, and if there is no, acquiring the required dependencies through the networking module to obtain the dependency file.
Step S2034, executing an automation build instruction based on the native code, the static product command, and the pass-through dependency file, and generating a deployment image.
In this embodiment, in an intranet or no-intranet environment, a package script and an image file are adopted to perform dependency association and image construction on the local code, so as to obtain a Docker deployment image.
According to the method, the semi-finished product mirror image is inherited when the mirror image is built locally, cloned source codes are stored at the designated positions, the dependency of the semi-finished product is associated by adopting the package script, the deployment mirror image is generated, the repeated downloading and the processing logic of the additional third-party module installation process are avoided, and the efficiency and the stability are improved.
In some optional implementations of this embodiment, after step 202, the electronic device may further perform the following steps:
and extracting an audit code from the local code, and sending the audit code to the client so that the client performs compliance audit according to the audit code.
In this embodiment, when a deployment file is generated, audit codes to be used are individually marked, after a local code is obtained based on the deployment file, the audit codes are extracted from the local code and sent to a client after packing and compression, so that enterprise users of the client can conduct compliance audit through the audit codes, and the safety compliance of the process is ensured.
In some alternative implementations, referring to fig. 4, fig. 4 shows a flowchart according to one embodiment of step S204 of the present application, step S204 comprising the steps of:
step S2041, deploying a deployment image to a client test environment;
step S2042, when the deployment completion message is detected, respectively performing stability and functionality tests on the deployment mirror image to obtain a stable test result and a functional test result;
step S2043, if the stable test result and the functional test result reach the expected conditions, confirming that the deployment is successful.
In this embodiment, a deployed image deployed by a client is tested, and when both a stable test result and a functional test are passed, the deployment is determined to be successful, and when at least one item fails, the deployment is determined to fail.
The expected conditions may be set according to actual needs, and are not particularly limited herein.
According to the method and the device, stability and functionality tests are carried out on the deployed images on the deployed clients, so that stability and normal functions are ensured, and the stability of code deployment of the clients is improved.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by computer readable instructions stored in a computer readable storage medium that, when executed, may comprise the steps of the embodiments of the methods described above. The storage medium may be a nonvolatile storage medium such as a magnetic disk, an optical disk, a Read-Only Memory (ROM), or a random access Memory (Random Access Memory, RAM).
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, these steps are not necessarily performed in order as indicated by the arrows. The steps are not strictly limited in order and may be performed in other orders, unless explicitly stated herein. Moreover, at least some of the steps in the flowcharts of the figures may include a plurality of sub-steps or stages that are not necessarily performed at the same time, but may be performed at different times, the order of their execution not necessarily being sequential, but may be performed in turn or alternately with other steps or at least a portion of the other steps or stages.
With further reference to fig. 5, as an implementation of the method shown in fig. 2, the present application provides an embodiment of a code offline deployment apparatus, where an embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 2, and the apparatus may be specifically applied to various electronic devices.
As shown in fig. 5, the code offline deployment apparatus 300 according to the present embodiment includes: an acquisition module 301, a cloning module 302, a construction module 303, and a deployment module 304, wherein:
the acquiring module 301 is configured to acquire a deployment file, decompress the deployment file, and obtain an external configuration file, a package script, and an image file, where the external configuration file includes code reference line information;
a cloning module 302, configured to clone a code from a remote server to a local location based on code reference line information, obtain a local code, and store the local code to a specified location;
the construction module 303 is configured to perform dependency association and mirror image construction on the local code by adopting a package script and a mirror image file in an intranet or non-intranet environment, so as to obtain a Docker deployment mirror image;
the deployment module 304 is configured to execute service deployment processing at the client server by using a Docker deployment image.
According to the method and the device, the mirror image is built through the association dependence, so that the mirror image contains all dependence components required by deployment, the deployment can be directly performed in a network-free or intranet environment, the code or components are not required to be acquired through networking, and the security of the code deployment of the client is improved.
In some alternative implementations of the present embodiment, referring to fig. 6, fig. 6 is a schematic structural diagram of one embodiment of a building module 303, where the building module 303 includes: a dependent packet acquisition unit 3031, a dependent determination unit 3032, a determination execution unit 3033, and a mirror image generation unit 3034, wherein:
a dependent package obtaining unit 3031, configured to obtain a dependent package in the image file, where the dependent package is specified in the external configuration file and is automatically downloaded and installed in the process of constructing the image;
a dependency judging unit 3032, configured to judge whether a dependency required for generating a deployment image exists in a dependency package by using a package script, where the package script is configured to parse content in the dependency package, and automatically package and construct a local code;
the judging and executing unit 3033 is used for generating a static product command based on the dependence in the dependence package if the dependence exists, and acquiring the required dependence through the networking module to obtain a dependence file if the dependence exists;
the image generating unit 3034 is configured to execute an automation construction instruction to generate a deployment image based on the native code, the static product command and the dependency file.
In this embodiment, in an intranet or no-intranet environment, a package script and an image file are adopted to perform dependency association and image construction on the local code, so as to obtain a Docker deployment image.
According to the method, the semi-finished product mirror image is inherited when the mirror image is built locally, cloned source codes are stored at the designated positions, the dependency of the semi-finished product is associated by adopting the package script, the deployment mirror image is generated, the repeated downloading and the processing logic of the additional third-party module installation process are avoided, and the efficiency and the stability are improved.
In some alternative implementations of the present embodiment, referring to fig. 7, fig. 7 is a schematic structural diagram of one embodiment of a deployment module 304, where the deployment module 304 includes: a deployment unit 3041, a test unit 3042, and a result determination unit 3043, wherein:
a deployment unit 3041 configured to deploy a deployment image to a client test environment;
the testing unit 3042 is configured to perform stability and functionality testing on the deployment image when a deployment completion message is detected, so as to obtain a stable testing result and a functional testing result;
and a result determining unit 3043 configured to confirm successful deployment if the stable test result and the functional test result both reach the expected conditions.
In this embodiment, a deployed image deployed by a client is tested, and when both a stable test result and a functional test are passed, the deployment is determined to be successful, and when at least one item fails, the deployment is determined to fail.
According to the method and the device, stability and functionality tests are carried out on the deployed images on the deployed clients, so that stability and normal functions are ensured, and the stability of code deployment of the clients is improved.
In some optional implementations of the present embodiment, the code offline deployment apparatus may further include: the device comprises a generation module and a storage module, wherein:
the generation module is used for constructing an image file according to the networking module and the dependent package;
and the storage module is used for storing the image file in a legal path, wherein the legal path is determined based on the dependency relationship in the dependency package.
In the embodiment, the networking module and the dependency package are constructed into the mirror image file, so that when the dependency component or the code in the dependency package is needed to be used later, the follow-up use efficiency is improved, meanwhile, the mirror image file is stored in a legal way, and the legal way is written into an external configuration file, thereby facilitating the follow-up operation and use, avoiding the leakage of rights of other code libraries and improving the safety.
In some optional implementations of this embodiment, the code offline deployment apparatus may further include an audit module configured to extract an audit code from the local code and send the audit code to the client, so that the client performs compliance audit according to the audit code.
In this embodiment, when a deployment file is generated, audit codes to be used are individually marked, after a local code is obtained based on the deployment file, the audit codes are extracted from the local code and sent to a client after packing and compression, so that enterprise users of the client can conduct compliance audit through the audit codes, and the safety compliance of the process is ensured.
In order to solve the technical problems, the embodiment of the application also provides computer equipment. Referring specifically to fig. 8, fig. 8 is a basic structural block diagram of a computer device according to the present embodiment.
The computer device 4 comprises a memory 41, a processor 42, a network interface 43 communicatively connected to each other via a system bus. It should be noted that only computer device 4 having components 41-43 is shown in the figures, but it should be understood that not all of the illustrated components are required to be implemented and that more or fewer components may be implemented instead. It will be appreciated by those skilled in the art that the computer device herein is a device capable of automatically performing numerical calculations and/or information processing in accordance with predetermined or stored instructions, the hardware of which includes, but is not limited to, microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASICs), programmable gate arrays (fields-Programmable Gate Array, FPGAs), digital processors (Digital Signal Processor, DSPs), embedded devices, etc.
The computer equipment can be a desktop computer, a notebook computer, a palm computer, a cloud server and other computing equipment. The computer equipment can perform man-machine interaction with a user through a keyboard, a mouse, a remote controller, a touch pad or voice control equipment and the like.
The memory 41 includes at least one type of readable storage medium including flash memory, hard disk, multimedia card, card memory (e.g., SD or DX memory, etc.), random Access Memory (RAM), static Random Access Memory (SRAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), programmable Read Only Memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the storage 41 may be an internal storage unit of the computer device 4, such as a hard disk or a memory of the computer device 4. In other embodiments, the memory 41 may also be an external storage device of the computer device 4, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash Card (Flash Card) or the like, which are provided on the computer device 4. Of course, the memory 41 may also comprise both an internal memory unit of the computer device 4 and an external memory device. In this embodiment, the memory 41 is typically used to store an operating system and various application software installed on the computer device 4, such as computer readable instructions of a code offline deployment method. Further, the memory 41 may be used to temporarily store various types of data that have been output or are to be output.
The processor 42 may be a central processing unit (Central Processing Unit, CPU), controller, microcontroller, microprocessor, or other data processing chip in some embodiments. The processor 42 is typically used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is configured to execute computer readable instructions stored in the memory 41 or process data, such as computer readable instructions for executing the code offline deployment method.
The network interface 43 may comprise a wireless network interface or a wired network interface, which network interface 43 is typically used for establishing a communication connection between the computer device 4 and other electronic devices.
The computer device provided in the embodiment may execute the code offline deployment method. The offline code deployment method may be the offline code deployment method of each embodiment described above.
In the embodiment, an external configuration file, a packaging script and an image file are obtained by acquiring a deployment file and decompressing the deployment file, wherein the external configuration file comprises code reference line information; based on the code reference line information, cloning codes from a remote server to the local to obtain local codes, and storing the local codes to a designated position; in an intranet or intranet-free environment, a package script and an image file are adopted to carry out dependency association and image construction on a local code, a Docker deployment image is obtained, service deployment processing is carried out on a client server by adopting the Docker deployment image, and image construction is carried out through association dependency, so that the image contains all dependency components required by deployment, and therefore, the deployment can be directly carried out in the intranet-free or intranet-free environment without obtaining codes or components through networking, and the security of the code deployment of a client is improved.
The present application also provides another embodiment, namely, a computer-readable storage medium storing computer-readable instructions executable by at least one processor to cause the at least one processor to perform the steps of the code offline deployment method as described above.
In the embodiment, an external configuration file, a packaging script and an image file are obtained by acquiring a deployment file and decompressing the deployment file, wherein the external configuration file comprises code reference line information; based on the code reference line information, cloning codes from a remote server to the local to obtain local codes, and storing the local codes to a designated position; in an intranet or intranet-free environment, a package script and an image file are adopted to carry out dependency association and image construction on a local code, a Docker deployment image is obtained, service deployment processing is carried out on a client server by adopting the Docker deployment image, and image construction is carried out through association dependency, so that the image contains all dependency components required by deployment, and therefore, the deployment can be directly carried out in the intranet-free or intranet-free environment without obtaining codes or components through networking, and the security of the code deployment of a client is improved.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk), comprising several instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the method described in the embodiments of the present application.
It is apparent that the embodiments described above are only some embodiments of the present application, but not all embodiments, the preferred embodiments of the present application are given in the drawings, but not limiting the patent scope of the present application. This application may be embodied in many different forms, but rather, embodiments are provided in order to provide a more thorough understanding of the present disclosure. Although the present application has been described in detail with reference to the foregoing embodiments, it will be apparent to those skilled in the art that modifications may be made to the embodiments described in the foregoing, or equivalents may be substituted for elements thereof. All equivalent structures made by the specification and the drawings of the application are directly or indirectly applied to other related technical fields, and are also within the protection scope of the application.
Claims (10)
1. A method for offline deployment of codes, comprising the steps of:
acquiring a deployment file, decompressing the deployment file to obtain an external configuration file, a package script and an image file, wherein the external configuration file comprises code reference line information;
cloning a clone code from a remote server to a local area based on the code reference line information to obtain a local code, and storing the local code to a designated position;
under an intranet or no-intranet environment, carrying out dependency association and mirror image construction on the local code by adopting the package script and the mirror image file to obtain a Docker deployment mirror image;
and executing service deployment processing on the client server by adopting the Docker deployment mirror image.
2. The method of offline deployment of code according to claim 1, further comprising, prior to the step of obtaining a deployment file:
constructing the mirror image file according to a networking module and a dependent package;
storing the image file in a legal path, wherein the legal path is determined based on the dependency relationship in the dependency package.
3. The method for offline deployment of codes according to claim 2, wherein the performing dependency association and image construction on the local codes by using the package script and the image file in the intranet or the non-intranet environment to obtain a Docker deployment image comprises:
Acquiring a dependent package in the image file, wherein the dependent package is designated in an external configuration file and is automatically downloaded and installed in the process of constructing the image;
judging whether the dependency required for generating the deployment image exists in the dependency package or not by adopting a packaging script, wherein the packaging script is used for analyzing the content in the dependency package and automatically packaging and constructing a local code;
if the dependency package exists, generating a static product command based on the dependency in the dependency package, and if the dependency package does not exist, acquiring the required dependency through the networking module to obtain a dependency file;
and executing an automatic construction instruction based on the local code, the static product command and the dependent file to generate the deployment image.
4. The code offline deployment method according to claim 1, wherein the code reference line information includes operation instructions and/or code library branch information for determining a state and a version of a code library, and wherein cloning codes from a remote server to a local based on the code reference line information, obtaining the local codes includes:
determining code branches to be deployed according to the operation instructions and/or the code library branch information;
And cloning codes in the code branches from a remote server to the local to obtain local codes.
5. The method for offline deployment of code according to claim 1, wherein the external configuration file further comprises a specific path, the specific path is used for storing relevant parameters for installing the image file, and after decompressing the deployment file to obtain the external configuration file, the package script and the image file, the method further comprises:
and acquiring relevant parameters for installing the image file from the specific path, and installing the image file according to the relevant parameters.
6. The code offline deployment method of claim 1, further comprising, after the step of storing the native code to a specified location:
and extracting an audit code from the local code, and sending the audit code to a client so that the client performs compliance audit according to the audit code.
7. The offline deployment method of codes according to any one of claims 1 to 6, wherein said performing a service deployment process at a client server using said Docker deployment image comprises:
Deploying the deployment image to a client test environment;
when a deployment completion message is detected, respectively carrying out stability and functionality tests on the deployment mirror image to obtain a stable test result and a functional test result;
and if the stable test result and the functional test result reach the expected conditions, confirming that the deployment is successful.
8. A code offline deployment apparatus, comprising:
the device comprises an acquisition module, a storage module and a storage module, wherein the acquisition module is used for acquiring a deployment file, decompressing the deployment file and acquiring an external configuration file, a package script and an image file, wherein the external configuration file comprises code reference line information;
the cloning module is used for cloning codes from a remote server to the local on the basis of the code reference line information to obtain local codes, and storing the local codes to the appointed positions;
the construction module is used for carrying out dependency association and mirror image construction on the local code by adopting the package script and the mirror image file in an intranet or non-intranet environment to obtain a Docker deployment mirror image;
and the deployment module is used for executing service deployment processing on the client server by adopting the Docker deployment mirror image.
9. A computer device comprising a memory having stored therein computer readable instructions which when executed by a processor implement the steps of the code offline deployment method of any of claims 1 to 7.
10. A computer readable storage medium having stored thereon computer readable instructions which when executed by a processor implement the steps of the code offline deployment method according to any of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310365104.1A CN116382718A (en) | 2023-03-30 | 2023-03-30 | Code offline deployment method and device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310365104.1A CN116382718A (en) | 2023-03-30 | 2023-03-30 | Code offline deployment method and device, computer equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116382718A true CN116382718A (en) | 2023-07-04 |
Family
ID=86963072
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310365104.1A Pending CN116382718A (en) | 2023-03-30 | 2023-03-30 | Code offline deployment method and device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116382718A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118151961A (en) * | 2024-05-07 | 2024-06-07 | 龙芯中科(合肥)技术有限公司 | Deployment method and device of running environment, electronic equipment and storage medium |
-
2023
- 2023-03-30 CN CN202310365104.1A patent/CN116382718A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118151961A (en) * | 2024-05-07 | 2024-06-07 | 龙芯中科(合肥)技术有限公司 | Deployment method and device of running environment, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109901834B (en) | Document page generation method, device, computer equipment and storage medium | |
CN112162753B (en) | Software deployment method, device, computer equipment and storage medium | |
US9563415B2 (en) | Generating visually encoded dynamic codes for remote launching of applications | |
CN110895471A (en) | Installation package generation method, device, medium and electronic equipment | |
CN110727575B (en) | Information processing method, system, device and storage medium | |
CN111580926A (en) | Model publishing method, model deploying method, model publishing device, model deploying device, model publishing equipment and storage medium | |
CN114297056A (en) | Automatic testing method and system | |
CN112416458A (en) | Preloading method and device based on ReactNative, computer equipment and storage medium | |
CN107305528B (en) | Application testing method and device | |
CN117093286B (en) | Plug-in generation method, device, equipment and computer readable storage medium | |
CN113138768B (en) | Application package generation method and device, electronic equipment and readable storage medium | |
CN110795181A (en) | Application program interface display method and device based on skip protocol and electronic equipment | |
CN113127361B (en) | Application development method and device, electronic equipment and storage medium | |
CN112965721B (en) | Project compiling method and device based on Android, computer equipment and storage medium | |
CN114443294B (en) | Big data service component deployment method, system, terminal and storage medium | |
CN116382718A (en) | Code offline deployment method and device, computer equipment and storage medium | |
CN113434254B (en) | Client deployment method, client deployment apparatus, computer device, and storage medium | |
CN113032256A (en) | Automatic test method, device, computer system and readable storage medium | |
CN112564979A (en) | Execution method and device for construction task, computer equipment and storage medium | |
CN113434217B (en) | Vulnerability scanning method, vulnerability scanning device, computer equipment and medium | |
CN116756016A (en) | Multi-browser testing method, device, equipment, medium and program product | |
CN111427770B (en) | Resource testing method and related equipment | |
CN111858302B (en) | Method and device for testing small program, electronic equipment and storage medium | |
CN113535221B (en) | Method and device for managing application version | |
CN114637672A (en) | Automatic data testing method and device, computer equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |