GitLab CI .yaml 中的两个 Docker 镜像

jea*_*rme 5 docker gitlab-ci gitlab-ci-runner

我正在尝试在 GitLab 上扩展我的一项 CI 工作:

deploy-stage:
  image: python:3.5
  environment: stage
  script:
  - pip install awscli
  - aws s3 cp dist s3://$S3_BUCKET_STAGE/ --recursive
  only:
    - stage
Run Code Online (Sandbox Code Playgroud)

我想要实现的是能够从 Vue.js 文件构建代码(通过使用npm run build),但要做到这一点,我需要 Node.js。但我还需要 Python 才能将文件上传到 S3。我怎样才能做到这一点?

jea*_*rme 9

经过这里的一些帮助,我最终得到了这样的gitlab-ci.yml配置:

build-stage:
  stage: build
  image: node:latest
  environment:
    name: stage
  script:
    - npm install
    - npm run build-stage
  only:
    - stage
  artifacts:
    expire_in: 2 hrs
    paths:
      - dist/

deploy-stage:
  stage: deploy
  image: python:3.5
  environment:
    name: stage
  script:
    - pip install awscli
    - aws s3 cp dist s3://$S3_BUCKET_STAGE/ --recursive
  dependencies:
    - build-stage
  only:
    - stage
Run Code Online (Sandbox Code Playgroud)

它简单易读。不需要来自 Docker 的任何自定义图像 - 只需完成一项工作,然后将结果移至下一项工作。奇迹般有效。