
1.3. Build and deploy environments¶
The architecture of our Webapp follows the client-server model. So, we use:
- Angular 5 framework for the client.
- Nodejs for the server.
According to this, different commands will be used to perform the build and deploy tasks of each of the environments. The following image shows a scheme with the steps to perform the different tasks ( execution, build and deploy) in a particular environment, “x”. All these are analogous in the three Health29 environments: development, production and test.
In this section we will explain the procedure to follow to perform each of these tasks. Therefore, the following section has been divided into sections to detail the specific steps for each of them.
1.3.1. Execution.¶
To run one of the application environments on our machine and be able to perform the implementation and testing tasks, based on the technologies chosen in our client-server model, we have to perform the following steps:
- The server is designed in nodejs v10.16.3, so it will be executed from the node console with the corresponding command.
- As the client is designed in Angular 5, we will use Angular Cli executing the corresponding script.
So, the first thing to do is to launch the server with “npm run serve”.
Then, we will see how to launch the client. To do this, first it is necessary to understand the configuration and architecture of the workspace of Angular’s projects. In the file package.json we will find the different scripts that have been designed to perform different tasks on the project, such as: the execution, the testing or the build of it.
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
In this case, to execute the client of our application we use the command: ng serve.
With this, we will have the Health29 application running at http://localhost:4200/.
1.3.2. Build: scripts.¶
The build is done on the Angular client. As seen in the previous section, using the scripts defined in the package.json file, uring development we’ve been using the ng serve command to build, watch, and serve the application from local memory. But when we are ready to deploy, however, we must use the ng build command to build the app and deploy the build artifacts elsewhere.
Both ng build and ng serve clear the output folder before they build the project, but only the ng build command writes the generated build artifacts to the output folder.
The output folder is dist/project-name/ by default. To output to a different folder, change the outputPath in angular.json.
As we saw in the diagram shown at the beginning of this section, by running ng build –prod we minimize and compress the code. This command will create a new folder called dist, and it will have the project optimized. This dist folder will be the one uploaded to the root of the node server that manages the API.
1.3.3. Deploy.¶
The deploy tasks can be executed according to the interactions in the master branch of each project. That is, you can configure the listening of the push or commits in the master branch of the project server of a specific environment to automate the deploy of this environment.
1.3.2. Azure Pipelines.¶
To deploy one of the environments, we could use Azure Pipelines.
The architecture proposed consists of the construction of CI/CD pipelines which helps you automate steps in your software delivery process, such as initiating code builds, running automated tests, and deploying to a staging or production environment. Automated pipelines remove manual errors, provide standardized development feedback loops and enable fast product iterations.
Thus, the corresponding pipelines for build and deploy the environment with the changes made should be executed manually. That is, we have 4 pipelines available in the project: one for the client and one for the server, of develop and test environments.
- Develop environment pipelines:
- Test environment pipelines:
The pipelines of the production environment were not implemented but it is recommendable since deploy is a critical task.
For convenience, both build and deploy tasks have been added to these pipelines. In this way, when you want to update any of the environments, you only need to execute the client and server pipelines, in that order. It is important to respect the order since when the build tasks are included, as indicated in the previous sections, it will be necessary to update the node server root with the content of the last client compilation.
It is important to emphasize here that the title of the section indicated that we make a semiautomation of the processes, this is due to the fact that the execution of the pipelines is manual.