From f32465aeafe1b70f5754cc730eaa502f145559c8 Mon Sep 17 00:00:00 2001 From: Marsell Kukuljevic Date: Tue, 27 Apr 2021 22:19:08 +0200 Subject: [PATCH 1/3] Add details to README.md about SmartOS metadata used for setting package and image rates, and fix an error regarding the HTTP paths to /images.json and /package.json --- README.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 732795e..0d5d3dd 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,21 @@ connected solely to the external network (aka public Internet). It should (although does not require) two JSON hash tables in the VM's internal\_metadata: sc:image\_subscription\_rates and sc:package\_rates; both map UUID strings to floats, with the image float representing a monthly subscription rate, and the -package float representing the rate per hour. +package float representing the rate per hour. A simplified example of a VM's +metadata: + + "internal_metadata_namespaces": ["sc"], + "internal_metadata": { + "sc:image_subscription_rates": + "{\"ca872441-09a3-4ceb-a843-6fa83ac6795d\": 70}", + "sc:package_rates": + "{\"64e9bcdd-1ba7-429f-9243-642891b81028\": 0.45}" + } + +Be aware that if the image and package JSON strings are malformed (not +serialized correctly), this will not affect the server startup; errors will +only show up in the client-side app when logged in, so make sure the JSON is +serialized correctly. Once the VM is running, the following steps are needed from within the VM: @@ -102,13 +116,13 @@ All calls will be passed through to cloudapi. For these calls to succeed, they MUST provide an X-Auth-Token header, containing the token returned from SSO. -## GET /rates/packages.json +## GET /packages.json Returns a JSON file mapping package UUIDs (a string) to the hourly rate (a float) that a customer will be charged for running a VM using that package. This is charged fractionally down to a minute granularity. -## GET /rates/images.json +## GET /images.json Returns a JSON file mapping image UUIDs (a string) to the monthly rate (a float) that a customer will be charged for running a VM using that image. From 60a5cd91c8fb567f8aa12b501a543144c6178144 Mon Sep 17 00:00:00 2001 From: Marsell Kukuljevic Date: Wed, 28 Apr 2021 14:11:56 +0200 Subject: [PATCH 2/3] Update README.md on building app/ for production. --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d5d3dd..9b9bdb9 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,13 @@ Then install the Angular compiler needed for the client-side app: ## Build the client-side app: - pushd app && npm run build && popd +For development: + + pushd app && ng build && popd + +For production (shakes tree and minifies to get smaller size): + + pushd app && ng build --prod && popd ## Generate server certificates From 17e2a5f86ab7b4c90f0cb74158bc46bc9e50a6bd Mon Sep 17 00:00:00 2001 From: Marsell Kukuljevic Date: Wed, 28 Apr 2021 17:28:31 +0200 Subject: [PATCH 3/3] Add support for serving gzipped static content. Between minification and this, the client-size app is now about 1MB in size when built for production. --- README.md | 9 +++++++-- bin/server.js | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9b9bdb9..31f11ac 100644 --- a/README.md +++ b/README.md @@ -59,9 +59,14 @@ For development: pushd app && ng build && popd -For production (shakes tree and minifies to get smaller size): +For production (shakes tree, minifies and gzips to get smaller size): - pushd app && ng build --prod && popd + pushd app + ng build --prod + for f in $(find dist -type f -not -name '*.html' -not -name '*.png'); do + gzip --best "$f"; + done + popd ## Generate server certificates diff --git a/bin/server.js b/bin/server.js index 510760e..3e82d55 100755 --- a/bin/server.js +++ b/bin/server.js @@ -200,7 +200,8 @@ function main() { // where to serve static content from let staticHandler = mod_restify.plugins.serveStatic({ directory: 'static', - default: 'index.html' + default: 'index.html', + gzip: true }); server.get(STATIC_RE, function staticFunnel(req, res, next) { staticHandler(req, res, function fileFound(err) {