Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

image: docker:latest  services:   - docker:dind  before_script:   - docker info   - docker-compose --version  buildJob:   stage: build   tags:     - docker   script:     - docker-compose build 

But in ci-log I receive message:

$ docker-compose --version /bin/sh: eval: line 46: docker-compose: not found 

What am I doing wrong?

like image 657
jonua Avatar asked Oct 05 '16 07:10

jonua


People also ask

What is Docker compose CI Yml?

Docker Compose is a tool that was developed to help define and share multi-container applications. With Compose, we can create a YAML file to define the services and with a single command, can spin everything up or tear it all down.


1 Answers

Docker also provides an official image: docker/compose

This is the ideal solution if you don't want to install it every pipeline.

Note that in the latest version of GitLab CI/Docker you will likely need to give privileged access to your GitLab CI Runner and configure/disable TLS. See Use docker-in-docker workflow with Docker executor

variables:   DOCKER_HOST: tcp://docker:2375/   DOCKER_DRIVER: overlay2  # Official docker compose image. image:   name: docker/compose:latest  services:   - docker:dind  before_script:   - docker version   - docker-compose version  build:   stage: build   script:     - docker-compose down     - docker-compose build     - docker-compose up tester-image 

Note that in versions of docker-compose earlier than 1.25:

Since the image uses docker-compose-entrypoint.sh as entrypoint you'll need to override it back to /bin/sh -c in your .gitlab-ci.yml. Otherwise your pipeline will fail with No such command: sh

    image:       name: docker/compose:latest       entrypoint: ["/bin/sh", "-c"] 
like image 196
webmaster777 Avatar answered Sep 29 '22 00:09

webmaster777