【发布时间】:2023-04-03 19:08:02
【问题描述】:
我对 Docker 和 Docker compose 还很陌生。
我想使用 docker compose 来测试我的项目并在测试正常时发布它。如果测试失败,它根本不应该发布应用程序。
这是我的 docker-compose.yml
version: '3'
services:
mongodb:
image: mongo
test:
build:
context: .
dockerfile: Dockerfile.tests
links:
- mongodb
publish:
build:
context: .
dockerfile: Dockerfile.publish
?? # I want to say here that publish step is dependent to test.
之后,在我的testAndPublish.sh 文件中,我想说:
docker-compose up
if [ $? = 0 ]; then # If all the services succeed
....
else
....
fi
因此,如果测试或发布步骤失败,我不会推送它。
如何在 docker-compose 中构建类似流程的步骤? 谢谢。
【问题讨论】:
标签: docker continuous-integration docker-compose dockerfile build-automation