我正在尝试让 Parcel Bundler 从 Dockerfile 中构建资产。但它失败了:
未找到条目。在 Bundler.bundle (/usr/local/lib/node_modules/parcel-bundler/src/Bundler.js:260:17) at ERROR: Service 'webapp' failed to build: The command '/bin/sh -c parcel build index.html' 返回一个非零代码:1
这是我的码头文件:
FROM node:8 as base
WORKDIR /usr/src/app
COPY package*.json ./
# Development
FROM base as development
ENV NODE_ENV=development
RUN npm install
RUN npm install -g parcel-bundler
WORKDIR /usr/src/app
RUN parcel build index.html <----- this is where its failing!
#RUN parcel watch index.html
# Uncomment to use Parcel's dev-server
#CMD [ "npm", "run", "parcel:dev" ]
#CMD ["npm", "start"]
# Production
FROM base as production
ENV NODE_ENV=production
COPY . .
RUN npm install --only=production
RUN npm install -g parcel-bundler
RUN npm run parcel:build
CMD [ "npm", "start" ]
注意:我试图让它首先在开发模式下运行。
当我“登录”容器时,我发现这个命令确实失败了:
# /bin/sh -c parcel build index.html
但这有效:
# parcel build index.html
这有效:
# /bin/sh -c "parcel build index.html"
但是在 Dockerfile 中使用这些变体仍然不起作用:
RUN /bin/sh -c "parcel build index.html"
或者
RUN ["/bin/sh", "-c", "parcel build index.html"]
注意:我也尝试了 'bash' 而不是 'sh',但它仍然不起作用。
任何想法为什么它不起作用?