我在将Docker镜像部署到AWS LightSail
时遇到了问题。我正在使用GitLab上的私有容器,并且我的镜像在构建后推送到那里。我为ci/cd创建了第二个阶段,以便将镜像部署到LightSail。
image: docker:19.03.12
services:
- docker:19.03.12-dind
build:
stage: build
before_script:
- docker login registry.gitlab.com --username $UserName -p $CiCdToken
script:
- docker build -t registry.gitlab.com/nickname/testprojectname .
- docker push registry.gitlab.com/nickname/testprojectname
deploy:
stage: deploy
image: python:latest
script:
- pip install awscli
- pip install lightsailctl
- aws lightsail push-container-image --service-name testprojectname --label testprojectname --image registry.gitlab.com/nickname/testprojectname
不幸的是,Python没有 lightsailctl
工具,而且 awscli
也不支持 lightsail
。
- 我不知道如何将从GitLab私有容器构建的容器推送到
lightsail
。 - 我不知道如何通过 runner 向
aws ctl
提供凭证。
祝好, Marcin Włoch
bentolor/docker-dind-awscli
,并借鉴了你的代码的一些部分,最终成功了!顺便说一句,如果有人在 Lightsail 中使用环境变量来存储秘密或凭据,建议在aws lightsail create-container-service-deployment
命令的末尾添加>/dev/null
,以防止这些秘密在 CI 日志中输出。 - IMB