简体   繁体   English

GitLab CI 构建多个 docker + 端到端测试

[英]GitLab CI build multiple dockers + test end-to-end

I want to build and test multiple dockers from one repo in GitLab.我想从 GitLab 中的一个 repo 构建和测试多个 docker。 This monorepo holds a few microservices that work together.这个 monorepo 包含一些协同工作的微服务。
We have have a working docker compose up to aid local dev, so thats a start.我们有一个可用的docker compose up来帮助本地开发人员,所以这是一个开始。 Goal is move build + test to GitLab, run a E2E test (end-to-end) of these dockers, and let GitLab upgrade our staging environment.目标是将 build + test 移至 GitLab,对这些 docker 运行 E2E 测试(端到端),并让 GitLab 升级我们的暂存环境。

The building of multiple dockers is just multiple jobs in build stage of the (one) pipeline, testing can happen per docker i guess, which leaves testing the whole with multiple dockers running in a (or the?) staging environment.多个 docker 的构建只是(一个)管道的构建阶段的多个作业,我猜每个 docker 都可以进行测试,这使得在(或?)登台环境中运行多个 docker 来测试整个。

  1. How can GitLab run E2E tests on multiple dockers? GitLab 如何在多个 docker 上运行 E2E 测试? (or is this unwise to begin with) (或者这是不明智的开始)

  2. Would we need Kubernetes for the inter-docker mapping (network, volumes, but also dependencies) that docker-compose now facilitates?我们是否需要 Kubernetes 来实现 docker-compose 现在促进的 docker 间映射(网络、卷以及依赖项)?

We are using a self-hosted GitLab CE instance.我们正在使用自托管的 GitLab CE 实例。

Update: cut shorter, use proper terminology.更新:缩短,使用适当的术语。

I haven't worked on PHP, and never done Docker build for multi module, although I tried out a quick example of multi module kind of thing for Nodejs.我没有研究过 PHP,也从来没有为多模块做过 Docker 构建,尽管我为 Nodejs 尝试了一个多模块类型的快速示例。 Check this Repo检查这个回购

Refer to .gitlab-ci.yml which builds two independent hello world kind of nodejs module.参考.gitlab-ci.yml构建了两个独立的 hello world 类 nodejs 模块。

I now adapted this to build docker images separately.我现在将其调整为单独构建 docker 镜像。

Original answer (question changed 12th July)原始答案(问题于 7 月 12 日更改)

You haven't mentioned what documentation you are referring to.您还没有提到您所指的文档。 You should be able to configure using .gitlab-ci.yml您应该能够使用.gitlab-ci.yml进行配置

AFAIK Building docker image should be programming language agnostic. AFAIK 构建 docker 镜像应该与编程语言无关。 If you can run docker build .如果您可以运行docker build . on your local.在你的本地。 Following documentation should help https://docs.gitlab.com/ee/ci/docker/using_docker_build.html以下文档应该有助于https://docs.gitlab.com/ee/ci/docker/using_docker_build.html

You can use Gitlab pipeline for testing < - > building images.您可以使用 Gitlab 管道来测试 <-> 构建图像。 Refer to https://docs.gitlab.com/ee/ci/pipelines.html参考https://docs.gitlab.com/ee/ci/pipelines.html

Refer to this for PHP build - https://docs.gitlab.com/ee/ci/examples/php.html请参阅此 PHP 构建 - https://docs.gitlab.com/ee/ci/examples/php.html

Answering my own question, 2 years of experience later.回答我自己的问题,2 年后的经验。

  • For a normal (single-project/service) repo the CI is straightforward.对于普通(单项目/服务)存储库,CI 很简单。
  • For a monorepo, an end-to-end test is straightforward.对于 monorepo,端到端测试很简单。

You can combine these aspects by having a repo with submodules, its essentially both.您可以通过拥有一个带有子模块的 repo 来组合这些方面,它本质上是两个。 But this can cause overhead if done continiously and mostly usefull for proofing beta/alpha and release-candidates.但是,如果连续进行并且对于验证 beta/alpha 和发布候选者非常有用,这可能会导致开销。

If you know more options, feel free to add here.如果您知道更多选项,请随时在此处添加。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM