-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: deployment documentation rework (#398)
- move and adapt nginx configuration - move angular specific deployment scenario document - skeleton for building blocks - test production deployment instructions - concept for multi-site
- Loading branch information
Showing
15 changed files
with
753 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<!-- | ||
kb_concepts | ||
kb_pwa | ||
kb_everyone | ||
kb_sync_latest_only | ||
--> | ||
|
||
# Deployment Scenarios for Angular Applications | ||
|
||
## Simple Browser-Side Rendering | ||
|
||
Angular Applications are by default built for a [static deployment][angular-deployment]. | ||
When running `ng build` in any shape or form, the build output is aggregated in the `dist` folder and the resulting files can be statically served using any HTTP server that is capable of doing that (only a [fallback](https://angular.io/guide/deployment#routed-apps-must-fallback-to-indexhtml) for `index.html` has to be configured). | ||
|
||
When the application is served this way, the initial page response for the browser is minimal (`index.html` with scripts inserted) and the application gets composed and rendered on the client side. | ||
|
||
![Angular-BrowserSideApp-Sequence](deployment-angular-browsersideapp-sequence.jpg 'Angular-BrowserSideApp-Sequence') | ||
|
||
Of course, this can have a significant impact on the client side if no efficient rendering power is available. | ||
Search engine crawlers might also not be able to execute JavaScript and therefor might only see the initial minimal response. | ||
|
||
This method of deployment is suitable for demo servers supplying a fast build chain. | ||
However, we do not recommend this setup for production use. | ||
|
||
> This setup is also used for the Angular CLI built-in webpack-dev-server and should not be confused with a standard production setup. | ||
## Browser-Side Rendering with On-Demand Server-Side Pre-Rendering (Angular Universal) | ||
|
||
To tackle sophisticated SEO requirements, the [Angular Universal][angular-universal] package was introduced. | ||
In a second step in the build process, a server-side application can be built by the Angular CLI after building the client-side application. | ||
The resulting distribution has to be executed in a node environment. | ||
The _server.js_ executable handles client requests on the server and pre-renders the content of the page, basically executing everything in a Node.js environment. | ||
The resulting initial page response to the browser is mainly prepared and can be displayed quickly on the client side while the client-side application is booting up. | ||
|
||
![Angular-ServerSideRendering-Sequence](deployment-angular-serversiderendering-sequence.jpg 'Angular-ServerSideRendering-Sequence') | ||
|
||
This method is the default setup for the Intershop PWA. | ||
We provide a `Dockerfile` for building the [SSR Image][concept-building-blocks]. | ||
|
||
## Impact of Service Workers | ||
|
||
If the Intershop PWA is run with an enabled [Service Worker][concept-progressive-web-app], the SSR process is only triggered for the first visit to the web page. | ||
After that, the Service Worker makes the Application behave like a simple browser-side application, where certain additional caching can lead to an improved client experience. | ||
|
||
Browsers and Crawlers that don't support JavaScript execution will however continue to get fully pre-rendered page responses from the SSR process. | ||
|
||
# Further References | ||
|
||
- [Concept - Building Blocks][concept-building-blocks] | ||
- [Concept - Progressive Web App][concept-progressive-web-app] | ||
- [Angular - Deployment][angular-deployment] | ||
- [Angular - Universal][angular-universal] | ||
|
||
[angular-deployment]: https://angular.io/guide/deployment | ||
[angular-universal]: https://angular.io/guide/universal | ||
[concept-building-blocks]: ./pwa-building-blocks.md | ||
[concept-progressive-web-app]: ./progressive-web-app.md#service-worker |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<!-- | ||
kb_concepts | ||
kb_pwa | ||
kb_everyone | ||
kb_sync_latest_only | ||
--> | ||
|
||
# Multi-Site Handling | ||
|
||
## Motivation | ||
|
||
Imagine running an Europe-wide shop with Intershop, where the website is available in 16 different countries with different languages and a varying selection of products, but only little modification of the website appearance over all. | ||
This would be set up by having 16 channels with one headless application each on the ICM side. | ||
|
||
In a setup before the PWA 0.9 release this would have lead to a deployment with 16 PWA instances combined with one nginx for caching each. | ||
Of course, a fail-over setup would increase the number of required deployment containers even more. | ||
|
||
That is why, since version 0.9 of the PWA there are means to dynamically configure ICM channel and application to determine the correct REST endpoint for each incoming top level request. | ||
|
||
The aforementioned scenario can now be run with just one PWA instance and a reverse proxy running in front, implementing this dynamic configuration. | ||
|
||
## Configuration | ||
|
||
To set ICM channels and applications dynamically, you have to use URL rewriting in a reverse proxy running in front of the PWA instances. | ||
The values have to be provided as URL parameters (not to be confused with query parameters). | ||
|
||
**nginx URL rewrite snippet** | ||
|
||
```text | ||
rewrite ^(.*)$ "$1;channel=inSPIRED-inTRONICS_Business-Site;application=-" break; | ||
``` | ||
|
||
The above example configuration snippet shows an [nginx](https://en.wikipedia.org/wiki/Nginx) rewrite rule on how to map an incoming top level request URL to a dynamically configured URL for the downstream PWA instance. | ||
It shows both the PWA parameters `channel`, `application` and their fixed example values. | ||
The parameters of each incoming request are then read by the PWA upon initialization and used for the composition of the initial HTML response on the server side. | ||
Afterwards they are propagated to the client side and re-used for subsequent REST requests. | ||
|
||
In the source code of the project we provide an [extended nginx](./pwa-building-blocks.md#pwa---nginx) docker image for easy configuration of multiple channels via sub-domains. | ||
|
||
## Multi-Site Production Deployment | ||
|
||
These steps should give an overview of the internal workings: | ||
|
||
![Current Deployment](pwa-building-blocks-production-deployment.svg) | ||
|
||
1. The Browser requests the page by URL from the reverse proxy. Nginx appends URL parameters to the incoming request URL for channel, application, ... depending on the incoming domain. | ||
|
||
2. The node express.js server runs Angular Universal pre-rendering for the requested URL. Angular Universal dynamically configures itself with the incoming parameters. | ||
|
||
3. The requested page is filled with content retrieved via ICM REST API for this dynamically configured channel. | ||
|
||
4. The configuration parameters are persisted for the client application via state transfer. Afterwards, the response is delivered to nginx. | ||
|
||
5. The response is delivered to the browser. | ||
|
||
6. The initial page response is displayed to the user and the Angular Client Application is booting up in the browser, configuring itself with the transferred parameters for channel, application, ... | ||
|
||
7. Once booted up, additional REST Calls are directed to the matching ICM endpoint for the configured channel. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.