Merge pull request #10489 from AllForNothing/postinstall

Fix postinstall script in Docker
This commit is contained in:
Will Sun 2020-02-03 14:13:12 +08:00 committed by GitHub
commit acfcd2d175
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);
}