问题描述
我有一个多阶段 Dockerfile,它在开发中效果很好,但是当我尝试为生产部署时,构建文件夹保持为空。我看不出哪里出了问题,应该对我有用。这是 Dockerfile:
ARG NODE_VERSION=13
ARG Nginx_VERSION=1.17
# "development" stage
FROM node:${NODE_VERSION}-alpine AS api_platform_client_common
EXPOSE 3000
workdir /usr/src/client
RUN yarn global add @api-platform/client-generator
RUN apk --no-cache --virtual build-dependencies add \
python \
make \
build-base
# prevent the reinstallation of node modules at every changes in the source code
copY package.json yarn.lock ./
RUN set -eux; \
yarn install
copY . ./
VOLUME /usr/src/client/node_modules
#ENV HTTPS true
FROM api_platform_client_common AS api_platform_client_development
CMD ["yarn","dev"]
# "build" stage
# depends on the "development" stage above
FROM api_platform_client_common AS api_platform_client_build
workdir /usr/src/client
ARG REACT_APP_API_ENTRYPOINT
ENV NODE_ENV production
RUN set -eux; \
npm run build
#yarn build
RUN npm install -g serve
CMD serve -s build -l 3000
是更复杂的 docker-compose 设置的一部分,但我认为其余文件无关紧要。当构建步骤发生时,我有日志说它已经生成:
File sizes after gzip:
914.33 KB build/static/js/2.fb074eef.chunk.js
25.57 KB build/static/js/main.2c9c53c7.chunk.js
23.82 KB build/static/css/main.581e45d5.chunk.css
12.56 KB build/static/css/2.5dd93f16.chunk.css
773 B build/static/js/runtime-main.09b85ec0.js
The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.
但是当我访问 npm serve 提供的内容时,我只会看到带有空白窗口的“构建中的文件/”。当我在我的 docker 容器中运行“ls /usr/src/client/build”时,它实际上是空的...
有人能看到有什么问题吗?
谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)