【发布时间】:2019-03-30 11:31:22
【问题描述】:
我正在尝试让 Parcel Bundler 从 Dockerfile 中构建资产。但它失败了:
????未找到条目。 在 Bundler.bundle (/usr/local/lib/node_modules/parcel-bundler/src/Bundler.js:260:17) 在错误:服务“webapp”未能构建:命令“/bin/sh -c parcel build index.html”返回非零代码: 1
这是我的 dockerfile:
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',但它仍然不起作用。
任何想法为什么它不起作用?
【问题讨论】:
标签: docker dockerfile parceljs