【发布时间】:2022-01-13 08:57:00
【问题描述】:
我正在运行这个命令
docker build -t project
在第 13 步安装失败
这是docker文件内容
### Base
FROM node:12-alpine as base
ENV NODE_ENV=production
RUN apk update --no-cache
RUN mkdir /app && chown -R node:node /app
USER node
WORKDIR /app
# Copy base dependencies describing
COPY --chown=node:node ./src ./src
COPY --chown=node:node ./static ./static
COPY --chown=node:node ./nest-cli.json ./
COPY --chown=node:node ./package*.json ./
COPY --chown=node:node ./tsconfig*.json ./
COPY --chown=node:node ./.env.${NODE_ENV} ./
RUN npm install --only=production
### Builder
FROM base as builder
RUN npm install --only=development
RUN npm run build
### Runtime
FROM node:12-alpine as runtime
ENV NODE_ENV=production
WORKDIR /app
# Copy runtime dependencies
COPY --chown=node:node --from=base /app/node_modules ./node_modules
COPY --chown=node:node --from=base /app/.env.${NODE_ENV} ./
COPY --chown=node:node --from=base /app/package.json ./
COPY --chown=node:node --from=base /app/static ./static
COPY --chown=node:node --from=builder /app/dist ./dist
CMD ["npm", "run", "start:prod"]
失败了
运行 npm install --only=production
我认为这是由节点图像引起的,您建议如何解决此问题?任何帮助将不胜感激!
这是控制台中出现的错误堆栈
> sharp@0.27.2 install /app/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
ERR! sharp Use with musl 1.2.2 requires manual installation of libvips >= 8.10.5
info sharp Attempting to build from source via node-gyp but this may fail due to the above error
info sharp Please see https://sharp.pixelplumbing.com/install for required dependencies
gyp ERR! find Python
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python" can be used
gyp ERR! find Python - "python" is not in PATH or produced an error
gyp ERR! find Python checking if "python2" can be used
gyp ERR! find Python - "python2" is not in PATH or produced an error
gyp ERR! find Python checking if "python3" can be used
gyp ERR! find Python - "python3" is not in PATH or produced an error
gyp ERR! find Python
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
gyp ERR! find Python (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python npm config set python "/path/to/pythonexecutable"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Python installation to
【问题讨论】:
-
使基于 Alpine 的图像更小的原因之一是使用名为 musl libc 的包代替“普通”GNU libc,但偶尔会出现兼容性问题。在各种
FROM行中删除单词-alpine有帮助吗?