Search code examples
dockerdocker-composegitlab-cigitlab-ci-runnergitlab-pipelines

Gitlab pipeline running a different docker image from subdirectory


I want to run performance tests in in gitlab pipeline as a separate stage. For that I want to raise a different image with docker container than what I use for all other stages.

So my project looks something like this: project:

-src/
  --gl-pipeline.yml
-.gitlab-ci.yml
-docker-compose.yml
-performance-tests/
  --docker-compose.yml(performance image with bzt installed)
  --perfomance-tests-jmeter.yml

in gl-pipeline.yml I've set up a task like

performance-tests:
  image: my_main_image
  stage: performance-tests
  script:
    - cd ./performance-tests && bzt perfomance-tests-jmeter.yml

Now when I run my task in the pipeline bzt perfomance-tests-jmeter.yml is being executed in the docker image defined in the root of the project, hence fails to run bzt as it is not installed there. how do I setup to run image in my performance-tests/ subdirectory?


Solution

  • You can define the image used per stage so in order to use this custom image you should first build this image (the one with bzt installed), push it to a docker registry and then use it instead of your main image in the performance-tests target

    performance-tests:
      image: <image_you_built_and_pushed_to_registry>
      stage: performance-tests
      script:
        - cd ./performance-tests && bzt perfomance-tests-jmeter.yml
        ```