CircleCI - 使用附加数据库映像运行构建的 docker 映像测试 - 连接被拒绝
我编写了一个 Circleci 配置,用于创建应用程序的 docker 映像、运行它、运行测试并将其推送到 DockerHub。
但我不知道如何运行需要数据库的测试。
这是我用于运行测试的配置的一部分。
executors:
docker-executor:
environment:
DOCKER_BUILDKIT: "1"
docker:
- image: cimg/base:2021.12
jobs:
run-tests:
executor: docker-executor
steps:
- setup_remote_docker:
version: 20.10.7
docker_layer_caching: true
- run:
name: Load archived test image
command: docker load -i /tmp/workspace/testimage.tar
- run:
name: Start Container
command: |
docker create --name app_container << pipeline.parameters.app_image >>:testing
docker start app_container
- run:
name: Run Tests
command: |
docker exec -it app_container ./vendor/bin/phpunit --log-junit testresults.xml --colors=never
如何在此处添加 MySQL 服务,以及如何将其与我的应用程序 docker 映像连接,以便我可以运行需要数据库的测试?
I wrote a circleci config for creating docker image of my app, running it, running tests, and pushing it to DockerHub.
But I can't figure out how to run tests that require a database.
Here is part of my config for running tests.
executors:
docker-executor:
environment:
DOCKER_BUILDKIT: "1"
docker:
- image: cimg/base:2021.12
jobs:
run-tests:
executor: docker-executor
steps:
- setup_remote_docker:
version: 20.10.7
docker_layer_caching: true
- run:
name: Load archived test image
command: docker load -i /tmp/workspace/testimage.tar
- run:
name: Start Container
command: |
docker create --name app_container << pipeline.parameters.app_image >>:testing
docker start app_container
- run:
name: Run Tests
command: |
docker exec -it app_container ./vendor/bin/phpunit --log-junit testresults.xml --colors=never
How to add MySQL service here, and how to connect it with my app docker image so I can run tests that require database?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论