Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

METRON-2253 optimise npm builds towards compile time rather then runtime for dev builds #1509

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
# limitations under the License.
#
---
- name: Build Metron
- name: Build Metron -DANGULAR_BUILD_PROFILE={{ ANGULAR_BUILD_PROFILE if ANGULAR_BUILD_PROFILE is defined else 'production' }}
shell: "{{ item }}"
args:
chdir: "{{ metron_build_dir }}"
with_items:
- mvn package -DskipTests -T 2C -P HDP-2.5.0.0,mpack
- mvn package -DskipTests -T 2C -P HDP-2.5.0.0,mpack -DANGULAR_BUILD_PROFILE={{ ANGULAR_BUILD_PROFILE if ANGULAR_BUILD_PROFILE is defined else 'production' }}
become: false
run_once: true
delegate_to: localhost
16 changes: 15 additions & 1 deletion metron-deployment/development/centos6/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Any platform that supports these tools is suitable, but the following instructio

### Deployment optimizations

1. Set environment variable
1. Skipping RPMLINT: Set environment variable
```
export ANSIBLE_ARGS='--extra-vars "SKIP_RPMLINT=1"'
```
Expand All @@ -91,6 +91,20 @@ Any platform that supports these tools is suitable, but the following instructio
env ANSIBLE_ARGS='--extra-vars "SKIP_RPMLINT=1"' vagrant up
```

1. Skipping npm runtime optimisation: Set environment variable
```
export ANSIBLE_ARGS='--extra-vars "ANGULAR_BUILD_PROFILE=devbuild"'
```
To disable npm compile-time optimization of the produced javascript. This can save a couple of minutes of time on the build
and deployment of the NodeJS portions of the project.
Either add this variable to your profile, or use it on the command line like

```
env ANSIBLE_ARGS='--extra-vars "ANGULAR_BUILD_PROFILE=devbuild"' vagrant up
```

1. Combining optimisations: `--extra-vars` can take multi `var=value` clauses. simply separate each variable with a space.

### Deployment debugging

1. To enable more verbose logging of ansible actions during the deployment, use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ This package installs the Metron Management UI %{metron_home}
%attr(0755,root,root) %{metron_home}/web/expressjs/node_modules/.bin/*
%attr(0755,root,root) %{metron_home}/web/expressjs/server.js
%attr(0644,root,root) %{metron_home}/web/expressjs/package.json
%attr(0644,root,root) %{metron_home}/web/management-ui/styles.*.css
%attr(0644,root,root) %{metron_home}/web/management-ui/styles*.css
%attr(0644,root,root) %{metron_home}/web/management-ui/favicon.ico
%attr(0644,root,root) %{metron_home}/web/management-ui/index.html
%attr(0644,root,root) %{metron_home}/web/management-ui/*.js
Expand Down Expand Up @@ -641,7 +641,7 @@ This package installs the Metron Alerts UI %{metron_home}
%attr(0755,root,root) %{metron_home}/web/expressjs/alerts-server.js
%attr(0644,root,root) %{metron_home}/web/alerts-ui/favicon.ico
%attr(0644,root,root) %{metron_home}/web/alerts-ui/index.html
%attr(0644,root,root) %{metron_home}/web/alerts-ui/styles.*.css
%attr(0644,root,root) %{metron_home}/web/alerts-ui/styles*.css
%attr(0644,root,root) %{metron_home}/web/alerts-ui/*.js
%attr(0644,root,root) %{metron_home}/web/alerts-ui/*.ttf
%attr(0644,root,root) %{metron_home}/web/alerts-ui/*.svg
Expand Down
23 changes: 22 additions & 1 deletion metron-interface/metron-alerts/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,27 @@
]
},
"configurations": {
"devbuild": {
"optimization": false,
"outputHashing": "none",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"showCircularDependencies": false,
"aot": true,
"extractLicenses": true,
"statsJson": false,
"progress": true,
"vendorChunk": true,
"buildOptimizer": false,
"es5BrowserSupport": false,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
},
"production": {
"optimization": true,
"outputHashing": "all",
Expand Down Expand Up @@ -150,4 +171,4 @@
"prefix": "app"
}
}
}
}
2 changes: 1 addition & 1 deletion metron-interface/metron-alerts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "Apache-2.0",
"angular-cli": {},
"scripts": {
"build": "./node_modules/@angular/cli/bin/ng build --prod",
"build": "./node_modules/@angular/cli/bin/ng build",
"start": "ng serve --aot",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test --browsers=Chrome",
Expand Down
3 changes: 2 additions & 1 deletion metron-interface/metron-alerts/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<node.version>v9.11.1</node.version>
<npm.version>6.2.0</npm.version>
<angular.build.profile>production</angular.build.profile>
</properties>
<dependencies>
</dependencies>
Expand Down Expand Up @@ -67,7 +68,7 @@
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
<arguments>run build -- --configuration=${angular.build.profile}</arguments>
</configuration>
</execution>
<execution>
Expand Down
21 changes: 21 additions & 0 deletions metron-interface/metron-config/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,27 @@
]
},
"configurations": {
"devbuild": {
"optimization": false,
"outputHashing": "none",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"showCircularDependencies": false,
"aot": true,
"extractLicenses": true,
"statsJson": false,
"progress": true,
"vendorChunk": true,
"buildOptimizer": false,
"es5BrowserSupport": false,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
},
"production": {
"optimization": true,
"outputHashing": "all",
Expand Down
2 changes: 1 addition & 1 deletion metron-interface/metron-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"angular-cli": {},
"scripts": {
"build": "ng build --prod",
"build": "ng build",
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test --browsers=Chrome",
Expand Down
3 changes: 2 additions & 1 deletion metron-interface/metron-config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<node.version>v9.11.1</node.version>
<npm.version>6.2.0</npm.version>
<angular.build.profile>production</angular.build.profile>
</properties>
<dependencies>
</dependencies>
Expand Down Expand Up @@ -68,7 +69,7 @@
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
<arguments>run build -- --configuration=${angular.build.profile}</arguments>
</configuration>
</execution>
<execution>
Expand Down
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@
<!-- ACE editor assets are covered in the metron-config NOTICE file -->
<exclude>**/src/assets/ace/**</exclude>
<exclude>dist/assets/ace/**</exclude>
<!-- scripts.js is MIT licensed - not sure why RAT is flagging it -->
<exclude>dist/scripts.js</exclude>
<!-- Generated svg and bundle.css containing Font Awesome fonts are covered in the
metron-interface/metron-config README and NOTICE files -->
<exclude>dist/*.svg</exclude>
Expand Down