我是Docker的新手。我正在使用“复制”命令复制一些文件,并且工作正常。但是,当我将这些复制命令添加到IF / ElSE语句时,它停止工作并显示错误returned a non-zero code: 127
。请在下面找到我正在使用的代码。
RUN if [ "$FRONT_END_BUILD" = "false" ]; then \
echo "front resources need not to copy" $FRONT_END_BUILD; \
else \
COPY --from=build /application/test.php /application/test.php;\
COPY --from=build /application/reactPage.blade.php /application/reactPage.blade.php;\
COPY --from=build /application/reactPageBlank.blade.php /application/reactPageBlank.blade.php;\
fi
答案 0 :(得分:1)
也许你可以做到。
COPY --from=build /application/test.php /application/test.php.backup
COPY --from=build /application/reactPage.blade.php /application/reactPage.blade.php.backup
COPY --from=build /application/reactPageBlank.blade.php /application/reactPageBlank.blade.php.backup
RUN if [ "$FRONT_END_BUILD" = "false" ]; then \
echo "front resources need not to copy" $FRONT_END_BUILD; \
else \
mv /application/test.php.backup /application/test.php;\
mv /application/reactPage.blade.php.backup /application/reactPage.blade.php;\
mv /application/reactPageBlank.blade.php.backup /application/reactPageBlank.blade.php;\
fi
答案 1 :(得分:0)
您可以执行以下操作(虚拟Dockerfile):
FROM node:10.8-stretch as build
RUN mkdir -p /application/
WORKDIR /application
RUN touch .emptyfile
RUN ls -l
FROM alpine:3.4
ENV TEMP = "false"
ENV First = ""
RUN if [ "TEMP" = "false" ]; then \
echo "front end is not required"; \
else \
echo "helo";\
fi
COPY --from=build /application/.emptyfile /application/resources/views/admin/master.blade.php* /bin/
要聚焦的线是
COPY --from=build /application/.emptyfile /application/resources/views/admin/master.blade.php* /bin/
此行的作用是将复制/application/.emptyfile
(这只是一个虚拟占位符文件),并将此/application/resources/views/admin/master.blade.php*
保留为可选。