Fix postinstall script in Docker

Signed-off-by: sshijun <sshijun@vmware.com>
This commit is contained in:
sshijun 2020-01-15 14:04:59 +08:00
parent 362c5211f8
commit 3175d5f646
2 changed files with 9 additions and 4 deletions

View File

@ -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}

View File

@ -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);
}