【问题标题】:ssh to a remote server using gitlab ci使用 gitlab ci SSH 到远程服务器
【发布时间】:2021-04-21 18:35:39
【问题描述】:

我想将我的 docker 镜像部署到公共远程服务器中,在该服务器中,我会将其连接到我的 gitlab 容器注册表以提取镜像并运行 docker-compose(在服务器中)

我的问题是如何使用 gitlab ci 文件 ssh 到该服务器?

gitlab ci.yml 文件

stages:
  - build
cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - .cache/
build:
  image: docker:19.03.12
  stage: build 
  services:
    - docker:19.03.12-dind
  variables:
    IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
  script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker build -t registry.gitlab.com/ossama.mahjour97/test-dockerfile/myimage .
    - docker push registry.gitlab.com/ossama.mahjour97/test-dockerfile/myimage

【问题讨论】:

    标签: docker docker-compose gitlab-ci continuous-deployment gitlab-ci-runner


    【解决方案1】:

    使用 sshpass 可以完美运行

    【讨论】:

    • 你能补充一点细节吗?就像您的 gitlab-ci.yml 使用该选项时的样子?
    猜你喜欢
    • 2022-07-11
    • 2016-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-20
    • 2021-05-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多