From 3175d5f646e1ba6446813cd4977fe007e55d2b87 Mon Sep 17 00:00:00 2001 From: sshijun Date: Wed, 15 Jan 2020 14:04:59 +0800 Subject: [PATCH] Fix postinstall script in Docker Signed-off-by: sshijun --- make/photon/portal/Dockerfile | 8 +++++--- src/portal/scripts/convert-yaml-to-json.js | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/make/photon/portal/Dockerfile b/make/photon/portal/Dockerfile index a95f35f12..8f66bcece 100644 --- a/make/photon/portal/Dockerfile +++ b/make/photon/portal/Dockerfile @@ -10,15 +10,17 @@ RUN apt-get update \ COPY src/portal/package.json /build_dir COPY src/portal/package-lock.json /build_dir -ENV NPM_CONFIG_REGISTRY=${npm_registry} -RUN npm install - +COPY src/portal/scripts /build_dir COPY ./api/harbor/swagger.yaml /build_dir +COPY ./api/v2.0/swagger.yaml /build_dir/swagger2.yaml + RUN python -c 'import sys, yaml, json; y=yaml.load(sys.stdin.read()); print json.dumps(y)' < swagger.yaml > swagger.json COPY ./LICENSE /build_dir COPY src/portal /build_dir +ENV NPM_CONFIG_REGISTRY=${npm_registry} +RUN npm install --unsafe-perm RUN node --max_old_space_size=2048 'node_modules/@angular/cli/bin/ng' build --prod FROM goharbor/harbor-portal-base:${harbor_base_image_version} diff --git a/src/portal/scripts/convert-yaml-to-json.js b/src/portal/scripts/convert-yaml-to-json.js index e3d623c41..5683705ef 100644 --- a/src/portal/scripts/convert-yaml-to-json.js +++ b/src/portal/scripts/convert-yaml-to-json.js @@ -4,12 +4,15 @@ 2.npm install ng-swagger-gen --save-dev */ //configuration -const inputFile = '../../api/v2.0/swagger.yaml'; +let inputFile = '../../api/v2.0/swagger.yaml'; const outputDir = 'ng-swagger-gen'; //convert swagger.yaml to swagger.json const yaml = require('js-yaml'); const fs = require('fs'); +if (fs.existsSync('swagger2.yaml')) { + inputFile = 'swagger2.yaml'; +} if (!fs.existsSync(outputDir)) { fs.mkdirSync(outputDir); }