Skip to content

Commit

Permalink
Configure the silent build #4
Browse files Browse the repository at this point in the history
  • Loading branch information
athlonUA committed Aug 13, 2018
1 parent 42b29a6 commit a82eb2b
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ docker exec -ti angular-universal_nodejs npm install
docker exec -ti angular-universal_nodejs bash -c 'npm start'
```

- in prod mode
- in prod mode (bash deploy.sh as quick solution)

```
docker-compose up -d --build
Expand Down
4 changes: 4 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
docker-compose up -d --build
docker exec -ti angular-universal_nodejs npm install
docker exec -ti angular-universal_nodejs bash -c 'npm run build:ssr'
docker exec -ti angular-universal_nodejs bash -c 'npm run serve:ssr'
11 changes: 11 additions & 0 deletions docker/nginx/nginx.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ http {
return 200 "User-agent: *\nDisallow: /\n";
}

error_page 502 /502.html;

location = /502.html {
try_files 502.html @error;
internal;
}

location @error {
root /var/www/angular-universal;
}

error_log /var/log/nginx/angular-universal_error.log;
access_log /var/log/nginx/angular-universal_access.log;
}
Expand Down
4 changes: 2 additions & 2 deletions project/application/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/browser",
"outputPath": "tmp/browser",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
Expand Down Expand Up @@ -90,7 +90,7 @@
"build": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist/server",
"outputPath": "tmp/server",
"main": "src/main.server.ts",
"tsConfig": "src/tsconfig.server.json"
},
Expand Down
5 changes: 3 additions & 2 deletions project/application/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
"lint": "ng lint",
"e2e": "ng e2e",
"build:ssr": "npm run build:client-and-server-bundles && npm run webpack:server",
"serve:ssr": "pm2 start dist/server.js",
"serve:ssr": "npm run silent:update && pm2 delete -s angular-universal || : && pm2 start dist/server.js --name angular-universal",
"build:client-and-server-bundles": "ng run angular-universal--browser:build:production && ng run angular-universal--server:build:production",
"webpack:server": "webpack --config webpack.server.config.js --progress --colors"
"webpack:server": "webpack --config webpack.server.config.js --progress --colors",
"silent:update": "rm -rf dist && cp -r tmp dist && rm -rf tmp"
},
"private": true,
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion project/application/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const PORT = process.env.PORT || 4000;
const DIST_FOLDER = join(process.cwd(), 'dist');

// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./dist/server/main');
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./tmp/server/main');

// Import module map for lazy loading
import { provideModuleMap } from '@nguniversal/module-map-ngfactory-loader';
Expand Down
11 changes: 11 additions & 0 deletions project/application/src/502.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Sorry, the site is temporarily unavailable</title>
</head>
<body style="text-align:center;">
<h1>Sorry, the site is temporarily unavailable</h1>
<p>Technical work is underway</p>
</body>
</html>
2 changes: 1 addition & 1 deletion project/application/webpack.server.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
// this makes sure we include node_modules and other 3rd party libraries
externals: [/node_modules/],
output: {
path: path.join(__dirname, 'dist'),
path: path.join(__dirname, 'tmp'),
filename: '[name].js',
},
module: {
Expand Down

0 comments on commit a82eb2b

Please sign in to comment.