我刚刚得到了这个错误后,添加了我的角项目对接。
我将这个命令用于:
docker build -t myProject:latest .Dockerfile:
#stage 1
FROM node:latest as node
WORKDIR / app
COPY. .
RUN npm install
RUN npm run build
#stage 2
FROM nginx:alpine
COPY --from=node /app/dist/myProject /usr/share/nginx/html这是一个错误:
[+] Building 37.4s(9 / 9) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 232B 0.0s
=> [internal] load.dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/node:latest 1.8s
=> [internal] load build context 2.6s
=> => transferring context: 4.04MB 2.5s
=> [1 / 5] FROM docker.io/library/node:latest @sha256:3e2e7e08f088c7c9c0c836622f725540ade205f10160a91dd3cc899170d410ef 0.0s
=> CACHED[2 / 5] WORKDIR /app 0.0s
=> [3/5] COPY. . 7.8s
=> [4/5] RUN npm install 15.4s
=> ERROR[5 / 5] RUN npm run build 9.9s
------
> [5/5] RUN npm run build:
#9 0.792
#9 0.792 > client@0.0.0 build
#9 0.792 > ng build
#9 0.792
#9 2.803 - Generating browser application bundles (phase: setup)...
#9 9.807 node:internal/crypto/hash:67
#9 9.807 this[kHandle] = new _Hash(algorithm, xofLen);
#9 9.807 ^
#9 9.807
#9 9.807 Error: error:0308010C:digital envelope routines::unsupported
#9 9.807 at new Hash (node:internal/crypto/hash:67:19)
#9 9.807 at Object.createHash (node:crypto:133:10)
#9 9.807 at BulkUpdateDecorator.hashFactory (/app/node_modules/webpack/lib/util/createHash.js:145:18)
#9 9.807 at BulkUpdateDecorator.update (/app/node_modules/webpack/lib/util/createHash.js:46:50)
#9 9.807 at RawSource.updateHash (/app/node_modules/webpack/node_modules/webpack-sources/lib/RawSource.js:77:8)
#9 9.807 at NormalModule._initBuildHash (/app/node_modules/webpack/lib/NormalModule.js:880:17)
#9 9.807 at handleParseResult (/app/node_modules/webpack/lib/NormalModule.js:946:10)
#9 9.807 at /app/node_modules/webpack/lib/NormalModule.js:1040:4
#9 9.807 at processResult (/app/node_modules/webpack/lib/NormalModule.js:755:11)
#9 9.807 at /app/node_modules/webpack/lib/NormalModule.js:819:5 {
#9 9.807 opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
#9 9.807 library: 'digital envelope routines',
#9 9.807 reason: 'unsupported',
#9 9.807 code: 'ERR_OSSL_EVP_UNSUPPORTED'
#9 9.807 }
#9 9.807
#9 9.807 Node.js v18.2.0
------
executor failed running[/ bin / sh - c npm run build]: exit code: 1
PS D:\dotnet Core\client> set NODE_OPTIONS = --openssl - legacy - provider
PS D:\dotnet Core\client> docker build -t myprojectlient:latest.
[+] Building 15.0s (10/10) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 32B 0.0s
=> [internal] load.dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/node:latest 3.1s
=> [auth] library / node:pull token for registry-1.docker.io 0.0s
=> [internal] load build context 3.2s
=> => transferring context: 4.04MB 3.1s
=> [1 / 5] FROM docker.io/library/node:latest @sha256:3e2e7e08f088c7c9c0c836622f725540ade205f10160a91dd3cc899170d410ef 0.0s
=> CACHED[2 / 5] WORKDIR /app 0.0s
=> CACHED[3 / 5] COPY . . 0.0s
=> CACHED[4 / 5] RUN npm install 0.0s
------我发现a solution建议降低节点版本的级别。
正如您在错误消息中看到的,它提到了用于Node.Js的版本18.2.0,但是我在node -v中获得了16.13.1版本。
发布于 2022-05-26 15:08:27
若要降级到节点版本16,请执行以下操作
#stage 1
FROM node:16 as node
WORKDIR /app
COPY . .
RUN npm install
RUN npm run build
#stage 2
FROM nginx:alpine
COPY --from=node /app/dist/myProject /usr/share/nginx/html如果需要使用webpack 4,正如您所链接的解决方案所暗示的那样,那么您需要确保这是您在package.json和Packy-lock.json文件中引用的内容。
发布于 2022-09-30 05:47:23
除非您想要将您的角度框架更新为最新版本,否则正确的方法是使用NODE_OPTIONS='--openssl-legacy-provider'标志进行构建:
RUN NODE_OPTIONS='--openssl-legacy-provider' npm run build见详细信息here
https://stackoverflow.com/questions/72393464
复制相似问题