我有一个Dockerfile,其中包含多个构建阶段。中间阶段运行测试。如果测试失败,我希望构建停止,但它会继续执行以下步骤。您可以看到输出结果,它超出了失败的RUN命令。
# Base image
FROM python:3.5 as base
# For running tests
FROM base
WORKDIR /root
RUN mkdir /root/src
ADD src/requirements.txt /root/src
RUN pip install -r /root/src/requirements.txt
ADD . /root
RUN ["/bin/bash", "-c", "cd test; ./run-tests.sh"]
# For publishing src files
FROM base
ADD src /root/src
ADD .pypirc /root/.pypirc
WORKDIR /root/src
CMD python setup.py sdist upload -r local
输出:
Step 6/13 : RUN pip install -r /root/src/requirements.txt
---> Using cache
---> 56fa7fc2f2e8
Step 7/13 : ADD . /root
---> 74c52977edcf
Step 8/13 : RUN ["/bin/bash", "-c", "cd test; ./run-tests.sh"]
---> Running in 68a184ab54af
...
----------------------------------------------------------------------
Ran 1 test in 10.122s
FAILED (failures=1)
The command '/bin/bash -c cd test; ./run-tests.sh' returned a non-zero code: 1
running sdist
running egg_info
...
running upload
Submitting dist/<artifact-name>-2.6.1.2.tar.gz to https://<subdomain>.jfrog.io/<context>/api/pypi/python-local
...
1
。命令/bin/bash -c cd test; ./run-tests.sh
返回了非零代码:1。 - Ragpython setup.py sdist upload -r local
,那么你应该注意到即使构建成功,它也不会在构建期间运行。它是在docker build
命令退出后运行的。请更新你的问题,包括命令本身的完整输出以及在构建完成后是否看到提示。 - BMitchset -e
。 - Rag