diff --git a/.dockerignore b/.dockerignore index d95ee2a1..7914ac96 100644 --- a/.dockerignore +++ b/.dockerignore @@ -9,6 +9,7 @@ dist files **/e2e/videos node_modules +sbin # Ignore only top-level package-lock.json /package-lock.json diff --git a/.gitignore b/.gitignore index 1b452670..32f3accf 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ dist files **/e2e/videos node_modules +sbin # Ignore only top-level package-lock.json /package-lock.json diff --git a/Dockerfile b/Dockerfile index 8fa39423..b20c00f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,7 +42,7 @@ WORKDIR ${APP_ROOT} # Install Application RUN chown -R 1001:0 ${APP_ROOT} USER 1001 -RUN npm ci --omit=dev +RUN npm ci --omit=dev && npm run build EXPOSE ${APP_PORT} -CMD ["node", "-r", "ts-node/register", "./bin/www"] +CMD ["node", "./sbin/bin/www"] diff --git a/app/.gitignore b/app/.gitignore index af47744e..d4cfa155 100644 --- a/app/.gitignore +++ b/app/.gitignore @@ -9,6 +9,9 @@ dist files **/e2e/videos node_modules +sbin +# Ignore only top-level package-lock.json +/package-lock.json # Ignore Helm subcharts charts/**/charts diff --git a/app/app.ts b/app/app.ts index 12b78c80..5565e493 100644 --- a/app/app.ts +++ b/app/app.ts @@ -93,7 +93,8 @@ appRouter.get('/api', (_req: Request, res: Response): void => { }); // Host the static frontend assets -appRouter.use('/', express.static(join(__dirname, 'dist'))); +// This route assumes being executed from '/sbin' +appRouter.use('/', express.static(join(__dirname, '../dist'))); // Mount application endpoints app.use('/', appRouter); diff --git a/app/package.json b/app/package.json index c410e810..b0c5088c 100644 --- a/app/package.json +++ b/app/package.json @@ -6,9 +6,12 @@ "author": "NR Common Service Showcase ", "license": "Apache-2.0", "scripts": { - "build": "ts-node ./frontend-utils.ts", - "clean": "rimraf coverage dist", - "clean:all": "npm run clean && ts-node ./frontend-utils.ts clean", + "build": "tsc", + "build:all": "ts-node ./frontend-utils.ts", + "postbuild:all": "npm run build", + "clean": "rimraf coverage dist sbin", + "clean:all": "ts-node ./frontend-utils.ts clean", + "postclean:all": "npm run clean", "debug": "ts-node-dev --debug --respawn --transpile-only --rs --watch bin,config,dist ./bin/www", "format": "prettier ./src --write", "lint": "eslint . **/www* --no-fix --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore", diff --git a/app/tsconfig.json b/app/tsconfig.json index e5ca9a50..10706550 100644 --- a/app/tsconfig.json +++ b/app/tsconfig.json @@ -44,7 +44,7 @@ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - "outDir": "./dist" /* Specify an output folder for all emitted files. */, + "outDir": "./sbin" /* Specify an output folder for all emitted files. */, // "removeComments": true, /* Disable emitting comments. */ // "noEmit": true, /* Disable emitting files from a compilation. */ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */