Run docker-compose build in .gitlab-ci.yml

前端 未结 9 1223
臣服心动
臣服心动 2020-12-12 14:06

I have a .gitlab-ci.yml file which contains following:

image: docker:latest

services:
  - docker:dind
         


        
9条回答
  •  爱一瞬间的悲伤
    2020-12-12 14:49

    I think most of the above are helpful, however i needed to collectively apply them to solve this problem, below is the script which worked for me

    I hope it works for you too

    Also note, in your docker compose this is the format you have to provide for the image name

    ///:

    image:
      name: docker/compose:latest
      entrypoint: ["/bin/sh", "-c"]
    
    variables:
      DOCKER_HOST: tcp://docker:2375/
      DOCKER_DRIVER: overlay2
    
    services:
      - docker:dind
    
    stages:
    - build_images
    
    before_script:
      - docker version
      - docker-compose version
      - docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY
    
    build:
      stage: build_images
      script:
        - docker-compose down
        - docker-compose build
        - docker-compose push
    

提交回复
热议问题