以Shell执行程序和Docker映像为基础的Gitlab CI

问题描述 投票:0回答:1

我在使用docker image的gitlab-ci时遇到麻烦。在互联网上搜索了很多内容,但仍然感到困惑。

问题:我需要使用docker映像作为gitlab ci构建的基础。

我正在使用shell executor,并且在我的gitlab-ci.yml中,我定义了这样的图像:

image: "registry.gitlab.com/my_projects/my_repo:latest"

我已将此docker映像推送到gitlab注册表。它包含构建所需的核心库(ruby,node,npm等)

我还在gitlab-runner / config.toml文件中定义了[runners.docker]设置,其中包含以下几行:

[[runners]]
  executor = "shell"
  [runners.docker]
    services = ["registry.gitlab.com/my_project/my_repo:latest"]

问题是gitlab-runner忽略了该图像。

这是我使用的教程:

https://dev.to/zimski/the-complete-guide-to-setup-a-cicd-for-rails-5-on-gitlab-2f2d

是否可以将docker映像用作gitlab-ci中shell executor中的基础?

docker gitlab gitlab-ci
1个回答
0
投票

当您使用外壳执行程序时,您的作业将像手动运行该外壳一样执行。如果您随后要使用docker映像进行构建,则只需像在shell中使用docker映像进行构建时手动执行的操作即可。

[根据编写方式,您想在.gitlab-ci.yml文件中使用image标记,并且正在设置[runners.docker]设置,这听起来像您想使用docker executor。注册运行程序时,可以选择此选项而不是shell执行程序。您可以在此处找到有关执行者的更多信息:

https://docs.gitlab.com/runner/configuration/advanced-configuration.html#the-executors

© www.soinside.com 2019 - 2024. All rights reserved.