[英]Gitlab Fargate unable to pull image during CI/CD
配置文件
concurrent = 100
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "xyz_project_name"
url = "https://gitlab.com/"
token = "yieSD7McA-WFMtFv5nzg"
executor = "custom"
builds_dir = "/opt/gitlab-runner/builds"
cache_dir = "/opt/gitlab-runner/cache"
[runners.custom]
privileged = true
config_exec = "/opt/gitlab-runner/fargate"
config_args = ["--config", "/etc/gitlab-runner/fargate.toml", "custom", "config"]
prepare_exec = "/opt/gitlab-runner/fargate"
prepare_args = ["--config", "/etc/gitlab-runner/fargate.toml", "custom", "prepare"]
run_exec = "/opt/gitlab-runner/fargate"
run_args = ["--config", "/etc/gitlab-runner/fargate.toml", "custom", "run"]
cleanup_exec = "/opt/gitlab-runner/fargate"
cleanup_args = ["--config", "/etc/gitlab-runner/fargate.toml", "custom", "cleanup"]
.gitlab-ci.yaml
image: docker:latest
stages:
- install_dependencies
- lint
- bundle
- build
- deploy
install_dependencies:
stage: install_dependencies
image: node:14
script:
- node -v
- npm -v
- ls node_modules
- npm install --unsafe-perm
artifacts:
paths:
- node_modules/
- version.v
- repo.name
lint:
image: node:14
stage: lint
script:
- npm run lint
bundle:
image: node:14
stage: bundle
script:
- npm run build:prod
artifacts:
paths:
- dist/
build:
stage: build
image: aws-docker:2.0.0
services:
- docker:dind
before_script:
- aws ecr get-login-password | docker login --username AWS --password-stdin $AWS_ECR_REGISTRY
script:
- docker build -t $DOCKER_REGISTRY $DOCKER_REGISTRY:latest .
- docker push $DOCKER_REGISTRY:latest
管道給出以下錯誤
$ node -v
bash: line 140: node: command not found
ERRO[2022-04-20T03:49:47Z] Application execution failed
這條管道與普通的 GitLab 跑步者一起工作正常但是當我將它移到 Fargate 跑步者時,它給出了這個錯誤。 我認為 Fargate runner 無法拉取圖像
我能做什么,我可以在容器映像中安裝節點 v-14。 但是aws-docker:2.0.0
呢
感謝您抽出寶貴的時間來詳細說明您的要求,這真的很有幫助!
fargate 自定義執行程序完全忽略image:
指令,如文檔中所述:
gitlab-ci.yml
文件中的image
和service
關鍵字將被忽略。 跑步者僅使用任務定義中指定的值。
如文檔中所述,在設置 Fargate Runner 時,您必須准備一個包含您需要的所有軟件的圖像。 這必須提前完成。 該作業使用在設置文檔的第 6 步中創建的 ECS 任務定義中定義的此圖像。
但是 aws-docker:2.0.0 呢
Fargate 的另一個關鍵限制是無法在 Fargate 內部使用docker
,因為在容器內部使用docker
需要容器具有特權,但 AWS 在 Fargate 上禁止特權容器,因此這是不可能的。
另請注意,即使不存在此限制,您也會遇到與services:
與image:
-- 執行程序會忽略該服務。
有一些替代方法可以構建和推送不需要 docker 守護進程(因此不需要特權容器)的圖像,例如使用 kaniko構建圖像。 您還可以查看 GitLab 博客,了解有關如何使用 AWS CodeBuild 在 Fargate 上構建容器的指南
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.