我正在做一个相对较大的项目,我的目标是本地化。我已经完成了所有必要的事情,并且我没有在扩展现有的 Docker 文件以启用它。但是,它失败了。这是 Docker 文件(至少在它工作的部分):
FROM node:15.11.0-alpine3.13 as builder
WORKDIR /app
COPY package*.json ./
COPY patch-webpack.js .
RUN npm ci --no-progress
RUN $(npm bin)/ng version
COPY . .
RUN npm run build
它总是在npm run build
.
如果我在本地机器上构建项目,它工作得非常好。这是错误日志(不幸的是,描述性不是很好)
ng "build"
Warning: Using differential loading with targets ES5 and ES2016 or higher may
cause problems. Browsers with support for ES2015 will load the ES2016+ scripts
referenced with script[type="module"] but they may not support ES2016+ syntax.
- Generating browser application bundles...
✔ Browser application bundle generation complete.
- Generating ES5 bundles for differential loading...
✔ ES5 bundle generation complete.
- Generating localized bundles...
✖ Localized bundle generation failed.
Call retries were exceeded
Error response from daemon: The command '/bin/sh -c npm run build' returned a non-zero code: 1
Failed to deploy '<unknown> Dockerfile: build/Dockerfile': Can't retrieve image ID from build stream
以下是我希望相关的文件摘录:
{
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
"build": "npm run ng build --prod",
"postbuild": "build/replace-i18n-files.sh dist",
"test": "ng test",
"test-ci": "ng test --code-coverage --karmaConfig=build/karma-ci.conf.js ",
"lint": "ng lint ndb-core --type-check",
"e2e": "ng e2e",
"compodoc": "npx compodoc -c doc/compodoc_sources/.compodocrc.json",
"postinstall": "ngcc && node patch-webpack.js",
"docs:json": "compodoc -p ./tsconfig.json -e json -d .",
"storybook": "npm run docs:json && start-storybook -p 6006",
"build-storybook": "npm run docs:json && build-storybook",
"extract-i18n": "ng extract-i18n --output-path ./src/locale/ && xliffmerge --profile xliffmerge.json de"
},
"private": true,
"dependencies": {
"@angular/animations": "^11.2.14",
"@angular/cdk": "^11.2.13",
"@angular/common": "^11.2.14",
"@angular/compiler": "^11.2.14",
"@angular/core": "^11.2.14",
"@angular/flex-layout": "^11.0.0-beta.33",
"@angular/forms": "^11.2.14",
"@angular/localize": "^11.2.14",
"@angular/material": "^11.2.13",
"@angular/platform-browser": "^11.2.14",
"@angular/platform-browser-dynamic": "^11.2.14",
"@angular/router": "^11.2.14",
"@angular/service-worker": "^11.2.14",
"@ngneat/until-destroy": "^8.0.4",
"@sentry/browser": "^6.2.5",
"angulartics2": "^10.0.0",
"crypto-js": "^4.0.0",
"deep-object-diff": "^1.1.0",
"faker": "^5.5.3",
"font-awesome": "^4.7.0",
"idb": "^6.0.0",
"lodash": "^4.17.21",
"md5": "^2.3.0",
"moment": "^2.29.1",
"ngx-filter-pipe": "^2.1.2",
"ngx-markdown": "^11.1.3",
"ngx-papaparse": "^5.0.0",
"npm": "^7.14.0",
"pouchdb-adapter-memory": "^7.2.2",
"pouchdb-authentication": "^1.1.3",
"pouchdb-browser": "^7.2.2",
"reflect-metadata": "^0.1.13",
"reveal": "0.0.4",
"rxjs": "^6.6.7",
"stream": "0.0.2",
"tslib": "^2.2.0",
"uuid": "^8.3.2",
"webdav": "^4.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1102.3",
"@angular/cli": "^11.2.12",
"@angular/compiler-cli": "^11.2.12",
"@babel/core": "^7.13.8",
"@compodoc/compodoc": "^1.1.11",
"@schematics/angular": "^11.2.3",
"@storybook/addon-actions": "^6.1.21",
"@storybook/addon-essentials": "^6.1.21",
"@storybook/addon-links": "^6.1.21",
"@storybook/angular": "^6.1.21",
"@types/crypto-js": "^4.0.1",
"@types/faker": "^5.5.0",
"@types/file-saver": "^2.0.1",
"@types/jasmine": "~3.6.4",
"@types/lodash": "^4.14.168",
"@types/node": "^14.14.31",
"@types/pouchdb": "^6.4.0",
"babel-loader": "^8.2.2",
"codelyzer": "^6.0.1",
"husky": "^5.1.3",
"jasmine-core": "~3.7.1",
"jasmine-spec-reporter": "~6.0.0",
"karma": "~6.3.1",
"karma-chrome-launcher": "~3.1.0",
"karma-cli": "~2.0.0",
"karma-coverage-istanbul-reporter": "~3.0.3",
"karma-firefox-launcher": "^2.1.0",
"karma-jasmine": "~4.0.1",
"karma-jasmine-html-reporter": "^1.5.4",
"lint-staged": "^10.5.4",
"prettier": "^2.2.1",
"protractor": "~7.0.0",
"ts-node": "^9.1.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.3.0",
"typescript": "^4.1.5",
"webpack": "^4.6.0"
}
}
角.json:
{
... projects/project
"i18n": {
"sourceLocale": "en-US",
"locales": {
"de": "src/locale/messages.de.xlf"
}
}
... projects/project/architect
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"aot": true,
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"localize": true,
"i18nMissingTranslation": "warning",
"assets": [
"src/assets",
"src/favicon.ico",
"src/manifest.json"
],
"styles": [
"node_modules/font-awesome/scss/font-awesome.scss",
"src/ndb-theme.scss",
"src/styles.scss"
],
"scripts": [
"node_modules/marked/lib/marked.js"
]
},
"configurations": {
"production": {
"localize": true,
"budgets": [
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"serviceWorker": true
}
}
}
}