Skip to content

Instantly share code, notes, and snippets.

@bzamecnik
Created August 8, 2018 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bzamecnik/bd8a98616e03d92929afb5bd68bd6d85 to your computer and use it in GitHub Desktop.
Save bzamecnik/bd8a98616e03d92929afb5bd68bd6d85 to your computer and use it in GitHub Desktop.

How not to run docker-compose in .gitlab-ci.yml?

Official docker-compose docs recommend this installer:

curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

Curl is not available in docker:lastest image, so let's use wget.

Wrong:

my_integration_test:
  stage: test
  image: docker:latest
  before_script:
  - wget https://github.com/docker/compose/releases/download/1.22.0/run.sh -O /usr/local/bin/docker-compose
  - chmod +x /usr/local/bin/docker-compose
  script:
  - docker-compose -f docker-compose.tests.yml run --rm tests pytest tests/integration_test.py
.FileNotFoundError: [Errno 2] No such file or directory: './docker-compose.api.test.yml'
ERROR: Job failed: exit code 1

It turns out that the installer mounts current directory as volume, hiding our source code!

Better:

Just install via pip:

my_integration_test:
  stage: test
  image: docker:latest
  before_script:
    - apk add --no-cache py-pip
    - pip install docker-compose
  script:
  - docker-compose -f docker-compose.tests.yml run --rm tests pytest tests/integration_test.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment